Boost logo

Boost Users :

From: Edwin Savarimuthu (zerobook_at_[hidden])
Date: 2007-11-02 12:27:17


You can use something like this as well.

std::vector<std::string> key_pair;
("secert", boost::program_options::value< std::vector<std::string>
>(&key_pair), "creates the share secret key");

Then you can do you error checks ...

if ( key_pair.size() == 2 )
{
  // Do your processing here
} else
{
  // error
}

This example uses string vector. I guess std::vector<BigInteger>
should also work for you.

Thanks,
Edwin

On 10/31/07, Ovanes Markarian <om_boost_at_[hidden]> wrote:
> One more addition:
>
> boost::tuple<BigInteger, BigInteger> key_pair;
>
> This will not parse your key. You need to do it manually. So your param
> should be std::string. And than you can tokenize you string. Or you define 2
> separate params and let program_options parse them into Integers for you.
> But I am unsure if this is supported. Probably yes. I am 100% sure program
> options will not tokenize one param for you. May be only if your key_pair
> supports construction from a space separted string.
>
>
> Regards,
> Ovanes
>
>
> On 10/31/07, Ovanes Markarian <om_boost_at_[hidden]> wrote:
> >
> > Hi!
> >
> >
> >
> > On 10/31/07, chun ping wang <cablepuff_at_[hidden]> wrote:
> > >
> > > HI how would I use program options to accept multiple input.
> > >
> > > The thing compiles but when I do DiffieHellman.exe --secert 817 697
> > >
> > > I get this error.
> > > C:\CPW\cs_classes>DiffieHellmanEncrypt --secert 817 697
> > > terminate called after throwing an instance of
> > > 'boost::program_options::invalid_
> > > option_value'
> > > what(): in option 'secert': invalid option value '817'
> > >
> > > This application has requested the Runtime to terminate it in an unusual
> > > way.
> > > Please contact the application's support team for more information.
> > >
> > >
> > >
> > the option is in your case:
> >
> > --secert="817 697"
> >
> > Regards,
> > Ovanes
>


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