diff options
Diffstat (limited to 'src/stable/trace.cpp')
-rw-r--r-- | src/stable/trace.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/stable/trace.cpp b/src/stable/trace.cpp new file mode 100644 index 0000000..03181e9 --- /dev/null +++ b/src/stable/trace.cpp | |||
@@ -0,0 +1,67 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2007-2011 Xagasoft, All rights reserved. | ||
3 | * | ||
4 | * This file is part of the libbu++ library and is released under the | ||
5 | * terms of the license contained in the file LICENSE. | ||
6 | */ | ||
7 | |||
8 | #include "bu/trace.h" | ||
9 | |||
10 | void Bu::__tracer( const char *pf ) | ||
11 | { | ||
12 | printf("trace: %s\n", pf ); | ||
13 | } | ||
14 | |||
15 | template<> void Bu::__tracer_format<float>( const float &v ) | ||
16 | { | ||
17 | printf("%f", v ); | ||
18 | } | ||
19 | |||
20 | template<> void Bu::__tracer_format<double>( const double &v ) | ||
21 | { | ||
22 | printf("%f", v ); | ||
23 | } | ||
24 | |||
25 | template<> void Bu::__tracer_format<void *>( void * const &v ) | ||
26 | { | ||
27 | printf("0x%08X", (ptrdiff_t)v ); | ||
28 | } | ||
29 | |||
30 | template<> void Bu::__tracer_format<char *>( char * const &v ) | ||
31 | { | ||
32 | printf("\"%s\"", v ); | ||
33 | } | ||
34 | |||
35 | template<> void Bu::__tracer_format<char **>( char ** const &v ) | ||
36 | { | ||
37 | printf("["); | ||
38 | for( int j = 0; v[j]; j++ ) | ||
39 | { | ||
40 | if( j > 0 ) | ||
41 | printf(", "); | ||
42 | printf("\"%s\"", v[j] ); | ||
43 | } | ||
44 | printf("]"); | ||
45 | } | ||
46 | |||
47 | template<> void Bu::__tracer_format<void const *>( void const * const &v ) | ||
48 | { | ||
49 | printf("0x%08X", (ptrdiff_t)v ); | ||
50 | } | ||
51 | |||
52 | template<> void Bu::__tracer_format<char const *>( char const * const &v ) | ||
53 | { | ||
54 | printf("\"%s\"", v ); | ||
55 | } | ||
56 | |||
57 | template<> void Bu::__tracer_format<char const **>( char const ** const &v ) | ||
58 | { | ||
59 | printf("["); | ||
60 | for( int j = 0; v[j]; j++ ) | ||
61 | { | ||
62 | if( j > 0 ) | ||
63 | printf(", "); | ||
64 | printf("\"%s\"", v[j] ); | ||
65 | } | ||
66 | printf("]"); | ||
67 | } | ||