00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00039 #ifndef BLOCXX_FUNC_NAME_PRINTER_HPP
00040 #define BLOCXX_FUNC_NAME_PRINTER_HPP
00041 #include "blocxx/BLOCXX_config.h"
00042 #include "blocxx/Format.hpp"
00043 #include <stdio.h>
00044 #include <unistd.h>
00045
00046
00047
00048
00049
00050 #ifdef BLOCXX_PRINT_FUNC_DEBUG
00051 #define PRINT_FUNC_NAME BLOCXX_FuncNamePrinter fnp##__LINE__ (__PRETTY_FUNCTION__)
00052
00053 #define PRINT_FUNC_NAME_ARGS1(a) BLOCXX_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a)
00054 #define PRINT_FUNC_NAME_ARGS2(a, b) BLOCXX_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b)
00055 #define PRINT_FUNC_NAME_ARGS3(a, b, c) BLOCXX_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c)
00056 #define PRINT_FUNC_NAME_ARGS4(a, b, c, d) BLOCXX_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d)
00057 #define PRINT_FUNC_NAME_ARGS5(a, b, c, d, e) BLOCXX_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e)
00058 #define PRINT_FUNC_NAME_ARGS6(a, b, c, d, e, f) BLOCXX_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e, f)
00059 #define PRINT_FUNC_NAME_ARGS7(a, b, c, d, e, f, g) BLOCXX_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e, f, g)
00060 #define PRINT_FUNC_NAME_ARGS8(a, b, c, d, e, f, g, h) BLOCXX_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e, f, g, h)
00061 #define PRINT_FUNC_NAME_ARGS9(a, b, c, d, e, f, g, h, i) BLOCXX_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e, f, g, h, i)
00062 #define PRINT_FUNC_NAME_ARGS10(a, b, c, d, e, f, g, h, i, j) BLOCXX_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e, f, g, h, i, j)
00063 #else
00064 #define PRINT_FUNC_NAME_ARGS1(a)
00065 #define PRINT_FUNC_NAME_ARGS2(a, b)
00066 #define PRINT_FUNC_NAME_ARGS3(a, b, c)
00067 #define PRINT_FUNC_NAME_ARGS4(a, b, c, d)
00068 #define PRINT_FUNC_NAME_ARGS5(a, b, c, d, e)
00069 #define PRINT_FUNC_NAME_ARGS6(a, b, c, d, e, f)
00070 #define PRINT_FUNC_NAME_ARGS7(a, b, c, d, e, f, g)
00071 #define PRINT_FUNC_NAME_ARGS8(a, b, c, d, e, f, g, h)
00072 #define PRINT_FUNC_NAME_ARGS9(a, b, c, d, e, f, g, h, i)
00073 #define PRINT_FUNC_NAME_ARGS10(a, b, c, d, e, f, g, h, i, j)
00074 #define PRINT_FUNC_NAME
00075 #endif
00076
00077 namespace BLOCXX_NAMESPACE
00078 {
00079
00080 class FuncNamePrinter
00081 {
00082 private:
00083 const char* m_funcName;
00084 public:
00085
00086 FuncNamePrinter(const char* funcName) : m_funcName(funcName)
00087 {
00088 fprintf(stderr, "%d Entering: %s\n", getpid(), funcName);
00089 }
00090 template<typename A>
00091 FuncNamePrinter(const char* funcName, const A& a) : m_funcName(funcName)
00092 {
00093 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00094 Format("(%1)", a).c_str());
00095 }
00096 template<typename A, typename B>
00097 FuncNamePrinter(const char* funcName, const A& a, const B& b) : m_funcName(funcName)
00098 {
00099 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00100 Format("(%1, %2)", a, b).c_str());
00101 }
00102 template<typename A, typename B, typename C>
00103 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c) : m_funcName(funcName)
00104 {
00105 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00106 Format("(%1, %2, %3)", a, b, c).c_str());
00107 }
00108 template<typename A, typename B, typename C, typename D>
00109 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d) : m_funcName(funcName)
00110 {
00111 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00112 Format("(%1, %2, %3, %4)", a, b, c, d).c_str());
00113 }
00114 template<typename A, typename B, typename C, typename D, typename E>
00115 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e) : m_funcName(funcName)
00116 {
00117 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00118 Format("(%1, %2, %3, %4, %5)", a, b, c, d, e).c_str());
00119 }
00120 template<typename A, typename B, typename C, typename D, typename E, typename F>
00121 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e, const F& f) : m_funcName(funcName)
00122 {
00123 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00124 Format("(%1, %2, %3, %4, %5, %6)", a, b, c, d, e, f).c_str());
00125 }
00126 template<typename A, typename B, typename C, typename D, typename E, typename F,
00127 typename G>
00128 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g) : m_funcName(funcName)
00129 {
00130 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00131 Format("(%1, %2, %3, %4, %5, %6, %7)", a, b, c, d, e, f, g).c_str());
00132 }
00133 template<typename A, typename B, typename C, typename D, typename E, typename F,
00134 typename G, typename H>
00135 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g, const H& h) : m_funcName(funcName)
00136 {
00137 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00138 Format("(%1, %2, %3, %4, %5, %6, %7, %8)", a, b, c, d, e, f, g, h).c_str());
00139 }
00140 template<typename A, typename B, typename C, typename D, typename E, typename F,
00141 typename G, typename H, typename I>
00142 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g, const H& h, const I& i) : m_funcName(funcName)
00143 {
00144 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00145 Format("(%1, %2, %3, %4, %5, %6, %7, %8, %9)", a, b, c, d, e, f, g, h, i).c_str());
00146 }
00147 template<typename A, typename B, typename C, typename D, typename E, typename F,
00148 typename G, typename H, typename I, typename J>
00149 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e, const F& f, const G& g, const H& h, const I& i, const J& j) : m_funcName(funcName)
00150 {
00151 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
00152 Format("(%1, %2, %3, %4, %5, %6, %7, %8, %9)", a, b, c, d, e, f, g, h, Format("%1, %2", i, j)).c_str());
00153 }
00154 ~FuncNamePrinter()
00155 { fprintf(stderr, "%d Leaving: %s\n", getpid(), m_funcName); }
00156 };
00157
00158 }
00159
00160 #endif //#define BLOCXX_FUNC_NAME_PRINTER_HPP