Public Member Functions | Protected Member Functions | Protected Attributes | Friends

wibble::commandline::SingleOptvalOption< T > Class Template Reference

Single option whose value can be or not be specified. More...

#include <options.h>

Inheritance diagram for wibble::commandline::SingleOptvalOption< T >:
Inheritance graph
[legend]
Collaboration diagram for wibble::commandline::SingleOptvalOption< T >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

bool hasValue () const
void setValue (const typename T::value_type &a)
T::value_type value () const

Protected Member Functions

 SingleOptvalOption (const std::string &name)
 SingleOptvalOption (const std::string &name, char shortName, const std::string &longName, const std::string &usage=std::string(), const std::string &description=std::string())
ArgList::iterator parse (ArgList &list, ArgList::iterator begin)
 Parse the next commandline parameter after the short form of the command has been found.
bool parse (const std::string &param)
 Parse the commandline parameter of a long commandline switch.
void parse_noarg ()
 Notify that the option is present in the command line, but has no arguments.
virtual bool arg_is_optional () const
 Return true if the argument to this function can be omitted.

Protected Attributes

T::value_type m_value
bool m_hasval

Friends

class OptionGroup
class Engine

Detailed Description

template<typename T>
class wibble::commandline::SingleOptvalOption< T >

Single option whose value can be or not be specified.

It works for long option style only: short options with an optional argument would be ambiguous.


Constructor & Destructor Documentation

template<typename T >
wibble::commandline::SingleOptvalOption< T >::SingleOptvalOption ( const std::string &  name  )  [inline, protected]
template<typename T >
wibble::commandline::SingleOptvalOption< T >::SingleOptvalOption ( const std::string &  name,
char  shortName,
const std::string &  longName,
const std::string &  usage = std::string(),
const std::string &  description = std::string() 
) [inline, protected]

Member Function Documentation

template<typename T >
virtual bool wibble::commandline::SingleOptvalOption< T >::arg_is_optional (  )  const [inline, protected, virtual]

Return true if the argument to this function can be omitted.

Reimplemented from wibble::commandline::Option.

template<typename T >
bool wibble::commandline::SingleOptvalOption< T >::hasValue (  )  const [inline]
template<typename T >
bool wibble::commandline::SingleOptvalOption< T >::parse ( const std::string &  param  )  [inline, protected, virtual]
template<typename T >
ArgList::iterator wibble::commandline::SingleOptvalOption< T >::parse ( ArgList list,
ArgList::iterator  begin 
) [inline, protected, virtual]

Parse the next commandline parameter after the short form of the command has been found.

It may or may not remove the parameter from the list, depending on if the option wants a value or not.

Signal that the option has been found, with the given argument (or 0 if no argument).

Returns:
true if it used the argument, else false

Implements wibble::commandline::Option.

Referenced by wibble::commandline::SingleOptvalOption< T >::parse().

template<typename T >
void wibble::commandline::SingleOptvalOption< T >::parse_noarg (  )  [inline, protected, virtual]

Notify that the option is present in the command line, but has no arguments.

Implements wibble::commandline::Option.

References wibble::commandline::SingleOptvalOption< T >::m_hasval, and wibble::commandline::Option::m_isset.

template<typename T >
void wibble::commandline::SingleOptvalOption< T >::setValue ( const typename T::value_type &  a  )  [inline]
template<typename T >
T::value_type wibble::commandline::SingleOptvalOption< T >::value (  )  const [inline]

Friends And Related Function Documentation

template<typename T >
friend class Engine [friend]

Reimplemented from wibble::commandline::Option.

template<typename T >
friend class OptionGroup [friend]

Reimplemented from wibble::commandline::Option.


Member Data Documentation

template<typename T >
bool wibble::commandline::SingleOptvalOption< T >::m_hasval [protected]
template<typename T >
T::value_type wibble::commandline::SingleOptvalOption< T >::m_value [protected]

The documentation for this class was generated from the following file: