Main   Classes   Namespace members   Examples   Recipes   Rationale   Related pages

boost::program_options::options_description Class Reference

A set of option descriptions. More...

#include <options_description.hpp>

List of all members.

Public Types

typedef boost::function2<
void, std::ostream &, const
option_description & > 
formatter
 User-provided function for formatting option_description instances.


Public Member Functions

 options_description ()
 Creates the instance.

 options_description (const std::string &caption)
 Creates the instance.

void add (shared_ptr< option_description > desc)
 Adds new variable description.

void add (const options_description &desc)
 Adds a group of option description.

option_description_easy_init<
p_option_description > 
add_options ()
 Returns an object of implementation-defined type suitable for adding options to options_description.

template<class T> option_description_easy_init<
T > 
add_options ()
 Returns an object suitable for adding options of user-defined class T to options_description instance.

unsigned count (const std::string &name) const
 Count the number of description with given name.

unsigned count_approx (const std::string &prefix) const
 Count the number of descriptions having the given string as prefix.

const option_descriptionfind (const std::string &name) const
 Returns description given a name.

const option_descriptionfind_approx (const std::string &prefix) const
 Returns description given a prefix.

std::set< std::string > keys () const
 Returns all such strings x for which count(x) == 1.

std::set< std::string > primary_keys () const
 For each option description stored, contains long name if not empty, if it is empty, short name is returned.

std::set< std::string > approximations (const std::string &prefix) const
 Returns all such long options for which 'prefix' is prefix.

void output (std::ostream &os, formatter f) const
 Output 'desc' to the specified streeam, calling 'f' to output each option_description element.


Friends

std::ostream & operator<< (std::ostream &os, const options_description &desc)
 Produces a human readable output of 'desc', listing options, their descriptions and allowed parameters.


Detailed Description

A set of option descriptions.

This provides convenient interface for adding new option (the add_options) method, and facilities to search for options by name.

See here for option adding interface discussion.

See also:
option_description


Member Typedef Documentation

typedef boost::function2<void, std::ostream&, const option_description&> boost::program_options::options_description::formatter
 

User-provided function for formatting option_description instances.


Constructor & Destructor Documentation

boost::program_options::options_description::options_description  
 

Creates the instance.

boost::program_options::options_description::options_description const std::string &    caption
 

Creates the instance.

The 'caption' parameter gives the name of this 'options_description' instance. Primarily usefull for output.


Member Function Documentation

void boost::program_options::options_description::add shared_ptr< option_description   desc
 

Adds new variable description.

Throws duplicate_variable_error if either short or long name matches that of already present one.

void boost::program_options::options_description::add const options_description &    desc
 

Adds a group of option description.

This have the same effect as adding all option_descriptions in 'desc' individually, except that output operator will show a separate group.

option_description_easy_init< options_description::p_option_description > boost::program_options::options_description::add_options  
 

Returns an object of implementation-defined type suitable for adding options to options_description.

The object returned will have these methods:

  • call operator, with signatures matching those of option_description constructors. Effects: new option_description object is created and added.
  • flags, default_value, default_parameter, validator, notify. They signatures match those of methods in construction part of option_description's interface. Precondition: at least one object should be already added via current adder object. Effects: forwards call to the appropriate method of last added option_description.

template<class T>
option_description_easy_init<T> boost::program_options::options_description::add_options  
 

Returns an object suitable for adding options of user-defined class T to options_description instance.

This function is not available when using the borland's compiler.

unsigned boost::program_options::options_description::count const std::string &    name const
 

Count the number of description with given name.

Returns 0 or 1. The 'name' parameter can be either name of long option, and short option prepended by '-'.

unsigned boost::program_options::options_description::count_approx const std::string &    prefix const
 

Count the number of descriptions having the given string as prefix.

This makes sense only for long options.

const option_description & boost::program_options::options_description::find const std::string &    name const
 

Returns description given a name.

Precondition:
count(name) == 1

const option_description & boost::program_options::options_description::find_approx const std::string &    prefix const
 

Returns description given a prefix.

Throws

Precondition:
count_approx(name) == 1

std::set< std::string > boost::program_options::options_description::keys   const
 

Returns all such strings x for which count(x) == 1.

std::set< std::string > boost::program_options::options_description::primary_keys   const
 

For each option description stored, contains long name if not empty, if it is empty, short name is returned.

std::set< std::string > boost::program_options::options_description::approximations const std::string &    prefix const
 

Returns all such long options for which 'prefix' is prefix.

void boost::program_options::options_description::output std::ostream &    os,
formatter    f
const
 

Output 'desc' to the specified streeam, calling 'f' to output each option_description element.


Friends And Related Function Documentation

std::ostream& operator<< std::ostream &    os,
const options_description &    desc
[friend]
 

Produces a human readable output of 'desc', listing options, their descriptions and allowed parameters.

Other options_description instances previously passed to add will be output separately.


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