Boost logo

Boost Users :

From: Harsh Deshmane (hdeshmane_at_[hidden])
Date: 2006-08-16 20:36:26


Hi,

Multiple occurrences are definitely allowed and handled.

If you do specify the option value to populate a container,
and then pass the containerpointer to the add_options() method,
you can later iterate over the options.
For e.g,
in
class cmdLineParser{
...
private:
vector<string>* _sources;
}

In cmdLineParser.cpp,

parse(int argc, char* argv[])
{
po::options_description genericDesc("Generic");
genericDesc.add_options()
        ("help", "Help Message")
        ("source,s", value(_sources), "source node name")
        ;
store(parse_command_line(argc,argv, genericDesc),_vm);
....

}

good luck,
-Harsh Deshmane

On Wednesday 16 August 2006 17:03, Ian McCulloch wrote:
> Hi,
>
> I have spent several hours looking at the docs and sources, but I cannot
> figure out how to allow multiple occurances of an option. Many unix tools
> allow you to specify the --verbose option multiple times, to mean
> increasing verbosity of output, and I want to replicate this behaviour.
>
> Does this require writing a new class derived from value_semantic, that
> combines the behaviour of bool_switch() and
> typed_value<std::vector<bool>> ? I'm not sure how to go about doing that.
>
> It is a very useful lib, but I do wish (often!) there was some real
> reference docs (aside from the doxygen stuff and comments in the sources
> themselves, which isn't enough :-(
>
> Unrelated, but in trying to figure this out from the docs, I noticed in the
> overview.html, in the Syntactic Information there is a call to a function
> value<string>()->implicit(). However typed_value<T> has no such member
> function. Maybe it is left over from a previous design iteration or
> something, as there is a member variable m_implicit but it is never
> initialized or accessed.
>
> Cheers,
> Ian McCulloch
>
>
> _______________________________________________
> 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