24 #include <utils/misc/string_conversions.h> 25 #include <core/exceptions/system.h> 48 for(
unsigned int i = 0; i < str.length(); ++i) {
49 str[i] = (char)toupper(str[i]);
62 for(
unsigned int i = 0; i < str.length(); ++i) {
63 str[i] = (char)tolower(str[i]);
78 if (asprintf(&tmp,
"%u", i) == -1) {
79 throw OutOfMemoryException(
"StringConversions::tostring(const unsigned int): asprintf() failed");
96 if (asprintf(&tmp,
"%i", i) == -1) {
114 if (asprintf(&tmp,
"%li", i) == -1) {
132 if (asprintf(&tmp,
"%f", f) == -1) {
150 if (asprintf(&tmp,
"%f", d) == -1) {
167 return std::string(
"true");
169 return std::string(
"false");
181 unsigned int l = atoll(s.c_str());
193 return atoi(s.c_str());
204 return (
float)atof(s.c_str());
215 return atof(s.c_str());
226 if ( (s ==
"true") ||
242 std::string::size_type p1 = s.find_first_not_of(
' ');
243 std::string::size_type p2 = s.find_last_not_of(
' ');
244 s = s.substr(p1 == std::string::npos ? 0 : p1,
245 p2 == std::string::npos ? s.length() - 1 : p2 - p1 + 1);
257 std::string::size_type p1 = s.find_first_not_of(
' ');
258 std::string::size_type p2 = s.find_last_not_of(
' ');
259 return s.substr(p1 == std::string::npos ? 0 : p1,
260 p2 == std::string::npos ? s.length() - 1 : p2 - p1 + 1);
static std::string to_upper(std::string str)
Convert string to all-uppercase string.
Fawkes library namespace.
static std::string to_lower(std::string str)
Convert string to all-lowercase string.
static void trim_inplace(std::string &s)
Trim string.
static int to_int(std::string s)
Convert string to an int value.
static std::string trim(std::string &s)
Trim spring.
static float to_float(std::string s)
Convert string to a float value.
static bool to_bool(std::string s)
Convert string to a bool value.
static double to_double(std::string s)
Convert string to a double value.
static std::string to_string(unsigned int i)
Convert unsigned int value to a string.
System ran out of memory and desired operation could not be fulfilled.
static unsigned int to_uint(std::string s)
Convert string to an unsigned int value.