Subject: Re: [boost] program_options::store() interface extension
From: Rob Stewart (robertstewart_at_[hidden])
Date: 2012-11-15 05:41:38
On Nov 14, 2012, at 12:09 PM, ST <smntov_at_[hidden]> wrote:
> I need to supply to my app a config file with following entries:
> item1 = 123
> item2 = 435
> item3 = 345
> itemN = 562
> where N is not known in advance, so there is no way to register such
> options. The only way to deal with them is to pass them as unregistered
> options and then use collect_unrecognized(). But then dealing with a
> vector<string> is not quit convenient. My suggestion is to add an a
> storeUnregistered flag to the store() function which will be false by
> default, but if set to true, will store all unregistered options with
> their values as strings. It will be possible then to check whether an
> item was provided like this: vm.count("item1") and cast its value like
> this: vm["item1"].as<int>() .
> Or is there already a good way to do what I need?
While that seems plausible, it allows for open-ended collection of options. I'd rather see a callback-based filter or the ability to register a regex to recognize acceptable options.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk