Boost logo

Boost :

From: Preston A. Elder (prez_at_[hidden])
Date: 2005-05-14 00:33:07


The INI file parser module of program_options needs to be changed. For
some reason, the comment delimiter has been changed from ';' to '#'. The
bigger problem is this has been taken beyond the first character of the
line and there is no escaping ability!

The more common INI file comment behavior is:
'#' is a comment ONLY if it is the first character of the line
';' is a comment from that point of the line on, unless preceeded by a '\'
(or more accurately, an odd number of '\' characters, since you could
theoretically do \\\;, to translate to \; when made a string).

I have written my own INI parser for my own purposes, but it is not
associated with program_options, which makes its usefulness in that
context limited (without a lot of extra coding, etc).

You can view the source here:
http://www.neuromancy.net/viewcvs/Mantra-I/src/file/inifile.cpp?root=mantra&rev=1.10&view=auto

My own implementation does differ from the standard INI file parsing
convention in allowing line continuation, ie.
Allowing:
my_option = some text \
            some more text
And it is interpreted as 'some text some more text'.

One big selling point of my implementation is that it uses boost::spirit
(the lexical parser) to do the parsing - so the logic for parsing is
encoded in the lexical parsing language, not in code. Theoretically, this
means you should be able to use my implementation directly, and adapt the
code from IniFile::Load() that uses it for program_options relatively
easily, and not have to worry about the parsing logic itself.

Otherwise (if you don't want to use a lexical-parser based implementation,
or my version specifically), could we please stick to the standards, and
allow '#' as a comment ONLY from the beginning of the line, and then ';'
from any point in the line (as '#' is treated in the current version)
(with the 'escaping' rules).

Thanks,

-- 
PreZ :)
Founder. The Neuromancy Society (http://www.neuromancy.net)

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk