BOOST program_options: parsing multiple argument list.

Posted by Arman on Stack Overflow See other posts from Stack Overflow or by Arman
Published on 2010-03-29T15:20:46Z Indexed on 2010/03/29 15:23 UTC
Read the original article Hit count: 719

Filed under:
|
|

Hello, I would like to pass the multiple arguments with positive or negative values. Is it possible to parse it?

Currently I have a following initialization:

vector<int> IDlist;
namespace po = boost::program_options;     
po::options_description commands("Allowed options");
            commands.add_options()              
                ("IDlist",po::value< vector<int> >(&IDlist)->multitoken(), "Which IDs to trace: ex. --IDlist=0 1 200 -2")
                ("help","print help")
                ;

and I would like to call:

./test_ids.x --IDlist=0 1 200 -2
unknown option -2

So,the program_options assumes that I am passing -2 as an another option.

Can I configure the program_options in such a way that it can accept the negative integer values?

Thanks Arman.

© Stack Overflow or respective owner

Related posts about c++

Related posts about boost