File tree Expand file tree Collapse file tree 3 files changed +54
-1
lines changed
Expand file tree Collapse file tree 3 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,9 @@ set ( SRC_FILES
2727 renderer.cpp
2828 renderer.hpp
2929 statistics.cpp
30- statistics.hpp )
30+ statistics.hpp
31+ string_util.cpp
32+ string_util.hpp )
3133
3234add_executable ( morebin ${SRC_FILES} )
3335target_link_libraries ( morebin ${Boost_LIBRARIES} )
Original file line number Diff line number Diff line change 1+ #include " string_util.hpp"
2+
3+ #include < stdint.h>
4+ #include < sstream>
5+
6+ using std::string;
7+ using std::stringstream;
8+
9+ template <typename NumT>
10+ const std::string toStr (const NumT number)
11+ {
12+ stringstream result;
13+ result << number;
14+ return result.str ();
15+ }
16+
17+ template <>
18+ const std::string toStr (const uint8_t number)
19+ {
20+ stringstream result;
21+ result << static_cast <uint16_t >(number);
22+ return result.str ();
23+ }
24+
25+ template <>
26+ const std::string toStr (const int8_t number)
27+ {
28+ stringstream result;
29+ result << static_cast <int16_t >(number);
30+ return result.str ();
31+ }
32+
33+ // template const string toStr(const uint8_t number);
34+ // template const string toStr(const int8_t number);
35+ template const string toStr (const uint16_t number);
36+ template const string toStr (const int16_t number);
37+ template const string toStr (const uint32_t number);
38+ template const string toStr (const int32_t number);
39+ template const string toStr (const uint64_t number);
40+ template const string toStr (const int64_t number);
41+ template const string toStr (const float number);
42+ template const string toStr (const double number);
Original file line number Diff line number Diff line change 1+ #ifndef _STRING_UTIL_HPP
2+ #define _STRING_UTIL_HPP 1
3+
4+ #include < string>
5+
6+ template <typename NumT>
7+ const std::string toStr (const NumT number);
8+
9+ #endif
You can’t perform that action at this time.
0 commit comments