More work on new streams

This commit is contained in:
Alex Hultman
2018-09-27 23:44:46 +02:00
parent ee81e9b0b0
commit 2c511ec904
7 changed files with 266 additions and 249 deletions
+49
View File
@@ -0,0 +1,49 @@
#ifndef UTILITIES_H
#define UTILITIES_H
/* Various common utilities */
#include <cstdint>
namespace uWS {
namespace utils {
int u32toaHex(uint32_t value, char *dst) {
char palette[] = "0123456789abcdef";
char temp[10];
char *p = temp;
do {
*p++ = palette[value % 16];
value /= 16;
} while (value > 0);
int ret = p - temp;
do {
*dst++ = *--p;
} while (p != temp);
return ret;
}
int u32toa(uint32_t value, char *dst) {
char temp[10];
char *p = temp;
do {
*p++ = (char) (value % 10) + '0';
value /= 10;
} while (value > 0);
int ret = p - temp;
do {
*dst++ = *--p;
} while (p != temp);
return ret;
}
}
}
#endif // UTILITIES_H