In the example documentation a multitoken is used for strings as follows: ("email", boost::program_options::valuevaluestd::string()->multitoken(), "email to send to") This means the command line can have the following option. --email beadle@mars beadle2@mars I'm trying to use the multitoken with an unsigned long as follows: ("sending,s", boost::program_options::value<unsigned long>()->multitoken(), "Distination node address and port number to transmit data.") The command option I would like to use is: -s 23 6543 When trying to do this the following error occurs. Unhandled exception: in option 'sending': multiple values not allowed How do I correctly define a multitoken and then how do I retrieve the different values? Ryan
Hi Ryan, maybe multitoken are only supported in the long form: --sending 23 5678 have you tried? Sönke -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Ryan McConnehey Sent: Monday, November 03, 2008 6:42 AM To: Boost-users Subject: [Boost-users] [program_options] Using multitokens In the example documentation a multitoken is used for strings as follows: ("email", boost::program_options::valuevaluestd::string()->multitoken(), "email to send to") This means the command line can have the following option. --email beadle@mars beadle2@mars I'm trying to use the multitoken with an unsigned long as follows: ("sending,s", boost::program_options::value<unsigned long>()->multitoken(), "Distination node address and port number to transmit data.") The command option I would like to use is: -s 23 6543 When trying to do this the following error occurs. Unhandled exception: in option 'sending': multiple values not allowed How do I correctly define a multitoken and then how do I retrieve the different values? Ryan _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Schau wrote:
Hi Ryan, maybe multitoken are only supported in the long form: --sending 23 5678 have you tried? Sönke
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Ryan McConnehey Sent: Monday, November 03, 2008 6:42 AM To: Boost-users Subject: [Boost-users] [program_options] Using multitokens
In the example documentation a multitoken is used for strings as follows:
("email", boost::program_options::valuevaluestd::string()->multitoken(), "email to send to")
This means the command line can have the following option.
--email beadle@mars beadle2@mars
I'm trying to use the multitoken with an unsigned long as follows:
("sending,s", boost::program_options::value<unsigned long>()->multitoken(), "Distination node address and port number to transmit data.")
The command option I would like to use is:
-s 23 6543
When trying to do this the following error occurs.
Unhandled exception: in option 'sending': multiple values not allowed
How do I correctly define a multitoken and then how do I retrieve the different values?
Ryan
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
I've tried using the long form of the option and the error is still given. Ryan
Ryan McConnehey schrieb:
In the example documentation a multitoken is used for strings as follows:
("email", boost::program_options::valuevaluestd::string()->multitoken(), "email to send to")
Hi,
I had the same problem. I believe the line in the documentation is
wrong. I tried:
("email", boost::program_options::valuevalue
()->multitoken(), "email to send to")
This works. Each token is saved in a string stored in a vector. Daniel
Now I run into another problem with multitoken:
In my code I have the following option:
("modelparams", po::value
daniel wrote:
Now I run into another problem with multitoken: In my code I have the following option:
("modelparams", po::value
()->multitoken(), "some modelparams") If I run my program only with --modelparams 0.7 1.2 33.0 everything is fine. But now I would like to append another option: --modelparams 0.7 1.2 33.0 --otheroption but get the exception: "in option 'modelparams ': invalid option value '--otheroption'" How can I get this right?
Daniel
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
I think this is a problem with the program options. Once multitoken is defined, the program options tried to read everything after the option as part of the option. For example: --config file.txt bob fish If another option is placed after the multitoken, program option doesn't interpret it as another option but part of the multitoken. For example: --config file.txt bob fish --send 23 Program options read the above line as all part of the --config option. Shouldn't multitoken read tokens until the next option is found? Ryan
Ryan McConnehey wrote:
Shouldn't multitoken read tokens until the next option is found?
Ryan That was my hope, too. Because I have not found a solution yet I gave up with multitoken. Know I define:
("modelparams", po::value<string>(), "some modelparams") and in the command line I write --modelparams "0.7 1.2 33.0" --otheroption then I parse the resulting string by hand: double param[3]; istringstream is(vm["modelparams"].as<string>()); for(int i=0;i<3;i++){ is>>param[i]; } Daniel
participants (3)
-
daniel
-
Ryan McConnehey
-
Schau,Sönke HG-Dir ae-se