optionmm::option_base Class Reference

#include <optionmm/option.hh>

Inheritance diagram for optionmm::option_base:

Inheritance graph
[legend]
Collaboration diagram for optionmm::option_base:

Collaboration graph
[legend]
List of all members.

Detailed Description

Base class for options.

This is needed to use the std::vector container in the class command_line below.

Definition at line 60 of file option.hh.

Public Types

typedef std::vector< int > position_list
enum  { cannot_handle, can_handle, bad_argument, missing_argument }

Public Member Functions

 option_base (char s, const std::string &l, const std::string &h)
virtual ~option_base ()
char short_name () const
const std::string & long_name () const
const std::string & help_string () const
virtual bool need_argument () const
virtual bool many_values () const
virtual int push_arg (const char *arg, int pos)=0
virtual int push_arg (int pos)=0
virtual int position (int i=0) const
virtual void print (int ll, std::ostream &o=std::cout) const =0
virtual int handle (const std::string &arg, int pos)
virtual int handle (char *&opt, char *&arg, int pos)

Protected Attributes

char _short_name
std::string _long_name
std::string _help_string
position_list _positions


Member Typedef Documentation

typedef std::vector<int> optionmm::option_base::position_list
 

Definition at line 63 of file option.hh.


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
cannot_handle 
can_handle 
bad_argument 
missing_argument 

Definition at line 74 of file option.hh.


Constructor & Destructor Documentation

optionmm::option_base::option_base char  s,
const std::string &  l,
const std::string &  h
[inline]
 

CTOR.

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

Definition at line 137 of file option.hh.

virtual optionmm::option_base::~option_base  )  [inline, virtual]
 

DTOR.

Definition at line 88 of file option.hh.


Member Function Documentation

int optionmm::option_base::handle char *&  opt,
char *&  arg,
int  pos
[inline, virtual]
 

Handle this option as a short.

Parameters:
opt The option
arg The possible argument.
pos The position of the option on the command line.
Returns:
positive on success, 0 on if no match, negative on failure.

Definition at line 180 of file option.hh.

References _short_name, can_handle, cannot_handle, missing_argument, need_argument(), and push_arg().

Here is the call graph for this function:

int optionmm::option_base::handle const std::string &  arg,
int  pos
[inline, virtual]
 

Process this as a long option.

Parameters:
arg is the option with leading "--"
pos The position of the option on the command line.
Returns:
positive on success, 0 on if no match, negative on failure.

Definition at line 158 of file option.hh.

References _long_name, cannot_handle, missing_argument, need_argument(), and push_arg().

Here is the call graph for this function:

const std::string& optionmm::option_base::help_string  )  const [inline]
 

Get the help string.

Returns:
the help string

Definition at line 97 of file option.hh.

References _help_string.

const std::string& optionmm::option_base::long_name  )  const [inline]
 

Get the long name.

Returns:
the long name

Definition at line 94 of file option.hh.

References _long_name.

virtual bool optionmm::option_base::many_values  )  const [inline, virtual]
 

Test if this option can have many values.

Returns:
true if this option can have many values

Reimplemented in optionmm::basic_option< Type, argument, multivalue, Trait >, and optionmm::basic_option< bool, false, false >.

Definition at line 103 of file option.hh.

Referenced by position().

virtual bool optionmm::option_base::need_argument  )  const [inline, virtual]
 

Test whether we need an argument.

Returns:
whether we need an argument

Reimplemented in optionmm::basic_option< Type, argument, multivalue, Trait >, and optionmm::basic_option< bool, false, false >.

Definition at line 100 of file option.hh.

Referenced by handle().

int optionmm::option_base::position int  i = 0  )  const [inline, virtual]
 

Get the position of the i'th argument.

Parameters:
i Which argument to get the position off
Returns:
Position of the i'th arument, or negative if is out of range

Definition at line 148 of file option.hh.

References _positions, and many_values().

Referenced by optionmm::basic_command_line< ErrorHandler >::help().

Here is the call graph for this function:

virtual void optionmm::option_base::print int  ll,
std::ostream &  o = std::cout
const [pure virtual]
 

Print this option help line to a stream.

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

Implemented in optionmm::basic_option< Type, argument, multivalue, Trait >, and optionmm::basic_option< bool, false, false >.

virtual int optionmm::option_base::push_arg int  pos  )  [pure virtual]
 

Toggle the option.

Parameters:
pos Where the option was set on the command line
Returns:
positive if OK, negative on errors

Implemented in optionmm::basic_option< Type, argument, multivalue, Trait >, and optionmm::basic_option< bool, false, false >.

virtual int optionmm::option_base::push_arg const char *  arg,
int  pos
[pure virtual]
 

Set one value.

Parameters:
arg The argument
pos Where the argument occured on the command line
Returns:
positive if OK, negative on errors

Implemented in optionmm::basic_option< Type, argument, multivalue, Trait >, and optionmm::basic_option< bool, false, false >.

Referenced by handle().

char optionmm::option_base::short_name  )  const [inline]
 

Get the short name.

Returns:
the short name

Definition at line 91 of file option.hh.

References _short_name.


Member Data Documentation

std::string optionmm::option_base::_help_string [protected]
 

The help string.

Definition at line 70 of file option.hh.

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

std::string optionmm::option_base::_long_name [protected]
 

Long name of the option.

Definition at line 68 of file option.hh.

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

position_list optionmm::option_base::_positions [protected]
 

List of positions.

Definition at line 72 of file option.hh.

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

char optionmm::option_base::_short_name [protected]
 

Short name of the option.

Definition at line 66 of file option.hh.

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


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