Option Class Referenceabstract

Implementation of the IOptionsParser interface. More...

#include <OptionsParser.hpp>

Inheritance diagram for Option:
Inheritance graph

Public Member Functions

 Option (const std::string &name, int nbArgs, bool mandatory, const std::string &defaultValue, bool visible, const std::string &help)
virtual ~Option ()
std::string getDefaultValue () const
void setDefaultValue (const std::string &value)
bool isMandatory () const
IOptionsParsergetParser (const std::string &name)
void accept (IOptionsParserVisitor &visitor, size_t depth=0)
- Public Member Functions inherited from OptionsParser
 OptionsParser (const std::string &name="", const std::string &help="")
virtual ~OptionsParser ()
const std::string & getName () const
void setName (const std::string &name)
void setVisible (bool status)
bool isVisible () const
const std::string & getHelp () const
void setHelp (const std::string &help)
misc::IPropertiesparse (int argc, char **argv)
misc::IPropertiesparseString (const std::string &s)
misc::IPropertiesgetProperties ()
bool saw (const std::string &name) const
void push_back (IOptionsParser *parser, size_t expandDepth=0, bool visibility=true)
void push_front (IOptionsParser *parser, size_t expandDepth=0, bool visibility=true)
std::list< IOptionsParser * > & getParsers ()
misc::IPropertiesgetDefaultProperties ()
- Public Member Functions inherited from SmartPointer
void use ()
void forget ()
- Public Member Functions inherited from ISmartPointer
virtual ~ISmartPointer ()

Protected Member Functions

size_t getNbArgs () const
virtual void proceed (const std::list< std::string > &args, IProperties &props)=0
- Protected Member Functions inherited from SmartPointer
 SmartPointer ()
virtual ~SmartPointer ()

Detailed Description

Implementation of the IOptionsParser interface.

This implementation represents the 'leaf' part of the Composite design pattern.

Constructor & Destructor Documentation

Option ( const std::string &  name,
int  nbArgs,
bool  mandatory,
const std::string &  defaultValue,
bool  visible,
const std::string &  help 


[in]name: name of the option
[in]nbArgs: number of arguments for this option
[in]mandatory: tells whether this option is mandatory or not
[in]defaultValue: default value for the option
[in]visible: tells whether this option may be shown in help
[in]help: textual help for this option
virtual ~Option ( )


Member Function Documentation

void accept ( IOptionsParserVisitor visitor,
size_t  depth = 0 

Visitor design pattern.

Reimplemented from OptionsParser.

std::string getDefaultValue ( ) const

Get the default value for the option

the default value (may be empty)
size_t getNbArgs ( ) const

Gives the number of arguments that must follow the option.

the arguments number.
IOptionsParser* getParser ( const std::string &  name)

Get a parser given its name.

[in]name: name of the parser to be retrieved
the parser instance if found, 0 otherwise.

Reimplemented from OptionsParser.

bool isMandatory ( ) const

Tells whether the option is mandatory or not.

the mandatory status.
virtual void proceed ( const std::list< std::string > &  args,
IProperties props 
protectedpure virtual

When an option is recognized in the arguments list, we look the number of waited args and put them in a list of string objects. This is this list that is given as argument of the proceed() method that mainly will affect the given args to the variable given to the instantiation of the (derived class) Option.

Implemented in OptionOneParam, and OptionNoParam.

void setDefaultValue ( const std::string &  value)

Set the default value for the option

[in]value: the default value (may be empty)

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