optionmm::basic_option< Type, argument, multivalue, Trait > Class Template Reference

#include <optionmm/option.hh>

Inheritance diagram for optionmm::basic_option< Type, argument, multivalue, Trait >:

Inheritance graph
[legend]
Collaboration diagram for optionmm::basic_option< Type, argument, multivalue, Trait >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<typename Type, bool argument = true, bool multivalue = true, typename Trait = option_trait<Type>>
class optionmm::basic_option< Type, argument, multivalue, Trait >

Command line option class.

The argument Type is the type of the value, argument specifies whether this option needs an argument, and multivalue says whether the option can take multiple values.

Examples:

demo.cc.

Definition at line 271 of file option.hh.

Public Types

typedef Type value_type
typedef std::vector< value_typevalue_list
typedef Trait trait_type

Public Member Functions

 basic_option (char s, const std::string &l, const std::string &h, value_type d)
virtual ~basic_option ()
bool need_argument () const
bool many_values () const
int size () const
const value_typevalue (int i=0) const
const value_listvalues () const
int push_arg (const char *arg, int pos)
int push_arg (int pos)
virtual void print (int ll, std::ostream &o=std::cout) const

Protected Attributes

value_list _values
value_type _default


Member Typedef Documentation

template<typename Type, bool argument = true, bool multivalue = true, typename Trait = option_trait<Type>>
typedef Trait optionmm::basic_option< Type, argument, multivalue, Trait >::trait_type
 

Type of value container.

Definition at line 276 of file option.hh.

template<typename Type, bool argument = true, bool multivalue = true, typename Trait = option_trait<Type>>
typedef std::vector<value_type> optionmm::basic_option< Type, argument, multivalue, Trait >::value_list
 

The value type.

Definition at line 275 of file option.hh.

template<typename Type, bool argument = true, bool multivalue = true, typename Trait = option_trait<Type>>
typedef Type optionmm::basic_option< Type, argument, multivalue, Trait >::value_type
 

Definition at line 274 of file option.hh.

Referenced by optionmm::basic_option< Type, argument, multivalue, Trait >::basic_option(), optionmm::basic_option< Type, argument, multivalue, Trait >::push_arg(), and optionmm::basic_option< Type, argument, multivalue, Trait >::value().


Constructor & Destructor Documentation

template<typename Type, bool arg, bool multi, typename Trait>
optionmm::basic_option< Type, arg, multi, Trait >::basic_option char  s,
const std::string &  l,
const std::string &  h,
value_type  d
[inline]
 

Constructor.

Parameters:
s The short name (possibly '\0')
l The long name (possibly "");
h The help string.
d The default value.

Definition at line 330 of file option.hh.

References optionmm::basic_option< Type, argument, multivalue, Trait >::value_type.

template<typename Type, bool argument = true, bool multivalue = true, typename Trait = option_trait<Type>>
virtual optionmm::basic_option< Type, argument, multivalue, Trait >::~basic_option  )  [inline, virtual]
 

Destructor.

Definition at line 291 of file option.hh.


Member Function Documentation

template<typename Type, bool argument = true, bool multivalue = true, typename Trait = option_trait<Type>>
bool optionmm::basic_option< Type, argument, multivalue, Trait >::many_values  )  const [inline, virtual]
 

Whether this optin can take many values.

Reimplemented from optionmm::option_base.

Definition at line 296 of file option.hh.

Referenced by optionmm::basic_option< Type, argument, multivalue, Trait >::print(), and optionmm::basic_option< Type, argument, multivalue, Trait >::push_arg().

template<typename Type, bool argument = true, bool multivalue = true, typename Trait = option_trait<Type>>
bool optionmm::basic_option< Type, argument, multivalue, Trait >::need_argument  )  const [inline, virtual]
 

Whether this option need an argument.

Reimplemented from optionmm::option_base.

Definition at line 294 of file option.hh.

Referenced by optionmm::basic_option< Type, argument, multivalue, Trait >::print().

template<typename Type, bool arg, bool multi, typename Trait>
void optionmm::basic_option< Type, arg, multi, Trait >::print int  ll,
std::ostream &  o = std::cout
const [inline, virtual]
 

Print this option help line to a stream.

