Boost logo

Boost Users :

Subject: Re: [Boost-users] [program_option] how to say only certain strings are allowed as arguments?
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2010-03-05 15:32:15


Michele Caini skrev:
> Il 04/03/2010 21:49, Thorsten Ottosen ha scritto:
>> Hi,
>>
>> Is there some way to say
>>
>> bpo::options_description desc("Allowed options");
>> desc.add_options()
>> ("method",
>> bpo::value<std::string>()->allowed_values("foo")("bar"), "" )
>>
>> so I donøt have to reject the arguments manually?
>>
>> Thanks
>>
>> -Thorsten
>
>
> Can you try using regex to cut off options?

That would be a good idea. I think it would also be cool if we could
simply say

   po::value<std::string>()->match( "some regex expression here" );

It so common to do this kind of validation that I think it would be a
benefit if the library could handle this. It should be possible to
let the library depend on boost.regex only when needed.

-Thorsten


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