iRoCS Toolbox  1.1.0
Public Member Functions | Protected Member Functions | Protected Attributes
Compiler< T > Class Template Reference

The Compiler class is used by CmdArg classes to convert strings into desired datatypes. More...

#include <Compiler.hh>

Collaboration diagram for Compiler< T >:

Public Member Functions

template<>
bool compile (const char *arg, const char *&endptr, int &value)
 
bool compile (const char *arg, const char *&enptr, T &value)
 Convert the given string into the desired datatype T. More...
 
template<>
bool compile (const char *arg, const char *&endptr, double &value)
 
template<>
bool compile (const char *arg, const char *&endptr, std::string &value)
 
template<>
bool compile (const char *arg, const char *&endptr, bool &value)
 
const std::string & errorMsg () const
 Return the error message of the last compilation. More...
 

Protected Member Functions

void setErrorMsg (const std::string &msg)
 Set the error message. More...
 

Protected Attributes

std::string pErrorMsg
 

Detailed Description

template<typename T>
class Compiler< T >

The Compiler class is used by CmdArg classes to convert strings into desired datatypes.

Definition at line 64 of file Compiler.hh.

Member Function Documentation

◆ compile() [1/5]

template<typename T>
bool Compiler< T >::compile ( const char *  arg,
const char *&  enptr,
T &  value 
)

Convert the given string into the desired datatype T.

If the compilation was not successful, false is returned and the error message is set. If endptr!=0 the function sets endptr to the first unrecognized char in arg or to 0 if there are no unrecognized chars. NOTE: This function must always successfully accept NULL strings.

Parameters
argthe string that is to be converted
endptrmust point to first unrecognized char in arg
valuehere the converted value is stored
Returns
true, if the compilation was successful

◆ errorMsg()

template<typename T>
const std::string& Compiler< T >::errorMsg ( ) const
inline

Return the error message of the last compilation.

Returns
error message

Definition at line 98 of file Compiler.hh.

◆ setErrorMsg()

template<typename T>
void Compiler< T >::setErrorMsg ( const std::string &  msg)
inlineprotected

Set the error message.

Parameters
msgerror message

Definition at line 114 of file Compiler.hh.

◆ compile() [2/5]

template<>
bool Compiler< int >::compile ( const char *  arg,
const char *&  endptr,
int &  value 
)

Definition at line 62 of file Compilers.hh.

◆ compile() [3/5]

template<>
bool Compiler< double >::compile ( const char *  arg,
const char *&  endptr,
double &  value 
)

Definition at line 94 of file Compilers.hh.

◆ compile() [4/5]

template<>
bool Compiler< std::string >::compile ( const char *  arg,
const char *&  endptr,
std::string &  value 
)

Definition at line 126 of file Compilers.hh.

◆ compile() [5/5]

template<>
bool Compiler< bool >::compile ( const char *  arg,
const char *&  endptr,
bool &  value 
)

Definition at line 142 of file Compilers.hh.

Field Documentation

◆ pErrorMsg

template<typename T>
std::string Compiler< T >::pErrorMsg
protected

Definition at line 117 of file Compiler.hh.

Referenced by Compiler< T >::errorMsg(), and Compiler< T >::setErrorMsg().


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