...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::program_options::value_semantic
// In header: <boost/program_options/value_semantic.hpp> class value_semantic { public: // construct/copy/destruct ~value_semantic(); // public member functions std::string name() const; unsigned min_tokens() const; unsigned max_tokens() const; bool is_composing() const; bool is_required() const; void parse(boost::any &, const std::vector< std::string > &, bool) const; bool apply_default(boost::any &) const; void notify(const boost::any &) const; };
Class which specifies how the option's value is to be parsed and converted into C++ types.
value_semantic
public member functionsstd::string name() const;
Returns the name of the option. The name is only meaningful for automatic help message.
unsigned min_tokens() const;
The minimum number of tokens for this option that should be present on the command line.
unsigned max_tokens() const;
The maximum number of tokens for this option that should be present on the command line.
bool is_composing() const;
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.
bool is_required() const;
Returns true if value must be given. Non-optional value
void parse(boost::any & value_store, const std::vector< std::string > & new_tokens, bool utf8) const;
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.
bool apply_default(boost::any & value_store) const;
Called to assign default value to 'value_store'. Returns true if default value is assigned, and false if no default value exists.
void notify(const boost::any & value_store) const;
Called when final value of an option is determined.