7 #ifndef CVRT_TEXT_H_018727339083427097434
8 #define CVRT_TEXT_H_018727339083427097434
11 #include <zen/string_tools.h>
66 template <
class T>
bool readText(
const std::string& input, T& value);
72 template <
class T>
void writeText(
const T& value, std::string& output);
114 struct GetTextType : StaticEnum<TextType,
115 IsSameType<T, bool>::value ? TEXT_TYPE_BOOL :
116 IsStringLike<T>::value ? TEXT_TYPE_STRING :
117 IsArithmetic<T>::value ? TEXT_TYPE_NUMBER :
122 template <
class T, TextType type>
133 struct ConvertText<T, TEXT_TYPE_BOOL>
135 void writeText(
bool value, std::string& output)
const
137 output = value ?
"true" :
"false";
139 bool readText(
const std::string& input,
bool& value)
const
141 const std::string tmp = trimCpy(input);
144 else if (tmp ==
"false")
154 struct ConvertText<T, TEXT_TYPE_NUMBER>
156 void writeText(
const T& value, std::string& output)
const
158 output = numberTo<std::string>(value);
160 bool readText(
const std::string& input, T& value)
const
162 value = stringTo<T>(input);
169 struct ConvertText<T, TEXT_TYPE_STRING>
171 void writeText(
const T& value, std::string& output)
const
173 output = utfCvrtTo<std::string>(value);
175 bool readText(
const std::string& input, T& value)
const
177 value = utfCvrtTo<T>(input);
185 struct ConvertText<T, TEXT_TYPE_OTHER>
188 static_assert(
sizeof(T) == -1,
"");
206 template <
class T>
inline
209 ConvertText<T, GetTextType<T>::value>().
writeText(value, output);
213 template <
class T>
inline
216 return ConvertText<T, GetTextType<T>::value>().
readText(input, value);
220 #endif //CVRT_TEXT_H_018727339083427097434
bool readText(const std::string &input, T &value)
Convert text to user data - used by XML elements and attributes.
Definition: cvrt_text.h:214
The zen::Xml namespace.
Definition: bind.h:15
void writeText(const T &value, std::string &output)
Convert user data into text - used by XML elements and attributes.
Definition: cvrt_text.h:207