Boost logo

Boost :

Subject: Re: [boost] Library for configuration file parsing
From: Denis Shevchenko (for.dshevchenko_at_[hidden])
Date: 2010-11-29 15:43:42


On 29.11.2010 22:39, Stewart, Robert wrote:
> One cannot reparse what hasn't been parsed. I suggest "reparse" and "parse" or "reload" and "load" for those two functions. (The latter pair is slightly easier to say.)
Hello Robert!

"Parse" and "load". Strictly speaking you are right, because parsing is
just one of the steps work with the configuration file. So from a
technical point of view the name "load" preferably than "parse". Thanks.
>
> Have you considered the ability to parse multiple files thereby augmenting the data with each new file's content rather than replacing what had been parsed already?
Confess, I have not thought about it. Do you think this possibility is
really useful?
> That, in turn, means that reloading or replacing content must invalidate outstanding references/subscriptions
I do not use references. If in configuration file exists option "Host":
------------------------
Host 44.67.42.90
------------------------
and we register it:
cf::configurator.add_option( "Host" ).default_value( "127.0.0.1" );

then after parsing we have object cf::option with name "Host" and with
value "44.67.42.90" (that is, in fact, two std::string). If user obtains
it value:
std::string host = cf::configurator.get_value( "Host" );

he just gets a copy of "44.67.42.90".

And if configuration will be changed:
------------------------
Host 56.89.45.44
------------------------
and after that user calls reparse() function, value of corresponding
object cf::option (with name "Host") will be replaced by "56.89.45.44".
After that user can obtain (already new) value:
std::string host = cf::configurator.get_value( "Host" );

And if after that user again changes configuration file and comment out
"Host" option:
------------------------
// Host 56.89.45.44
------------------------
and calls reparse() function, and obtains it value:
std::string host = cf::configurator.get_value( "Host" );

he gets a copy of initial default value "127.0.0.1".

- Denis


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