Re: [Boost-users] [program_options] multitoken

What about parameters like -I for gcc? Utilities can add -I's to the command line. It would be an added headache to synchronize all these tools to eventually come up with a -I arg1,arg2,...

On 2/13/06, Edward Diener
I believe this functionality is built right in to the program_options library if you use value< vector<T> > as your value semantic. There is an example of this in the "Getting Started" section of the program_options documentation (http://www.boost.org/doc/html/program_options/tutorial.html). Here is a small snippet of what's in the docs: int opt; po::options_description desc("Allowed options"); desc.add_options() ("help", "produce help message") ("optimization", po::value<int>(&opt)->default_value(10), "optimization level") ("include-path,I", po::value< vector<string> >(), "include path") ("input-file", po::value< vector<string> >(), "input file") ; The tutorial section in the docs isn't 100% clear about what this does, but I'm pretty sure if you have a command-line with (for example) multiple --include-path options, then push_back is called on a vector in the variables_map for each instance of the --include-path option. There is probably a different section in the docs that describes this in detail, but I'm not sure where it is. Hope this helps, Nathan.

Hi again
I tried what was in the tutorials at the time and the thing was that, let's say I wanted include paths and files, I would have to write the following:
myCommand -I /path1 -I /path2 -f file1 -f file2
(specifying the option for each file and path so it's pushed back into the vector) That is fine, but if I try the following:
myCommand -I /path1 /path2 -f file1 file2
then the parser didn't recognize the 'file' option and the paths vector<string> had all these elements:
/path1, /path2, -f, file1, file2
That wa not what I expected. In particular, I wanted to do something like myCommand -I /path1/* -f file*, and ran into the previous problem.
Javier
----- Original Message ----
From: Vladimir Prus
Hi Nathan, I've just clarified the tutorial to say that std::vector values automatically allow multiple occurences of options. Thanks, Volodya _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (6)
-
Alexander Kondratyuk
-
Edward Diener
-
Javier Gonzalez
-
Nathan LeZotte
-
Sohail Somani
-
Vladimir Prus