Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
EnumOption< T > Class Template Reference

#include <elm/option/EnumOption.h>

+ Inheritance diagram for EnumOption< T >:

Classes

class  Make
 

Public Types

typedef Pair< cstring, T > value_t
 

Public Member Functions

 EnumOption (const Make &m)
 
value (void) const
 
void set (const T &value)
 
usage_t usage (void) override
 
void process (String arg) override
 
cstring argDescription (void) override
 
 operator T (void) const
 
EnumOptionoperator= (const T &value)
 
- Public Member Functions inherited from Option
 Option ()
 
 Option (const Make &make)
 
virtual ~Option ()
 
virtual cstring description ()
 

Additional Inherited Members

- Protected Attributes inherited from Option
cstring desc
 

Detailed Description

template<class T>
class elm::option::EnumOption< T >

This class handle enumerations in command line arguments. At construction time, it receive an associative array of EnumOption::value_t that matches T values with their name. The first item of this array is used to get the default value of the option and the argument description for help display.

Parameters
TType of the enumerated value.

Member Typedef Documentation

◆ value_t

typedef Pair<cstring, T> value_t

Constructor & Destructor Documentation

◆ EnumOption()

EnumOption ( const Make m)
inline

Build a boolean option with a long name.

Parameters
managerParent option manager.
long_nameMultiple-letter name.
descriptionOption description.
valuesList of enumerated values.

Build a boolean option with a short name and a long name.

Parameters
managerParent option manager.
short_nameSingle-letter name.
long_nameMultiple-letter name.
descriptionOption description.
valuesList of enumerated values.

Member Function Documentation

◆ argDescription()

cstring argDescription ( void  )
inlineoverridevirtual

If the option requires an argument, get the description of the argument.

Returns
Argument description.

Implements Option.

◆ operator T()

operator T ( void  ) const
inline

Shortcut to get().

References EnumOption< T >::value().

◆ operator=()

EnumOption & operator= ( const T &  value)
inline

Shortcut to set().

References EnumOption< T >::set().

◆ process()

void process ( String  arg)
inlineoverridevirtual

This method is called by the option manager when the option is encountered.

Parameters
argIf the option requires an argument, the value of the argument.

Implements Option.

References elm::_.

◆ set()

void set ( const T &  value)
inline

Change the current value of the option.

Parameters
valueNew value of the option.

References EnumOption< T >::value().

Referenced by EnumOption< T >::operator=().

◆ usage()

usage_t usage ( void  )
inlineoverridevirtual

Get the argument usage type of this function.

Returns
Argument usage type.

Implements Option.

References elm::option::arg_required.

◆ value()

const T & value ( void  ) const
inline

Get the current value of the option.

Returns
Current value.

Referenced by EnumOption< T >::operator T(), and EnumOption< T >::set().


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