Parameters:
ll Width for the option names
o The stream to write to

Implements optionmm::option_base.

Definition at line 398 of file option.hh.

References optionmm::option_base::_help_string, optionmm::option_base::_long_name, optionmm::option_base::_short_name, optionmm::basic_option< Type, argument, multivalue, Trait >::many_values(), and optionmm::basic_option< Type, argument, multivalue, Trait >::need_argument().

Here is the call graph for this function:

template<typename Type, bool arg, bool multi, typename Trait>
int optionmm::basic_option< Type, arg, multi, Trait >::push_arg int  pos  )  [inline, virtual]
 

Add a value.

This is used by the command_line class to set the values of the options, in case need_argument tests false.

Parameters:
pos The position on the command line the option was given at.

Implements optionmm::option_base.

Definition at line 376 of file option.hh.

References optionmm::basic_option< Type, argument, multivalue, Trait >::_default, optionmm::option_base::_positions, optionmm::basic_option< Type, argument, multivalue, Trait >::_values, optionmm::option_base::can_handle, and optionmm::basic_option< Type, argument, multivalue, Trait >::many_values().

Here is the call graph for this function:

template<typename Type, bool arg, bool multi, typename Trait>
int optionmm::basic_option< Type, arg, multi, Trait >::push_arg const char *  arg,
int  pos
[inline, virtual]
 

Add a value from a string.

This is used by the command_line class to set the values of the options, in case need_argument tests true.

Parameters:
pos The position on the command line the option was given at.
arg The value added.

Implements optionmm::option_base.

Definition at line 351 of file option.hh.

References optionmm::option_base::_positions, optionmm::basic_option< Type, argument, multivalue, Trait >::_values, optionmm::option_base::bad_argument, optionmm::option_base::can_handle, optionmm::basic_option< Type, argument, multivalue, Trait >::many_values(), and optionmm::basic_option< Type, argument, multivalue, Trait >::value_type.

Here is the call graph for this function:

template<typename Type, bool argument = true, bool multivalue = true, typename Trait = option_trait<Type>>
int optionmm::basic_option< Type, argument, multivalue, Trait >::size  )  const [inline]
 

Number of values of this option.

Examples:
demo.cc.

Definition at line 298 of file option.hh.

template<typename Type, bool arg, bool multi, typename Trait>
const Type & optionmm::basic_option< Type, arg, multi, Trait >::value int  i = 0  )  const [inline]
 

Get value.

Parameters:
i The value number to get.
Returns:
the i value, or if that is out of bounds, the first value.
Examples:
demo.cc.

Definition at line 340 of file option.hh.

References optionmm::basic_option< Type, argument, multivalue, Trait >::_default, optionmm::basic_option< Type, argument, multivalue, Trait >::_values, and optionmm::basic_option< Type, argument, multivalue, Trait >::value_type.

template<typename Type, bool argument = true, bool multivalue = true, typename Trait = option_trait<Type>>
const value_list& optionmm::basic_option< Type, argument, multivalue, Trait >::values  )  const [inline]
 

Get all values.

Definition at line 306 of file option.hh.


Member Data Documentation

template<typename Type, bool argument = true, bool multivalue = true, typename Trait = option_trait<Type>>
value_type optionmm::basic_option< Type, argument, multivalue, Trait >::_default [protected]
 

A list of the values.

Definition at line 279 of file option.hh.

Referenced by optionmm::basic_option< Type, argument, multivalue, Trait >::push_arg(), and optionmm::basic_option< Type, argument, multivalue, Trait >::value().

template<typename Type, bool argument = true, bool multivalue = true, typename Trait = option_trait<Type>>
value_list optionmm::basic_option< Type, argument, multivalue, Trait >::_values [protected]
 

Definition at line 278 of file option.hh.

Referenced by optionmm::basic_option< Type, argument, multivalue, Trait >::push_arg(), optionmm::basic_option< bool, false, false >::size(), optionmm::basic_option< Type, argument, multivalue, Trait >::value(), and optionmm::basic_option< bool, false, false >::values().


The documentation for this class was generated from the following file:
Top of page Last update Tue Jan 13 19:10:36 2004
Christian Holm
Created by DoxyGen 1.3.4