Boost logo

Boost Users :

From: Javier Gonzalez (javierggt_at_[hidden])
Date: 2006-04-24 09:35:22


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 <ghost_at_[hidden]>
To: boost-users_at_[hidden]
Sent: Monday, April 24, 2006 4:52:17 AM
Subject: Re: [Boost-users] [program_options] multitoken

Nathan LeZotte wrote:

> 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.

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_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net