9 #ifndef TurtleBrains_String_hpp
10 #define TurtleBrains_String_hpp
12 #include <turtle_brains/core/tb_configuration.hpp>
13 #include <turtle_brains/core/tb_error.hpp>
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
395 return (tbCore::tbString::npos == input.find(contents)) ?
false :
true;
404 return (0 == input.find(contents)) ?
true :
false;
T FromString(const std::string &input)
Definition: tb_string.hpp:154
tbString ToString(const T &object)
Definition: tb_string.hpp:371
std::string ToStdString(const T &object)
Definition: tb_string.hpp:50
T FromWideString(const std::wstring &input)
Definition: tb_string.hpp:257
Here is some information about the primary namespace.
Definition: tb_application_dialog.hpp:21
T FromStdString(const std::string &input)
Definition: tb_string.hpp:134
std::wstring ToWideString(const T &object)
Definition: tb_string.hpp:174
bool StringStartsWith(const tbString &input, const tbString &contents)
Definition: tb_string.hpp:402
bool StringContains(const tbString &input, const tbString &contents)
Definition: tb_string.hpp:393
Contains core functionality for each component of the API.
Definition: tb_debug_logger.hpp:88
#define tb_error_if(errorTest, message,...)
Definition: tb_error.hpp:42
std::string tbString
Definition: tb_string.hpp:335