Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.
PrevUpHomeNext

Class value_semantic

boost::program_options::value_semantic

Synopsis

// In header: <boost/program_options/value_semantic.hpp>


class value_semantic {
public:
  // construct/copy/destruct
  virtual ~value_semantic();

  // public member functions
  virtual std::string name() const = 0;
  virtual unsigned min_tokens() const = 0;
  virtual unsigned max_tokens() const = 0;
  virtual bool is_composing() const = 0;
  virtual bool is_required() const = 0;
  virtual void 
  parse(boost::any &, const std::vector< std::string > &, bool) const = 0;
  virtual bool apply_default(boost::any &) const = 0;
  virtual void notify(const boost::any &) const = 0;
};

Description

Class which specifies how the option's value is to be parsed and converted into C++ types.

value_semantic public construct/copy/destruct

  1. virtual ~value_semantic();

value_semantic public member functions

  1. virtual std::string name() const = 0;

    Returns the name of the option. The name is only meaningful for automatic help message.

  2. virtual unsigned min_tokens() const = 0;

    The minimum number of tokens for this option that should be present on the command line.

  3. virtual unsigned max_tokens() const = 0;

    The maximum number of tokens for this option that should be present on the command line.

  4. virtual bool is_composing() const = 0;

    Returns true if values from different sources should be composed. Otherwise, value from the first source is used and values from other sources are discarded.

  5. virtual bool is_required() const = 0;

    Returns true if value must be given. Non-optional value

  6. virtual void 
    parse(boost::any & value_store, const std::vector< std::string > & new_tokens, 
          bool utf8) const = 0;

    Parses a group of tokens that specify a value of option. Stores the result in 'value_store', using whatever representation is desired. May be be called several times if value of the same option is specified more than once.

  7. virtual bool apply_default(boost::any & value_store) const = 0;

    Called to assign default value to 'value_store'. Returns true if default value is assigned, and false if no default value exists.

  8. virtual void notify(const boost::any & value_store) const = 0;

    Called when final value of an option is determined.


PrevUpHomeNext