11 #ifndef _LIMBO_PROGRAMOPTIONS_CONVERSIONHELPERS_H
12 #define _LIMBO_PROGRAMOPTIONS_CONVERSIONHELPERS_H
23 namespace programoptions
40 inline bool operator()(T& target,
const char* value)
const
58 inline void operator()(std::ostream& os, T
const& target)
const
107 inline bool operator()(
bool& target,
const char* value)
const
126 inline bool operator()(
char& target,
const char* value)
const
141 inline bool operator()(
unsigned char& target,
const char* value)
const
158 target = atoi(value);
171 inline bool operator()(
unsigned int& target,
const char* value)
const
173 target = atoi(value);
186 inline bool operator()(
long& target,
const char* value)
const
188 target = atol(value);
201 inline bool operator()(
unsigned long& target,
const char* value)
const
203 target = atol(value);
216 inline bool operator()(
long long& target,
const char* value)
const
218 target = atol(value);
231 inline bool operator()(
unsigned long long& target,
const char* value)
const
233 target = atol(value);
246 inline bool operator()(
float& target,
const char* value)
const
248 target = atof(value);
261 inline bool operator()(
double& target,
const char* value)
const
263 target = atof(value);
271 template <
typename T>
277 inline bool operator()(std::vector<T>& target,
const char* value)
const
289 template <
typename T>
295 inline bool operator()(std::set<T>& target,
const char* value)
const
314 inline void operator()(std::ostream& os,
bool const& target)
const
316 os << ((target)?
"true" :
"false");
323 template <
typename T>
329 inline void operator()(std::ostream& os, std::vector<T>
const& target)
const
331 const char* prefix =
"";
332 for (
typename std::vector<T>::const_iterator it = target.begin(); it != target.end(); ++it)
344 template <
typename T>
350 inline void operator()(std::ostream& os, std::set<T>
const& target)
const
352 const char* prefix =
"";
353 for (
typename std::set<T>::const_iterator it = target.begin(); it != target.end(); ++it)
void operator()(std::ostream &os, bool const &target) const
printing target
bool operator()(long &target, const char *value) const
parse a char-based string to target
metafunction for parsing a char-based string to a target data type
bool operator()(std::vector< T > &target, const char *value) const
parse a char-based string to target
bool operator()(std::set< T > &target, const char *value) const
parse a char-based string to target
bool operator()(unsigned char &target, const char *value) const
parse a char-based string to target
bool operator()(bool &target, const char *value) const
parse a char-based string to target
bool operator()(unsigned int &target, const char *value) const
parse a char-based string to target
bool operator()(unsigned long long &target, const char *value) const
parse a char-based string to target
void operator()(std::ostream &os, T const &target) const
printing target
bool operator()(float &target, const char *value) const
parse a char-based string to target
bool operator()(bool const &target) const
generic boolean operation
metafunction for printing a target data type
bool operator()(unsigned long &target, const char *value) const
parse a char-based string to target
void operator()(T &target, T const &source) const
assign source to target
bool operator()(double &target, const char *value) const
parse a char-based string to target
bool operator()(int &target, const char *value) const
parse a char-based string to target
void operator()(std::ostream &os, std::set< T > const &target) const
printing target
bool operator()(T &target, const char *value) const
parse a char-based string to target
bool iequals(string const &s1, string const &s2)
check two strings equal, case-insensitive
Check string is integer, floating point, number... Convert string to upper/lower cases.
metafunction for assign a source data type to a target data type
void operator()(std::ostream &os, std::vector< T > const &target) const
printing target
bool operator()(char &target, const char *value) const
parse a char-based string to target
metafunction for boolean operation
bool operator()(long long &target, const char *value) const
parse a char-based string to target
bool operator()(T const &) const
generic boolean operation