[program options] parsing std::string
Hello, I want to parse std::string, perhaps into a vector<string>, but I do not want the command line argument to be positional in nature (i.e. like the examples demonstrate), because there may be a handful of parameters I need to capture into string or vector<string>. I've been able to parse integral types like int, even vector<int>, but haven't had much success with string. Possible or is this a program options "feature" and/or bug? Regards, Michael Powell
Hello Michael:
If you want no positional options to be allowed you can refer to this
answer:
http://stackoverflow.com/questions/3858251/parsing-positional-arguments/3859...
To parse a multi-token value correctly you should call special member
function of a PO option.
PO option is of type boost::program_options::typed_value<T>, it has a
member function multitoken().
multitoken() should be called before adding an option to PO set of
functions. Value type should be std::vector<T> then.
Regards,
Dmitriy Matison.
On 29 May 2013 14:24, Michael Powell
Hello,
I want to parse std::string, perhaps into a vector<string>, but I do not want the command line argument to be positional in nature (i.e. like the examples demonstrate), because there may be a handful of parameters I need to capture into string or vector<string>.
I've been able to parse integral types like int, even vector<int>, but haven't had much success with string. Possible or is this a program options "feature" and/or bug?
Regards,
Michael Powell _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Dmitriy Matison
-
Michael Powell