6 #include <sys/socket.h> 27 line =
"Length= " +
toString(len) +
" bytes.";
35 for (
UINT16 i=0; i< 16; i++)
54 std::string s =
"0123456789ABCDEF";
93 std::string s = s1 + s2;
106 for (i=0; i < text.length(); i++)
109 if ((c >=
'A') || (c <=
'Z'))
127 std::ostringstream os;
138 INT32 inch = (
INT32)((m - ((
double)feet * 0.3048)) / 0.0254);
143 if ((inch > 0) || (feet == 0))
161 int conversions = sscanf(text.c_str(),
"%d", &value);
162 if (conversions == 1)
177 if ((c >=
'0') && (c <=
'9'))
181 else if ((c >=
'A') && (c <=
'F'))
183 value = c -
'A' + 10;
185 else if ((c >=
'a') && (c <=
'f'))
187 value = c -
'a' + 10;
207 if (useLowerCaseLetters ==
false)
210 c =
'A' + value - 10;
215 c =
'a' + value - 10;
229 UINT8 value = (byte >> 4);
254 const double twoPi = (2.0 *
PI);
274 sprintf(c,
"%i", value);
275 return (std::string(c));
284 sprintf(c,
"%i", value);
285 return (std::string(c));
288 #if INTPTR_MAX != INT32_MAX 292 sprintf(c,
"%zu", value);
293 return (std::string(c));
308 std::string::size_type digits_before_decimal_point,
309 std::string::size_type digits_after_decimal_point)
312 std::string text =
doubleToString(val, digits_after_decimal_point);
315 const std::string::size_type dotPosition = text.find_first_of(
'.', 0);
316 if (dotPosition != std::string::npos)
319 if (dotPosition < digits_before_decimal_point)
322 std::string::size_type numExtraSpaces = digits_before_decimal_point - dotPosition;
323 text = std::string(numExtraSpaces,
' ') + text;
330 if (text.length() < (digits_before_decimal_point + digits_after_decimal_point + 1))
333 std::string::size_type numExtraSpaces =
334 (digits_before_decimal_point + digits_after_decimal_point + 1) - text.length();
335 text += std::string(numExtraSpaces,
' ');
345 int digits_after_decimal_point)
348 std::stringstream sstr;
349 sstr << std::fixed << std::setprecision(digits_after_decimal_point) << val;
354 std::string
toString(
double val,
int digits_after_decimal_point)
370 if (ipAdrStr.length() < 3)
376 UINT32 adrVal = INADDR_NONE;
380 size_t pos = ipAdrStr.find_first_of(
':');
381 if ((pos > 0) && (pos < (ipAdrStr.length() - 1)))
383 addrStr = ipAdrStr.substr(0, pos);
384 portStr = ipAdrStr.substr(pos+1);
392 adrVal = (
UINT32)inet_addr(addrStr.c_str());
396 if (portStr.length() > 0)
442 (((
UINT32)buffer[1]) << 16) +
443 (((
UINT32)buffer[2]) << 8 ) +
466 UINT8 value = buffer[0];
488 (((
UINT32)buffer[1]) << 16) +
489 (((
UINT32)buffer[2]) << 8 ) +
502 for (
UINT16 i = 0; i<length; i++)
556 buffer[0] = ((value >> 24) & 0xFF);
557 buffer[1] = ((value >> 16) & 0xFF);
558 buffer[2] = ((value >> 8 ) & 0xFF);
559 buffer[3] = ((value ) & 0xFF);
578 buffer[0] = ((value >> 8 ) & 0xFF);
579 buffer[1] = ((value ) & 0xFF);
606 strncpy((
char*)buffer, text.c_str(), text.length());
607 buffer += text.length();
Internal: Structure for reading/writing a float as an UINT32.
#define printInfoMessage(a, b)