9 #ifndef _TurtleBrains_String_h_
10 #define _TurtleBrains_String_h_
12 #include "tb_configuration.h"
28 #define tb_string(object) TurtleBrains::Core::ToString((object))
50 template <
typename T> std::string
ToStdString(
const T&
object)
80 std::stringstream stream;
81 const std::ctype<char>& ctfacet = std::use_facet< std::ctype<char> >(stream.getloc());
82 for (
size_t i = 0; i <
object.size(); ++i)
84 stream << static_cast<char>(ctfacet.narrow(static_cast<char>(
object[i]),
'?'));
112 std::stringstream ss;
115 ss.precision(precision);
136 tb_error_if(
true == input.empty(),
"Invalid value for parameter: input, expected valid, non-empty, string.");
138 std::stringstream ss(input);
156 return FromStdString<T>(input);
176 std::wstringstream wss;
203 std::wostringstream stream;
204 const std::ctype<wchar_t>& ctfacet = std::use_facet< std::ctype<wchar_t> >(stream.getloc());
205 for (
size_t i = 0; i <
object.size(); ++i)
207 stream << ctfacet.widen(
object[i]);
235 std::wstringstream wss;
238 wss.precision(precision);
259 tb_error_if(
true == input.empty(),
"Invalid value for parameter: input, expected valid, non-empty, string.");
261 std::wstringstream wss(input);
277 template <
typename T> T
FromString(
const std::wstring& input)
279 return FromWideString<T>(input);
297 #ifdef tb_with_wide_string
371 template <
typename T> tbString
ToString(
const T&
object)
373 #ifdef tb_with_wide_string
380 inline tbString
ToString(
float value,
int precision = 0)
382 #ifdef tb_with_wide_string
T FromString(const std::string &input)
Definition: tb_string.h:154
tbString ToString(const T &object)
Definition: tb_string.h:371
std::string ToStdString(const T &object)
Definition: tb_string.h:50
T FromWideString(const std::wstring &input)
Definition: tb_string.h:257
Here is some information about the primary namespace.
Definition: tb_application_dialog.h:21
T FromStdString(const std::string &input)
Definition: tb_string.h:134
std::wstring ToWideString(const T &object)
Definition: tb_string.h:174
Contains core functionality for each component of the API.
Definition: tb_debug_logger.h:91
#define tb_error_if(errorTest, message,...)
Definition: tb_error.h:37
std::string tbString
Definition: tb_string.h:335