aboutsummaryrefslogtreecommitdiff
path: root/src/trace.cpp
blob: dab53d692477ed3a046dfb77d09c9db44402b290 (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#define BU_TRACE
#include "bu/trace.h"

void Bu::__tracer( const char *pf )
{
	printf("trace: %s\n", pf );
}

template<> void Bu::__tracer_format<int8_t>( const int8_t &v )
{
	printf("%hhd", v );
}

template<> void Bu::__tracer_format<uint8_t>( const uint8_t &v )
{
	printf("%hhu", v );
}

template<> void Bu::__tracer_format<int16_t>( const int16_t &v )
{
	printf("%hd", v );
}

template<> void Bu::__tracer_format<uint16_t>( const uint16_t &v )
{
	printf("%hu", v );
}

template<> void Bu::__tracer_format<int32_t>( const int32_t &v )
{
	printf("%d", v );
}

template<> void Bu::__tracer_format<uint32_t>( const uint32_t &v )
{
	printf("%u", v );
}

template<> void Bu::__tracer_format<int64_t>( const int64_t &v )
{
	printf("%lld", v );
}

template<> void Bu::__tracer_format<uint64_t>( const uint64_t &v )
{
	printf("%llu", v );
}

template<> void Bu::__tracer_format<bool>( const bool &v )
{
	if( v )
		printf("true");
	else
		printf("false");
}

template<> void Bu::__tracer_format<char>( const char &v )
{
	printf("%hhd", v );
}
/*
template<> void Bu::__tracer_format<long>( const long &v )
{
	printf("%ld", v );
}

template<> void Bu::__tracer_format<unsigned long>( const unsigned long &v )
{
	printf("%lu", v );
}*/

template<> void Bu::__tracer_format<float>( const float &v )
{
	printf("%f", v );
}

template<> void Bu::__tracer_format<double>( const double &v )
{
	printf("%f", v );
}

template<> void Bu::__tracer_format<void *>( void * const &v )
{
	printf("0x%08X", (ptrdiff_t)v );
}

template<> void Bu::__tracer_format<char *>( char * const &v )
{
	printf("\"%s\"", v );
}

template<> void Bu::__tracer_format<char **>( char ** const &v )
{
	printf("[");
	for( int j = 0; v[j]; j++ )
		printf("\"%s\"", v[j] );
	printf("]");
}

template<> void Bu::__tracer_format<void const *>( void const * const &v )
{
	printf("0x%08X", (ptrdiff_t)v );
}

template<> void Bu::__tracer_format<char const *>( char const * const &v )
{
	printf("\"%s\"", v );
}

template<> void Bu::__tracer_format<char const **>( char const ** const &v )
{
	printf("[");
	for( int j = 0; v[j]; j++ )
		printf("\"%s\"", v[j] );
	printf("]");
}