26 template<
typename T>
inline std::string
toString(
const T &value) {
27 std::ostringstream out;
34 std::ostringstream out;
35 out << std::boolalpha << value;
41 const int sigDigits = std::numeric_limits<double>::digits10;
42 std::ostringstream out;
43 out << std::setprecision(sigDigits) << value;
49 const int sigDigits = std::numeric_limits<float>::digits10;
50 std::ostringstream out;
51 out << std::setprecision(sigDigits) << value;
57 const int sigDigits = std::numeric_limits<long double>::digits10;
58 std::ostringstream out;
59 out << std::setprecision(sigDigits) << value;
66 template<>
inline std::string toString<std::string>(
const std::string &value) {
67 return std::string(value);
75 return std::string(value);
82 return std::string(1, value);
95 template<
typename N>
inline bool strToNum(
const std::string &str,
96 N &number, std::ios_base &(* format)(std::ios_base &) = std::dec) {
97 return !(std::istringstream(str) >> format >> number).fail();
100 #endif // #ifndef CONVERSIONS_H
std::string toString< PtrToChar >(const PtrToChar &value)
Specialization for char *.
Definition: conversions.h:74
std::string toString< long double >(const long double &value)
Specialization for long double.
Definition: conversions.h:56
char * PtrToChar
Definition: conversions.h:72
std::string toString< float >(const float &value)
Specialization for float.
Definition: conversions.h:48
std::string toString< bool >(const bool &value)
Specialization for bool.
Definition: conversions.h:33
std::string toString(const T &value)
Converts the selected value into a string.
Definition: conversions.h:26
bool strToNum(const std::string &str, N &number, std::ios_base &(*format)(std::ios_base &)=std::dec)
Converts the selected string into a number.
Definition: conversions.h:95
std::string toString< char >(const char &value)
Specialization for char.
Definition: conversions.h:81
std::string toString< double >(const double &value)
Specialization for double.
Definition: conversions.h:40