Boost logo

Boost Users :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2005-11-11 03:24:20


Hi Giuseppe,

> I'm using program_options, and I want to be able to learn what the option
> type is by manipulating an options_description object. As I illustrate in
> the example below (boost 1.33), I can do this if the option has been given
> a default value. Could anyone suggest a wasy to this for options without a
> default?

It looks like there's not one. In general, an option can use arbitrary
user-defined class derived from "value_semantics" to handle value, so the
problem is not solvable in general.

For the case of using "typed_value" template provided by the library, I can
do this:

  - Add new class 'typed_value_base', with "typeinfo& type()" method.
  - Implement that method in typed_value template

What do you think about this approach?

> The story behind this question is that I would like to be able to build a
> simple GUI parameter dialog based on the options_description, and I want
> to map different types to different widgets.

Wow, that sound great.

- 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