clockUtils  1.1
clockUtils::argParser::Variable< T > Class Template Reference

specialization of the variable, depending on the template type More...

#include <BasicVariable.h>

Inheritance diagram for clockUtils::argParser::Variable< T >:
Inheritance graph

Public Member Functions

 Variable (const std::string &longname, const std::string &shortname, const std::string &description, T value, bool required, bool multiple)
 initializes a new variable taking the argument name, the description text and a default value, calls constructor of BasicVariable More...
 
bool isBool () const override
 returns true, if T is bool, otherwise false. Default implementation always returns false, for bool this method is specialized More...
 
bool setValue (const std::string &value) override
 sets the parsed value of the argument and returns true, if value was valid, otherwise false More...
 
T & operator= (const T &val)
 assignment operator taking type T More...
 
 operator T () const
 operator casting Variable<T> to T More...
 
size_t count () const
 returns amount of values provided if using multiple More...
 
at (size_t idx) const
 returns value at position idx, idx = 0 is _value, idx = 1 is first element of _values, idx >= count results in undefined behaviour More...
 
template<>
bool CLOCK_ARGPARSER_API setValue (const std::string &value)
 specialization of setValue for std::string so it can work with strings containing spaces More...
 
template<>
bool CLOCK_ARGPARSER_API setValue (const std::string &value)
 specialization of setValue for char because chars contain only one single character More...
 
template<>
bool CLOCK_ARGPARSER_API setValue (const std::string &value)
 specialization of setValue for bool because it shall also allow usage of true and false More...
 
- Public Member Functions inherited from clockUtils::argParser::BasicVariable
 BasicVariable (const std::string &longname, const std::string &shortname, const std::string &description, bool required, bool multiple)
 constructor taking the longname (= argument in argument list), shortname (= short name for the argument list) and a description text for –help, inserts variable into the variableList of the Parser More...
 
virtual ~BasicVariable ()
 destructor, removes variable of the variableList of the Parser More...
 
std::string getLongname () const
 returns the argument of the variable More...
 
std::string getShortname () const
 returns the argument of the variable More...
 
bool isSet () const
 returns true, if this variable was set via command line More...
 
bool isRequired () const
 returns true, if this variable is required to be set More...
 
bool canHaveMultiple () const
 returns true, if this variable can have multiple values More...
 

Friends

bool operator== (const T &first, const Variable< T > &second)
 operator comparing type T and Variable containing type T More...
 
bool operator== (const Variable< T > &first, const T &second)
 
bool operator!= (const T &first, const Variable< T > &second)
 
bool operator!= (const Variable< T > &first, const T &second)
 
std::ostream & operator<< (std::ostream &out, Variable &v)
 stream operator More...
 

Additional Inherited Members

- Protected Attributes inherited from clockUtils::argParser::BasicVariable
bool _set
 tells whether the variable was set via command line or not More...
 

Detailed Description

template<typename T>
class clockUtils::argParser::Variable< T >

specialization of the variable, depending on the template type

Definition at line 143 of file BasicVariable.h.

Constructor & Destructor Documentation

§ Variable()

template<typename T>
clockUtils::argParser::Variable< T >::Variable ( const std::string &  longname,
const std::string &  shortname,
const std::string &  description,
value,
bool  required,
bool  multiple 
)
inline

initializes a new variable taking the argument name, the description text and a default value, calls constructor of BasicVariable

Definition at line 148 of file BasicVariable.h.

Member Function Documentation

§ at()

template<typename T>
T clockUtils::argParser::Variable< T >::at ( size_t  idx) const
inline

returns value at position idx, idx = 0 is _value, idx = 1 is first element of _values, idx >= count results in undefined behaviour

Definition at line 225 of file BasicVariable.h.

Here is the call graph for this function:

§ count()

template<typename T>
size_t clockUtils::argParser::Variable< T >::count ( ) const
inline

returns amount of values provided if using multiple

Definition at line 218 of file BasicVariable.h.

§ isBool()

template<typename T>
bool clockUtils::argParser::Variable< T >::isBool ( ) const
inlineoverridevirtual

returns true, if T is bool, otherwise false. Default implementation always returns false, for bool this method is specialized

Implements clockUtils::argParser::BasicVariable.

Definition at line 154 of file BasicVariable.h.

§ operator T()

template<typename T>
clockUtils::argParser::Variable< T >::operator T ( ) const
inline

operator casting Variable<T> to T

Definition at line 203 of file BasicVariable.h.

§ operator=()

template<typename T>
T& clockUtils::argParser::Variable< T >::operator= ( const T &  val)
inline

assignment operator taking type T

Definition at line 195 of file BasicVariable.h.

§ setValue() [1/4]

template<typename T>
bool clockUtils::argParser::Variable< T >::setValue ( const std::string &  value)
inlineoverridevirtual

sets the parsed value of the argument and returns true, if value was valid, otherwise false

Implements clockUtils::argParser::BasicVariable.

Definition at line 161 of file BasicVariable.h.

Here is the caller graph for this function:

§ setValue() [2/4]

template<>
bool CLOCK_ARGPARSER_API clockUtils::argParser::Variable< std::string >::setValue ( const std::string &  value)
virtual

specialization of setValue for std::string so it can work with strings containing spaces

Implements clockUtils::argParser::BasicVariable.

§ setValue() [3/4]

template<>
bool CLOCK_ARGPARSER_API clockUtils::argParser::Variable< char >::setValue ( const std::string &  value)
virtual

specialization of setValue for char because chars contain only one single character

Implements clockUtils::argParser::BasicVariable.

§ setValue() [4/4]

template<>
bool CLOCK_ARGPARSER_API clockUtils::argParser::Variable< bool >::setValue ( const std::string &  value)
virtual

specialization of setValue for bool because it shall also allow usage of true and false

Implements clockUtils::argParser::BasicVariable.

Friends And Related Function Documentation

§ operator!= [1/2]

template<typename T>
bool operator!= ( const T &  first,
const Variable< T > &  second 
)
friend

Definition at line 184 of file BasicVariable.h.

§ operator!= [2/2]

template<typename T>
bool operator!= ( const Variable< T > &  first,
const T &  second 
)
friend

Definition at line 188 of file BasicVariable.h.

§ operator<<

template<typename T>
std::ostream& operator<< ( std::ostream &  out,
Variable< T > &  v 
)
friend

stream operator

Definition at line 210 of file BasicVariable.h.

§ operator== [1/2]

template<typename T>
bool operator== ( const T &  first,
const Variable< T > &  second 
)
friend

operator comparing type T and Variable containing type T

Definition at line 176 of file BasicVariable.h.

§ operator== [2/2]

template<typename T>
bool operator== ( const Variable< T > &  first,
const T &  second 
)
friend

Definition at line 180 of file BasicVariable.h.


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