34 #define YARP_DOUBLE_TO_STRING_MAX_LENGTH (16 + DECIMAL_DIG + YARP_DBL_EXP_DIG)
48 inline std::string fp_to_string(T x)
59 struct lconv* lc = localeconv();
60 size_t offset = str.find(lc->decimal_point);
61 if (offset != std::string::npos) {
63 }
else if (str.find(
'e') == std::string::npos && str !=
"inf" && str !=
"-inf" && str !=
"nan") {
73 inline T fp_from_string(std::string src)
76 return std::numeric_limits<T>::infinity();
79 return -std::numeric_limits<T>::infinity();
82 return std::numeric_limits<T>::quiet_NaN();
86 size_t offset = src.find(
'.');
87 if (offset != std::string::npos) {
88 struct lconv* lc = localeconv();
89 src[offset] = lc->decimal_point[0];
91 return static_cast<T
>(strtod(src.c_str(),
nullptr));
100 memcpy((
char*)(&tmp), code.
get(), code.
length());
108 if (code.
length() !=
sizeof(i)) {
109 yCError(NETTYPE,
"not enough room for integer");
119 sprintf(buf,
"%x", x);
126 sprintf(buf,
"%lx", x);
133 sprintf(buf,
"%x", x);
141 sprintf(buf,
"%d", x);
148 sprintf(buf,
"%ld", x);
155 sprintf(buf,
"%u", x);
162 return atoi(x.c_str());
168 return fp_to_string(x);
173 return fp_to_string(x);
178 return fp_from_string<yarp::conf::float32_t>(s);
183 return fp_from_string<yarp::conf::float64_t>(s);
188 return fp_from_string<yarp::conf::float32_t>(std::move(s));
193 return fp_from_string<yarp::conf::float64_t>(std::move(s));
215 for (n = 0; n < 256; n++) {
216 c = (
unsigned long)n;
217 for (k = 0; k < 8; k++) {
219 c = 0xedb88320L ^ (c >> 1);
234 static unsigned long update_crc(
unsigned long crc,
unsigned char* buf,
size_t len)
237 unsigned long c = crc;
243 for (n = 0; n < len; n++) {
244 c =
crc_table[(c ^ buf[n]) & 0xff] ^ (c >> 8);
252 return update_crc(0xffffffffL, (
unsigned char*)buf, len) ^ 0xffffffffL;