Main   Classes   Namespace members   Examples   Recipes   Rationale   Related pages

boost::program_options::option_description Class Reference

Describes one possible command line/config file option. More...

#include <options_description.hpp>

Inherited by boost::program_options::option_description_easy_init< Derived >, and boost::program_options::option_description_easy_init< p_option_description >.

Inheritance diagram for boost::program_options::option_description:

Inheritance graph
[legend]
List of all members.

Public Types

typedef boost::function2<
void, boost::any &, const
std::vector< std::string > & > 
validator_function
 The type of function which perform validation of option parameters.

typedef boost::function1<
void, const boost::any & > 
notify_function
 The type of function which will be called to notify about final value of option.

typedef boost::function1<
void, option_description & > 
initialize_function
 The type of function that is used to initialize option_description.


Public Member Functions

std::string format_name () const
 Returns the option name, formatted suitably for usage message.

std::string format_parameter () const
 Return the parameter name and properties, formatted suitably for usage message.

Construction
 option_description (const char *name, const char *parameter_name)
 Creates an option_description instance with the specified name and parameter_name.

 option_description (const char *name, const char *parameter, const char *description)
 Same as above, but also sets the description for this option.

 option_description (const char *name, const initialize_function &f)
 Initializes *this from name, assuming empty parameter_name.

 option_description (const char *name, const initialize_function &f, const char *description)
 Initialized *this from name and description, and assuming empty parameter_name.

option_description & name (const char *name)
 Sets the long name and short name, using the following convention: - if there's no "," character in 'name', it specifies long name - otherwise, the part before "," specifies long name and the part after -- long name.

option_description & description (const char *desc)
 Sets the description.

option_description & parameter (const char *parameter)
 Sets the parameter name.

option_description & flags (char f)
 Sets flags to the passed value.

option_description & default_value (const char *)
 Sets default value of the option.

option_description & default_parameter (const char *)
 Sets default value of the option's parameter.

option_description & validator (const validator_function &)
 Sets validator to be used for the options's parameter.

option_description & notify (const notify_function &)
 Sets notify function to be used with this option.

Syntantic properties
const std::string & short_name () const
 Name to be used with short-style option ("-w").

const std::string & long_name () const
 Name to be used with long-style option ("--whatever").

const std::string & description () const
 Explanation of this option.

const std::string & parameter () const
 Name of the parameter.

char flags () const
 Flags that apply to this variable.

Semantic properties
const std::string & default_value () const
 Returns default value.

const std::string & default_parameter () const
 Returns detaul parameter's value.

const validator_functionvalidator () const
 Function that performs validation and fixup on value.

const notify_functionnotify () const
 Function that should be called when value of the variable is finally set.


Detailed Description

Describes one possible command line/config file option.

There are two kinds of properties of an option. First describe it syntactically and are used only to validate input. Second affect interpretation of the option, for example default value for it or function that should be called when the value is finally know. Routines which perform parsing never use second kind of properties -- they are side effect free.

See also:
options_description


Member Typedef Documentation

typedef boost::function2<void, boost::any&, const std::vector<std::string>&> boost::program_options::option_description::validator_function
 

The type of function which perform validation of option parameters.

It will be called with the current value of option as the first parameter (possible empty 'any'), and with values specified in the next occurence of option. It should update the value, or throw.

typedef boost::function1<void, const boost::any&> boost::program_options::option_description::notify_function
 

The type of function which will be called to notify about final value of option.

typedef boost::function1<void, option_description&> boost::program_options::option_description::initialize_function
 

The type of function that is used to initialize option_description.


Constructor & Destructor Documentation

boost::program_options::option_description::option_description const char *    name,
const char *    parameter_name
 

Creates an option_description instance with the specified name and parameter_name.

Name is set by call to this->name. Flags will be set this way:

  • '|' (no parameter) if parameter_name is empty
  • '?' (optional), '+' (1 or more values) '*' (0 or more values) if the last symbol of parameter_name is '?', '+', or '*'.
  • ':' (required parameter) otherwise.

boost::program_options::option_description::option_description const char *    name,
const char *    parameter,
const char *    description
 

Same as above, but also sets the description for this option.

boost::program_options::option_description::option_description const char *    name,
const initialize_function   f
 

Initializes *this from name, assuming empty parameter_name.

After that, calls 'f' on *this.

boost::program_options::option_description::option_description const char *    name,
const initialize_function   f,
const char *    description
 

Initialized *this from name and description, and assuming empty parameter_name.

After that, calls 'f' on *this.


Member Function Documentation

option_description & boost::program_options::option_description::name const char *    name
 

Sets the long name and short name, using the following convention: - if there's no "," character in 'name', it specifies long name - otherwise, the part before "," specifies long name and the part after -- long name.

option_description & boost::program_options::option_description::description const char *    desc
 

Sets the description.

Reimplemented in boost::program_options::option_description_easy_init< Derived >, and boost::program_options::option_description_easy_init< p_option_description >.

option_description & boost::program_options::option_description::parameter const char *    parameter
 

Sets the parameter name.

See also:
boost::program_options::parameter

Reimplemented in boost::program_options::option_description_easy_init< Derived >, and boost::program_options::option_description_easy_init< p_option_description >.

option_description & boost::program_options::option_description::flags char    f
 

Sets flags to the passed value.

The value of 'c' has the same meaning as in cmdline::add_option.

Reimplemented in boost::program_options::option_description_easy_init< Derived >, and boost::program_options::option_description_easy_init< p_option_description >.

option_description & boost::program_options::option_description::default_value const char *   
 

Sets default value of the option.

Reimplemented in boost::program_options::option_description_easy_init< Derived >, and boost::program_options::option_description_easy_init< p_option_description >.

option_description & boost::program_options::option_description::default_parameter const char *   
 

Sets default value of the option's parameter.

Reimplemented in boost::program_options::option_description_easy_init< Derived >, and boost::program_options::option_description_easy_init< p_option_description >.

option_description & boost::program_options::option_description::validator const validator_function  
 

Sets validator to be used for the options's parameter.

Reimplemented in boost::program_options::option_description_easy_init< Derived >, and boost::program_options::option_description_easy_init< p_option_description >.

option_description & boost::program_options::option_description::notify const notify_function  
 

Sets notify function to be used with this option.

Reimplemented in boost::program_options::option_description_easy_init< Derived >, and boost::program_options::option_description_easy_init< p_option_description >.

const std::string & boost::program_options::option_description::short_name   const
 

Name to be used with short-style option ("-w").

const std::string & boost::program_options::option_description::long_name   const
 

Name to be used with long-style option ("--whatever").

const std::string & boost::program_options::option_description::description   const
 

Explanation of this option.

const std::string & boost::program_options::option_description::parameter   const
 

Name of the parameter.

char boost::program_options::option_description::flags   const
 

Flags that apply to this variable.

const std::string & boost::program_options::option_description::default_value   const
 

Returns default value.

const std::string & boost::program_options::option_description::default_parameter   const
 

Returns detaul parameter's value.

const option_description::validator_function & boost::program_options::option_description::validator   const
 

Function that performs validation and fixup on value.

const option_description::notify_function & boost::program_options::option_description::notify   const
 

Function that should be called when value of the variable is finally set.

std::string boost::program_options::option_description::format_name   const
 

Returns the option name, formatted suitably for usage message.

std::string boost::program_options::option_description::format_parameter   const
 

Return the parameter name and properties, formatted suitably for usage message.


The documentation for this class was generated from the following files:
Generated on 23 May 2003 with
doxygen