2

i like to read a vector using boost program options with multitoken and from a config file file. using:

std::vector<int> numbers
po::options_description desc ( "Allowed Arguments" );
desc.add_options()
( "numbers,n", po::value< std::vector< int > > ( &numbers)->multitoken(), "my numbers" );

std::ifstream ifs ( "config.ini" , std::ifstream::in );
po::store ( po::parse_config_file ( ifs , desc ), vm );
po::notify ( vm );

but my now I have to define every value in my config.ini in separate row. like

numbers = 0
numbers = 1
numbers = 3
numbers = 5

is there a way/syntax to define all number in one line such as: numbers = [0 1 3 5] # this does not work

Thanks Markus

Max
  • 340
  • 2
  • 15
  • Does the solution offered [here](http://stackoverflow.com/a/2939249/820657) not help? – ksl Aug 26 '15 at 11:29

1 Answers1

1

According to the documentation, one line configures one value.

However, you could read the value for numbers as a string, then parse with a regex or similar to get the individual values.

Phil Lello
  • 8,377
  • 2
  • 25
  • 34
  • Thanks Phil, Thats how I implemented it but I was hoping to find a better solution :-) – Max Jan 26 '15 at 07:50