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 options_description

boost::program_options::options_description

Synopsis

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


class options_description {
public:
  // construct/copy/destruct
  options_description(unsigned = m_default_line_length);
  options_description(const std::string &, unsigned = m_default_line_length);

  // public member functions
  void add(shared_ptr< option_description >) ;
  options_description & add(const options_description &) ;
  options_description_easy_init add_options() ;
  const option_description & find(const std::string &, bool) const;
  const option_description * find_nothrow(const std::string &, bool) const;
  const std::vector< shared_ptr< option_description > > & options() const;
  void print(std::ostream &) const;
  static const unsigned m_default_line_length;
};

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.

option_description

options_description public construct/copy/destruct

  1. options_description(unsigned line_length = m_default_line_length);

    Creates the instance.

  2. options_description(const std::string & caption, 
                        unsigned line_length = m_default_line_length);

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

options_description public member functions

  1. void 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.

  2. options_description & add(const options_description & desc) ;

    Adds a group of option description. This has the same effect as adding all option_descriptions in 'desc' individually, except that output operator will show a separate group. Returns *this.

  3. options_description_easy_init add_options() ;

    Returns an object of implementation-defined type suitable for adding options to options_description. The returned object will have overloaded operator() with parameter type matching 'option_description' constructors. Calling the operator will create new option_description instance and add it.

  4. const option_description & find(const std::string & name, bool approx) const;
  5. const option_description * 
    find_nothrow(const std::string & name, bool approx) const;
  6. const std::vector< shared_ptr< option_description > > & options() const;
  7. void print(std::ostream & os) const;

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


PrevUpHomeNext