-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathstring_util.cpp
42 lines (36 loc) · 1.04 KB
/
string_util.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "string_util.hpp"
#include <stdint.h>
#include <sstream>
using std::string;
using std::stringstream;
template <typename NumT>
const std::string toStr(const NumT number)
{
stringstream result;
result << number;
return result.str();
}
template <>
const std::string toStr(const uint8_t number)
{
stringstream result;
result << static_cast<uint16_t>(number);
return result.str();
}
template <>
const std::string toStr(const int8_t number)
{
stringstream result;
result << static_cast<int16_t>(number);
return result.str();
}
//template const string toStr(const uint8_t number);
//template const string toStr(const int8_t number);
template const string toStr(const uint16_t number);
template const string toStr(const int16_t number);
template const string toStr(const uint32_t number);
template const string toStr(const int32_t number);
template const string toStr(const uint64_t number);
template const string toStr(const int64_t number);
template const string toStr(const float number);
template const string toStr(const double number);