Rev 1596 | Rev 1602 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1596 | Rev 1598 | ||
|---|---|---|---|
| Line 22... | Line 22... | ||
| 22 | #define TYPE_COMMON_H |
22 | #define TYPE_COMMON_H |
| 23 | 23 | ||
| 24 | #include <iostream> |
24 | #include <iostream> |
| 25 | #include <string> |
25 | #include <string> |
| 26 | #include <vector> |
26 | #include <vector> |
| - | 27 | ||
| - | 28 | #include <stdio.h> |
|
| 27 | 29 | ||
| 28 | #include <boost/shared_ptr.hpp> |
30 | #include <boost/shared_ptr.hpp> |
| 29 | 31 | ||
| 30 | namespace atom { |
32 | namespace atom { |
| 31 | namespace type { |
33 | namespace type { |
| Line 35... | Line 37... | ||
| 35 | 37 | ||
| 36 | template <typename T> |
38 | template <typename T> |
| 37 | struct HexTo |
39 | struct HexTo |
| 38 | { |
40 | { |
| 39 | T value; |
41 | T value; |
| 40 | 42 | ||
| 41 | operator T() const |
43 | operator T() const |
| 42 | { |
44 | { |
| 43 | return value; |
45 | return value; |
| 44 | } |
46 | } |
| 45 | 47 | ||
| Line 48... | Line 50... | ||
| 48 | in >> std::hex >> out.value; |
50 | in >> std::hex >> out.value; |
| 49 | return in; |
51 | return in; |
| 50 | } |
52 | } |
| 51 | }; |
53 | }; |
| 52 | 54 | ||
| - | 55 | inline std::string ToHex(unsigned int value) |
|
| - | 56 | { |
|
| - | 57 | char hex_string[11]; |
|
| - | 58 | ||
| - | 59 | snprintf(hex_string, sizeof(hex_string), "0x%08X", value); |
|
| - | 60 | ||
| - | 61 | return std::string(hex_string); |
|
| - | 62 | ||
| - | 63 | } |
|
| 53 | 64 | ||
| 54 | }; // namespace type |
65 | }; // namespace type |
| 55 | }; // namespace atom |
66 | }; // namespace atom |
| 56 | 67 | ||
| 57 | #endif // TYPE_COMMON_H |
68 | #endif // TYPE_COMMON_H |