Program-options and priority

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Program-options and priority

Boost - Users mailing list
Hi.  I'm finding program_options pretty handy but I have a usage question which is not clear from the documentation.  Is a hierarchy of sources not possible if I use value<T>(&my_arg)?

My use case is the following:

I have a hierarchy of sources: command line, environment variables, user-specified config file or default config file, and lastly a system default.

I just set my_arg to whatever default is appropriate and then let parse_command_line do all the work.

This is convenient because I can have a module simply define an options_description for callers to use.

This works fine unless the option is specified twice (say command line and then environment).  The last of the two values is used rather than the first one.

Is this hierarchy only possible if I use value<T>() and not value<T>(&my_var)?  That will add some complexity for callers.


Boost-users mailing list
[hidden email]