iLab Neuromorphic Robotics Toolkit  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages

Functions

template<class T >
void nrt::paramValToString (T const &val, std::string &result)
 Machine-readable conversion of T to a string, for use in nrt::Parameter. More...
 
template<class T >
void nrt::paramStringToVal (std::string const &valstring, T &result)
 Machine-readable conversion from string to T, for use in nrt::Parameter. More...
 
template<class Q >
void nrt::paramValToString (std::vector< Q > const &val, std::string &result)
 Machine-readable output to a string, for use in nrt::Parameter: outputs [Element1, Element2, ...]. More...
 
template<class Q >
void nrt::paramStringToVal (std::string const &valstring, std::vector< Q > &result)
 Machine-readable input from a string, for use in nrt::Parameter: reads [Element1, Element2, ...]. More...
 
template<class K , class V >
void nrt::paramValToString (std::map< K, V > const &val, std::string &result)
 Machine-readable output to a string, for use in nrt::Parameter: outputs [Key1:Value1, Key2:Value2, ...]. More...
 
template<class K , class V >
void nrt::paramStringToVal (std::string const &valstring, std::map< K, V > &result)
 Machine-readable input from a string, for use in nrt::Parameter: reads [Key1:Value1, Key2:Value2, ...]. More...
 
template<>
void nrt::paramValToString< bool > (bool const &val, std::string &result)
 Machine-readable conversion of bool to a string, for use in nrt::Parameter. More...
 
template<>
void nrt::paramStringToVal< bool > (std::string const &valstring, bool &result)
 Machine-readable conversion from string to bool, for use in nrt::Parameter. More...
 
template<>
void nrt::paramValToString< std::string > (std::string const &val, std::string &result)
 Machine-readable conversion of string to a string, for use in nrt::Parameter. More...
 
template<>
void nrt::paramStringToVal< std::string > (std::string const &valstring, std::string &result)
 Machine-readable conversion from string to string, for use in nrt::Parameter. More...
 

Function Documentation

template<class T >
void nrt::paramValToString ( T const &  val,
std::string &  result 
)
inline

Machine-readable conversion of T to a string, for use in nrt::Parameter.

A default implementation is provided which internally just uses boost::lexical_cast. When implementing new types that can be used as parameters, users should supply the appropriate template specialization for this function. This function is used internally by Parameter to get a Parameter value as string.

Definition at line 45 of file ParameterStringConversionImpl.H.

Referenced by nrt::ValidValuesSpecRegex< T >::checkValueValidity().

template<class T >
void nrt::paramStringToVal ( std::string const &  valstring,
T &  result 
)
inline

Machine-readable conversion from string to T, for use in nrt::Parameter.

Exceptions
Implementation-dependentexception encountered during conversion, if any, e.g., nrt::exception::Exception or, for the default implementation, boost::bad_lexical_cast.

A default implementation is provided which internally just uses boost::lexical_cast. When implementing new types that can be used as parameters, users should supply the appropriate template specialization for this function. This function is used internally by Parameter to set a Parameter value from string.

Definition at line 52 of file ParameterStringConversionImpl.H.

template<class Q >
void nrt::paramValToString ( std::vector< Q > const &  val,
std::string &  result 
)
inline

Machine-readable output to a string, for use in nrt::Parameter: outputs [Element1, Element2, ...].

Specialization for std::vector<T> which supports nesting of other vectors and vectors of other types such as Dims and Points

Definition at line 59 of file ParameterStringConversionImpl.H.

template<class Q >
void nrt::paramStringToVal ( std::string const &  valstring,
std::vector< Q > &  result 
)
inline

Machine-readable input from a string, for use in nrt::Parameter: reads [Element1, Element2, ...].

Exceptions
nrt::exception::Exceptionif input string is malformed. Specialization for std::vector<T> which supports nesting of other vectors and vectors of other types such as Dims and Points

Definition at line 66 of file ParameterStringConversionImpl.H.

template<class K , class V >
void nrt::paramValToString ( std::map< K, V > const &  val,
std::string &  result 
)
inline

Machine-readable output to a string, for use in nrt::Parameter: outputs [Key1:Value1, Key2:Value2, ...].

Specialization for std::map which supports nesting of other maps/vectors

Definition at line 73 of file ParameterStringConversionImpl.H.

template<class K , class V >
void nrt::paramStringToVal ( std::string const &  valstring,
std::map< K, V > &  result 
)
inline

Machine-readable input from a string, for use in nrt::Parameter: reads [Key1:Value1, Key2:Value2, ...].

Exceptions
nrt::exception::Exceptionif input string is malformed. Specialization for std::map which supports nesting of other maps/vectors

Definition at line 80 of file ParameterStringConversionImpl.H.

template<>
void nrt::paramValToString< bool > ( bool const &  val,
std::string &  result 
)
inline

Machine-readable conversion of bool to a string, for use in nrt::Parameter.

Returns
"true" or "false".

Definition at line 87 of file ParameterStringConversionImpl.H.

template<>
void nrt::paramStringToVal< bool > ( std::string const &  valstring,
bool &  result 
)
inline

Machine-readable conversion from string to bool, for use in nrt::Parameter.

Exceptions
nrt::exception::Exceptionif input string is malformed.

Specialization for bool so that we can accept nice verbose terms rather than just 0 and 1. Acceptable ways to set a bool Parameter are:

  • "true" or "false"
  • "t" or "f"
  • "yes" or "no"
  • "y" or "n"
  • 1 or 0
  • An empty string will set the Parameter to true, so you may use boolean parameters as switches, e.g., "--myFlag" is equivalent to "--myFlag=true"

Definition at line 94 of file ParameterStringConversionImpl.H.

template<>
void nrt::paramValToString< std::string > ( std::string const &  val,
std::string &  result 
)

Machine-readable conversion of string to a string, for use in nrt::Parameter.

This implementation just returns the original string.

template<>
void nrt::paramStringToVal< std::string > ( std::string const &  valstring,
std::string &  result 
)

Machine-readable conversion from string to string, for use in nrt::Parameter.

This implementation just returns the original string.