0

In my project I've got some internal config structures containing options registration using default values (let's say Config.x=0, Config.y=0), those values are not modifable for a client.

Sometimes users of my application want to modify default values of those fields before parsing command line arguments, so before parsing they just change those values manually (let's say Config.x=3, Config.y=4) and then fetch command-line/.ini ifle options and parse it using parseOptions.

If those external arguments contain only a part of those options i.e. Config.x=9, values of other options will be those which are registered using boost::program_options, not those currently assigned, so the result would be Config.x=9, Config.y=0 instead of Config.x=9, Config.y=4. So basically it seems that, boost::program_options::parseOptions clears all options before parsing.

Is there anyway to prevent boost from clearing already assigned options in case they do not appear in command-line arguments?

sehe
  • 374,641
  • 47
  • 450
  • 633
mtszkw
  • 2,717
  • 2
  • 17
  • 31

1 Answers1

1

This can't be done. However, you should be able to create parsed_options either manually¹, or you can supply the options as a "faux" configfile so you can actually use the configfile parser on it.

Once you have the parsed_options you can store/notify them as usual.


¹ though this isn't supported/documented, see the comment at boost::program_option::basic_parsed_options<>

sehe
  • 374,641
  • 47
  • 450
  • 633