Boost logo

Boost :

Subject: Re: [boost] program_options: Support for open-end options
From: Rob Stewart (robertstewart_at_[hidden])
Date: 2012-12-27 10:28:47


On Dec 26, 2012, at 12:56 PM, ST <smntov_at_[hidden]> wrote:

> It would be great to implement support for open-end options, something like that:
>
> item_1 = 23
> item_2 = 45
> ...
> item_N = 465
>
> The idea is to to be able to provide following input:
>
> configOptions.add_options()
> ("item_", value<int>(), "items");
>
> now if add_options() sees a key that ends with a "_" it accepts all
> options with keys that start with item_, no matter what comes after it, and treat all of them as int .

I think that's really odd, though I understand that you want something to allow a great number of options without defining them ahead of time.

My first thought was a command line delimiter to introduce a list of such options:

... --foo 1=23 2=45 ... N=465

You'd specify "foo" as the delimiter and PO would then parse the remaining values into pairs to populate a map. Since the set of name/value pairs is open ended, they would always go last on the command line. Of course, you could also specify a delimiter to signal the end of the pairs. (If you want validation that the option names match a pattern, you can add that, too.)

To avoid the name/value pairs, the following could be used to populate a vector:

... --foo 23 45 ... 465

___
Rob


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk