diff options
Diffstat (limited to '')
-rw-r--r-- | src/trace.cpp | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/src/trace.cpp b/src/trace.cpp new file mode 100644 index 0000000..b328565 --- /dev/null +++ b/src/trace.cpp | |||
@@ -0,0 +1,116 @@ | |||
1 | #define BU_TRACE | ||
2 | #include "bu/trace.h" | ||
3 | |||
4 | void Bu::__tracer( const char *pf ) | ||
5 | { | ||
6 | printf("trace: %s\n", pf ); | ||
7 | } | ||
8 | |||
9 | template<> void Bu::__tracer_format<int8_t>( const int8_t &v ) | ||
10 | { | ||
11 | printf("%hhd", v ); | ||
12 | } | ||
13 | |||
14 | template<> void Bu::__tracer_format<uint8_t>( const uint8_t &v ) | ||
15 | { | ||
16 | printf("%hhu", v ); | ||
17 | } | ||
18 | |||
19 | template<> void Bu::__tracer_format<int16_t>( const int16_t &v ) | ||
20 | { | ||
21 | printf("%hd", v ); | ||
22 | } | ||
23 | |||
24 | template<> void Bu::__tracer_format<uint16_t>( const uint16_t &v ) | ||
25 | { | ||
26 | printf("%hu", v ); | ||
27 | } | ||
28 | |||
29 | template<> void Bu::__tracer_format<int32_t>( const int32_t &v ) | ||
30 | { | ||
31 | printf("%d", v ); | ||
32 | } | ||
33 | |||
34 | template<> void Bu::__tracer_format<uint32_t>( const uint32_t &v ) | ||
35 | { | ||
36 | printf("%u", v ); | ||
37 | } | ||
38 | |||
39 | template<> void Bu::__tracer_format<int64_t>( const int64_t &v ) | ||
40 | { | ||
41 | printf("%lld", v ); | ||
42 | } | ||
43 | |||
44 | template<> void Bu::__tracer_format<uint64_t>( const uint64_t &v ) | ||
45 | { | ||
46 | printf("%llu", v ); | ||
47 | } | ||
48 | |||
49 | template<> void Bu::__tracer_format<bool>( const bool &v ) | ||
50 | { | ||
51 | if( v ) | ||
52 | printf("true"); | ||
53 | else | ||
54 | printf("false"); | ||
55 | } | ||
56 | |||
57 | template<> void Bu::__tracer_format<char>( const char &v ) | ||
58 | { | ||
59 | printf("%hhd", v ); | ||
60 | } | ||
61 | |||
62 | template<> void Bu::__tracer_format<long>( const long &v ) | ||
63 | { | ||
64 | printf("%ld", v ); | ||
65 | } | ||
66 | |||
67 | template<> void Bu::__tracer_format<unsigned long>( const unsigned long &v ) | ||
68 | { | ||
69 | printf("%lu", v ); | ||
70 | } | ||
71 | |||
72 | template<> void Bu::__tracer_format<float>( const float &v ) | ||
73 | { | ||
74 | printf("%f", v ); | ||
75 | } | ||
76 | |||
77 | template<> void Bu::__tracer_format<double>( const double &v ) | ||
78 | { | ||
79 | printf("%f", v ); | ||
80 | } | ||
81 | |||
82 | template<> void Bu::__tracer_format<void *>( void * const &v ) | ||
83 | { | ||
84 | printf("0x%08X", (unsigned int)v ); | ||
85 | } | ||
86 | |||
87 | template<> void Bu::__tracer_format<char *>( char * const &v ) | ||
88 | { | ||
89 | printf("\"%s\"", v ); | ||
90 | } | ||
91 | |||
92 | template<> void Bu::__tracer_format<char **>( char ** const &v ) | ||
93 | { | ||
94 | printf("["); | ||
95 | for( int j = 0; v[j]; j++ ) | ||
96 | printf("\"%s\"", v[j] ); | ||
97 | printf("]"); | ||
98 | } | ||
99 | |||
100 | template<> void Bu::__tracer_format<void const *>( void const * const &v ) | ||
101 | { | ||
102 | printf("0x%08X", (unsigned int)v ); | ||
103 | } | ||
104 | |||
105 | template<> void Bu::__tracer_format<char const *>( char const * const &v ) | ||
106 | { | ||
107 | printf("\"%s\"", v ); | ||
108 | } | ||
109 | |||
110 | template<> void Bu::__tracer_format<char const **>( char const ** const &v ) | ||
111 | { | ||
112 | printf("["); | ||
113 | for( int j = 0; v[j]; j++ ) | ||
114 | printf("\"%s\"", v[j] ); | ||
115 | printf("]"); | ||
116 | } | ||