51 bool toDouble(
const std::string&
string,
double& value)
61 double value_new = std::strtod(
string.c_str(), &end);
63 if (errno != 0 || end !=
string.c_str() +
string.length())
77 bool toFloat(
const std::string&
string,
float& value)
86 float value_new = std::strtof(
string.c_str(), &end);
88 if (errno != 0 || end !=
string.c_str() +
string.length())
102 bool toInt32(
const std::string&
string, int32_t& value, int32_t base)
111 int64_t value_new = std::strtol(
string.c_str(), &end, base);
113 if (errno != 0 || end !=
string.c_str() +
string.length())
118 if (value_new > std::numeric_limits<int32_t>::max() ||
119 value_new < std::numeric_limits<int32_t>::min())
124 value = (int32_t) value_new;
133 bool toUInt32(
const std::string&
string, uint32_t& value, int32_t base)
142 int64_t value_new = std::strtol(
string.c_str(), &end, base);
144 if (errno != 0 || end !=
string.c_str() +
string.length())
149 if (value_new > std::numeric_limits<uint32_t>::max() || value_new < 0)
154 value = (uint32_t) value_new;
161 int8_t
toInt8(
const std::string&
string, int8_t& value, int32_t base)
165 int64_t value_new = std::strtol(
string.c_str(), &end, base);
167 value = (int8_t) value_new;
174 uint8_t
toUInt8(
const std::string&
string, uint8_t& value, int32_t base)
178 int64_t value_new = std::strtol(
string.c_str(), &end, base);
180 value = (uint8_t) value_new;
186 for(std::string::size_type s=str.length()-1; s>0; --s)
188 if(str[s] ==
'0' && !isdigit(str[s-1]))
break;
189 else if (str[s] ==
'0') str.erase(s,1);
bool toFloat(const std::string &string, float &value)
Interprets the contents of "string" as a floating point number of type float.
bool toDouble(const std::string &string, double &value)
Interprets the contents of "string" as a floating point number of type double It stores the "string"'...
uint8_t toUInt8(const std::string &string, uint8_t &value, int32_t base)
Interprets the contents of "string" as a floating point number of whatever unsigned integer type your...
bool toUInt32(const std::string &string, uint32_t &value, int32_t base)
Interprets the contents of "string" as a floating point number of whatever unsigned integer type your...
Declares lower-level string utility functions used when parsing messages.
int8_t toInt8(const std::string &string, int8_t &value, int32_t base)
Interprets the contents of "string" as a floating point number of whatever integer type your system h...
std::string trimString(std::string str)
Removes trailing zeros from a string representing a float or double except for the first zero after t...
bool toInt32(const std::string &string, int32_t &value, int32_t base)
Interprets the contents of "string" as a floating point number of whatever integer type your system h...