Boost logo

Boost Users :

Subject: Re: [Boost-users] Multiple Multitokens
From: Vladimir Prus (vladimir_at_[hidden])
Date: 2009-04-16 11:34:26


David Doria wrote:

> I looked into the source to see if I could find what the count() function
> was supposed to be doing, but I actually didn't find a count() function at
> all?? The usage seems to be "was this parameter set"? But what I'm looking
> for is "how many times was this parameter set - ie. how many times did I see
> --list?)
>
> Vladimir, you made it sound like po::parse_command_line does not collapse
> the multiple parameters, but when you call po::store do they get collapsed?

Yes. po::parse_command_line does not collapse. po::store calls the 'store'
method of the value_semantics object associated with the option for each
occurrence of --list on the command line, with all the tokens found on
the command line. The typed_value class that po::value creates relays to
the 'validate' function template. Therefore, if you wish to use 'store'
you can either:

1. Introduce your custom class for storing those lists and specialize
validate for that class
2. Create your own class derived from value_semantics.

(1) is much easier.

You can still grab options returned by parse_command_line and process
them in a custom way.

- Volodya


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