Boost logo

Boost Users :

From: DV Henkel-Wallace (gumby_at_[hidden])
Date: 2020-08-31 05:28:38


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.

Thanks,
d


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net