Re: Parsing project file



On Sunday 24 August 2003 04:26, Russell Shaw wrote:

Hi,

Is there any library or standard tool for reading in
a list of name=value pairs and ignoring comments?
Preferably, a name=value pair could be added or
modified in the program, then inserted into the
project file.

The Lexical Scanner (GScanner) that comes with GLib should be able to do that, 
but of course you could also go for an sscanf() type of solution.

http://developer.gnome.org/doc/API/2.0/glib/glib-Lexical-Scanner.html


We use GScanner in ed2k-gtk-gui to read in the options file, which contains 
lines like

icon_theme = "h2o"
max_logfile_size = 1000
toolbar_show_search_options = false


The function opt_read() in the following code is an example of how to use it - 
maybe you find it useful.

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/ed2k-gtk-gui/ed2k_gui/ed2k_gui/options.c?rev=HEAD&content-type=text/vnd.viewcvs-markup
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/ed2k-gtk-gui/ed2k_gui/ed2k_gui/options.h?rev=HEAD&content-type=text/vnd.viewcvs-markup

Cheers
-Tim





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]