blocxx
FuncNamePrinter.hpp
Go to the documentation of this file.
1/*******************************************************************************
2* Copyright (C) 2005, Vintela, Inc. All rights reserved.
3* Copyright (C) 2006, Novell, Inc. All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7*
8* * Redistributions of source code must retain the above copyright notice,
9* this list of conditions and the following disclaimer.
10* * Redistributions in binary form must reproduce the above copyright
11* notice, this list of conditions and the following disclaimer in the
12* documentation and/or other materials provided with the distribution.
13* * Neither the name of
14* Vintela, Inc.,
15* nor Novell, Inc.,
16* nor the names of its contributors or employees may be used to
17* endorse or promote products derived from this software without
18* specific prior written permission.
19*
20* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30* POSSIBILITY OF SUCH DAMAGE.
31*******************************************************************************/
32
33
38
39#ifndef BLOCXX_FUNC_NAME_PRINTER_HPP
40#define BLOCXX_FUNC_NAME_PRINTER_HPP
41#include "blocxx/BLOCXX_config.h"
42#include "blocxx/Format.hpp"
43#include <stdio.h>
44#include <unistd.h>
45
46// The classes and functions defined in this file are not meant for general
47// use, they are internal implementation details. They may change at any time.
48
49// For printing function names during debug
50#ifdef BLOCXX_PRINT_FUNC_DEBUG
51#define PRINT_FUNC_NAME BLOCXX_FuncNamePrinter fnp##__LINE__ (__PRETTY_FUNCTION__)
52
53#define PRINT_FUNC_NAME_ARGS1(a) BLOCXX_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a)
54#define PRINT_FUNC_NAME_ARGS2(a, b) BLOCXX_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b)
55#define PRINT_FUNC_NAME_ARGS3(a, b, c) BLOCXX_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c)
56#define PRINT_FUNC_NAME_ARGS4(a, b, c, d) BLOCXX_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d)
57#define PRINT_FUNC_NAME_ARGS5(a, b, c, d, e) BLOCXX_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e)
58#define PRINT_FUNC_NAME_ARGS6(a, b, c, d, e, f) BLOCXX_FuncNamePrinter fnp##__LINE__ ( __PRETTY_FUNCTION__ , a, b, c, d, e, f)
59#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)
60#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)
61#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)
62#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)
63#else
64#define PRINT_FUNC_NAME_ARGS1(a)
65#define PRINT_FUNC_NAME_ARGS2(a, b)
66#define PRINT_FUNC_NAME_ARGS3(a, b, c)
67#define PRINT_FUNC_NAME_ARGS4(a, b, c, d)
68#define PRINT_FUNC_NAME_ARGS5(a, b, c, d, e)
69#define PRINT_FUNC_NAME_ARGS6(a, b, c, d, e, f)
70#define PRINT_FUNC_NAME_ARGS7(a, b, c, d, e, f, g)
71#define PRINT_FUNC_NAME_ARGS8(a, b, c, d, e, f, g, h)
72#define PRINT_FUNC_NAME_ARGS9(a, b, c, d, e, f, g, h, i)
73#define PRINT_FUNC_NAME_ARGS10(a, b, c, d, e, f, g, h, i, j)
74#define PRINT_FUNC_NAME
75#endif /* #ifdef BLOCXX_PRINT_FUNC_DEBUG */
76
77namespace BLOCXX_NAMESPACE
78{
79
81{
82private:
83 const char* m_funcName;
84public:
85
86 FuncNamePrinter(const char* funcName) : m_funcName(funcName)
87 {
88 fprintf(stderr, "%d Entering: %s\n", getpid(), funcName);
89 }
90 template<typename A>
91 FuncNamePrinter(const char* funcName, const A& a) : m_funcName(funcName)
92 {
93 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
94 Format("(%1)", a).c_str());
95 }
96 template<typename A, typename B>
97 FuncNamePrinter(const char* funcName, const A& a, const B& b) : m_funcName(funcName)
98 {
99 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
100 Format("(%1, %2)", a, b).c_str());
101 }
102 template<typename A, typename B, typename C>
103 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c) : m_funcName(funcName)
104 {
105 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
106 Format("(%1, %2, %3)", a, b, c).c_str());
107 }
108 template<typename A, typename B, typename C, typename D>
109 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d) : m_funcName(funcName)
110 {
111 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
112 Format("(%1, %2, %3, %4)", a, b, c, d).c_str());
113 }
114 template<typename A, typename B, typename C, typename D, typename E>
115 FuncNamePrinter(const char* funcName, const A& a, const B& b, const C& c, const D& d, const E& e) : m_funcName(funcName)
116 {
117 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
118 Format("(%1, %2, %3, %4, %5)", a, b, c, d, e).c_str());
119 }
120 template<typename A, typename B, typename C, typename D, typename E, typename F>
121 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)
122 {
123 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
124 Format("(%1, %2, %3, %4, %5, %6)", a, b, c, d, e, f).c_str());
125 }
126 template<typename A, typename B, typename C, typename D, typename E, typename F,
127 typename G>
128 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)
129 {
130 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
131 Format("(%1, %2, %3, %4, %5, %6, %7)", a, b, c, d, e, f, g).c_str());
132 }
133 template<typename A, typename B, typename C, typename D, typename E, typename F,
134 typename G, typename H>
135 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)
136 {
137 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
138 Format("(%1, %2, %3, %4, %5, %6, %7, %8)", a, b, c, d, e, f, g, h).c_str());
139 }
140 template<typename A, typename B, typename C, typename D, typename E, typename F,
141 typename G, typename H, typename I>
142 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)
143 {
144 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
145 Format("(%1, %2, %3, %4, %5, %6, %7, %8, %9)", a, b, c, d, e, f, g, h, i).c_str());
146 }
147 template<typename A, typename B, typename C, typename D, typename E, typename F,
148 typename G, typename H, typename I, typename J>
149 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)
150 {
151 fprintf(stderr, "%d Entering: %s\n\t%s\n", getpid(), funcName,
152 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());
153 }
155 { fprintf(stderr, "%d Leaving: %s\n", getpid(), m_funcName); }
156}; // class FuncNamePrinter
157
158} // end namespace BLOCXX_NAMESPACE
159
160#endif //#define BLOCXX_FUNC_NAME_PRINTER_HPP
#define F(x, y, z)
Definition MD5.cpp:209
#define I(x, y, z)
Definition MD5.cpp:212
#define G(x, y, z)
Definition MD5.cpp:210
#define H(x, y, z)
Definition MD5.cpp:211
FuncNamePrinter(const char *funcName, const A &a, const B &b, const C &c, const D &d)
FuncNamePrinter(const char *funcName, const A &a, const B &b, const C &c, const D &d, const E &e)
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)
FuncNamePrinter(const char *funcName, const A &a, const B &b, const C &c, const D &d, const E &e, const F &f)
FuncNamePrinter(const char *funcName, const A &a)
FuncNamePrinter(const char *funcName, const A &a, const B &b, const C &c)
FuncNamePrinter(const char *funcName)
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)
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)
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)
FuncNamePrinter(const char *funcName, const A &a, const B &b)
Taken from RFC 1321.