wibble  1.1
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
wibble::commandline::Option Class Referenceabstract

Interface for a parser for one commandline option. More...

#include <options.h>

Inheritance diagram for wibble::commandline::Option:
Inheritance graph
[legend]
Collaboration diagram for wibble::commandline::Option:
Collaboration graph
[legend]

Public Member Functions

 Option ()
 
virtual ~Option ()
 
bool isSet () const
 
const std::string & name () const
 
void addAlias (char c)
 
void addAlias (const std::string &str)
 
const std::string & fullUsage () const
 Return a full usage message including all the aliases for this option. More...
 
std::string fullUsageForMan () const
 
- Public Member Functions inherited from wibble::commandline::Managed
virtual ~Managed ()
 

Public Attributes

std::vector< char > shortNames
 
std::vector< std::string > longNames
 
std::string usage
 
std::string description
 
bool hidden
 

Protected Member Functions

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

Protected Attributes

bool m_isset
 

Friends

class OptionGroup
 
class Engine
 

Detailed Description

Interface for a parser for one commandline option.

Constructor & Destructor Documentation

◆ Option() [1/3]

wibble::commandline::Option::Option ( const std::string &  name)
inlineprotected

◆ Option() [2/3]

wibble::commandline::Option::Option ( const std::string &  name,
char  shortName,
const std::string &  longName,
const std::string &  usage = std::string(),
const std::string &  description = std::string() 
)
inlineprotected

◆ Option() [3/3]

wibble::commandline::Option::Option ( )

◆ ~Option()

virtual wibble::commandline::Option::~Option ( )
inlinevirtual

Member Function Documentation

◆ addAlias() [1/2]

void wibble::commandline::Option::addAlias ( char  c)
inline

◆ addAlias() [2/2]

void wibble::commandline::Option::addAlias ( const std::string &  str)
inline

◆ arg_is_optional()

virtual bool wibble::commandline::Option::arg_is_optional ( ) const
inlineprotectedvirtual

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

Reimplemented in wibble::commandline::SingleOptvalOption< T >.

Referenced by fullUsage(), and fullUsageForMan().

◆ fullUsage()

const std::string & wibble::commandline::Option::fullUsage ( ) const

Return a full usage message including all the aliases for this option.

References arg_is_optional(), longNames, and shortNames.

◆ fullUsageForMan()

std::string wibble::commandline::Option::fullUsageForMan ( ) const

◆ isSet()

bool wibble::commandline::Option::isSet ( ) const
inline

◆ name()

const std::string& wibble::commandline::Option::name ( ) const
inline

◆ parse() [1/2]

virtual ArgList::iterator wibble::commandline::Option::parse ( ArgList list,
ArgList::iterator  begin 
)
protectedpure 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

Implemented in wibble::commandline::VectorOption< T >, wibble::commandline::SingleOptvalOption< T >, wibble::commandline::SingleOption< T >, and wibble::commandline::BoolOption.

◆ parse() [2/2]

virtual bool wibble::commandline::Option::parse ( const std::string &  param)
protectedpure virtual

Parse the commandline parameter of a long commandline switch.

Returns
true if the parameter has been used

Implemented in wibble::commandline::VectorOption< T >, wibble::commandline::SingleOptvalOption< T >, wibble::commandline::SingleOption< T >, and wibble::commandline::BoolOption.

◆ parse_noarg()

virtual void wibble::commandline::Option::parse_noarg ( )
protectedpure virtual

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

Implemented in wibble::commandline::VectorOption< T >, wibble::commandline::SingleOptvalOption< T >, wibble::commandline::SingleOption< T >, and wibble::commandline::BoolOption.

Friends And Related Function Documentation

◆ Engine

friend class Engine
friend

◆ OptionGroup

friend class OptionGroup
friend

Member Data Documentation

◆ description

std::string wibble::commandline::Option::description

◆ hidden

bool wibble::commandline::Option::hidden

◆ longNames

std::vector<std::string> wibble::commandline::Option::longNames

◆ m_isset

bool wibble::commandline::Option::m_isset
protected

◆ shortNames

std::vector<char> wibble::commandline::Option::shortNames

◆ usage

std::string wibble::commandline::Option::usage

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