[program_option] how to say only certain strings are allowed as arguments?

Hi, Is there some way to say bpo::options_description desc("Allowed options"); desc.add_options() ("method", bpo::valuestd::string()->allowed_values("foo")("bar"), "" ) so I donøt have to reject the arguments manually? Thanks -Thorsten

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::valuestd::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?

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::valuestd::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::valuestd::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

What puzzles me is that JavaScript can accurately determine the correct time zone settings for the local system including daylight savings time settings and time zone name. Is there a trick to achieve this with boost date_time?

On Friday 05 March 2010 23:32:15 Thorsten Ottosen wrote:
Is there some way to say
bpo::options_description desc("Allowed options"); desc.add_options() ("method", bpo::valuestd::string()->allowed_values("foo")("bar"), "" ) .... I think it would also be cool if we could simply say
po::valuestd::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.
I agree this could be handy -- both ideas above. Unfortunately, I am unlikely to implement this immediately, so could you file an issue? Thanks, Volodya
participants (4)
-
Michele Caini
-
Pete
-
Thorsten Ottosen
-
Vladimir Prus