[program_options] call notify() twice?
My app has a configuration file. We don't know where it will be for sure, so we are planning to make the location of the file a commandline option. So, after reading the commandline option, we will want to parse the config file. Is this a resaonable and legal thing to do? We will need to call the map's notify() function twice, if I interpret it correctly. I suppose I could try it, but I wanted to make sure I didn't use a feature that is not part of the design, and have it disabled on me in the future. -- Marty Fried public.forums@gmail.com Left Coast, USA.
Marty Fried wrote:
My app has a configuration file. We don't know where it will be for sure, so we are planning to make the location of the file a commandline option.
So, after reading the commandline option, we will want to parse the config file.
Is this a resaonable and legal thing to do? We will need to call the map's notify() function twice, if I interpret it correctly. I suppose I could try it, but I wanted to make sure I didn't use a feature that is not part of the design, and have it disabled on me in the future.
You don't need to call 'notify' twice -- first, parse the command line (including
calling 'store' put the option into variables_map). Obtain the value of the
necessary option from the variables map, and if necessary, parse the
config file, again, including 'store' like:
store(parse_config_file(ifs, config_file_options), vm);
After that, call 'notify(vm)' -- once.
I don't think that anything will break *now*, if you call notify twice, but then,
the documentation say:
/** Specifies a function to be called when the final value
is determined. */
typed_value* notifier(function1
Back on Wed, 25 Jun 2008 09:47:16 +0400, in
gmane.comp.lib.boost.user,Vladimir Prus
Marty Fried wrote:
My app has a configuration file. We don't know where it will be for sure, so we are planning to make the location of the file a commandline option.
So, after reading the commandline option, we will want to parse the config file.
You don't need to call 'notify' twice -- first, parse the command line (including calling 'store' put the option into variables_map). Obtain the value of the necessary option from the variables map, and if necessary, parse the config file, again, including 'store' like:
store(parse_config_file(ifs, config_file_options), vm);
After that, call 'notify(vm)' -- once.
Thanks a lot; I didn't know the purpose of notify, and thought it might be necessary to get the data into the variables_map. This way makes sense to me, now.
I don't think that anything will break *now*, if you call notify twice, but then, the documentation say:
/** Specifies a function to be called when the final value is determined. */ typed_value* notifier(function1
f) and reporting the *final* value twice seems weird.
That's the reason I didn't want to simply try it and assume the result is the design. Far be it for me to do something weird. :-) Thanks for your input. -- Marty Fried Senior software engineer Aldon http://www.aldon.com
participants (2)
-
Marty Fried
-
Vladimir Prus