Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2005-02-28 02:58:44

Stefan Slapeta wrote:

> Vladimir Prus wrote:
>> Can you give the specific use cases. I think that fully generic solution
>> can be overly complex, and we can get away with some helper functions.
>> Say, 'mutially_excluse_options' can check than only one option of a group
>> is specified.
> what about this syntax?
> po::options_validator v =
> ( po::exists("option_a") & po::exists("option_c")
> |
> ( po::exists("option_c") & po::exists("option_d")
> ;
> bool valid = v.validate(desc);

Yea, this is a possibility.

> I attach a working basic solution (many things copied from spirit ;) ),
> feel free to do anything you want with it.
> I used operator ^ for mutually exclusive options, but I'm afraid it's
> not perfect as it's not the same as xor!

Maybe, we can avoid defining the operators ourself and use those defined by
Boost.Lambda, or Phoenix? The attached works for me. And if we store that
boost::function inside options_description instance, we'll be able to
call user-provided validation code after parsing is done.

But not all compilers will handle this ;-)

- Volodya

Boost list run by bdawes at, gregod at, cpdaniel at, john at