00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef MESSAGE_MACROS_HH
00025 #define MESSAGE_MACROS_HH
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 #include <iostream>
00069 #include <cassert>
00070 #include <string>
00071
00072 #include "tools-win32.hh"
00073
00074 DLL_TOOLS void DBG_MSG_SPACES(int n);
00075
00076
00077
00078
00079
00080 #ifdef DEBUG_MESSAGES
00081
00082 #define MSG(s) (DBG_MSG_SPACES(0), std::cout << s << std::endl)
00083 #define TRACE(s) (DBG_MSG_SPACES(0), std::cout << #s, std::cout.flush(), s, \
00084 std::cout << " ==> OK" << std::endl)
00085 #define BEGIN(s) (DBG_MSG_SPACES(1), std::cout << "==> " << s << std::endl)
00086 #define END(s) (DBG_MSG_SPACES(-1), std::cout << "<== " << s << std::endl)
00087
00088 #ifdef __ASSERT_FUNCTION
00089 #define ENTER (DBG_MSG_SPACES(1), std::cout << "==> " << __ASSERT_FUNCTION\
00090 << std::endl)
00091 #define EXIT (DBG_MSG_SPACES(-1), std::cout << "<== " << __ASSERT_FUNCTION\
00092 << std::endl)
00093 #else
00094 #define ENTER (DBG_MSG_SPACES(1), std::cout << "==> " << __FILE__\
00095 << ":" << __LINE__ << std::endl)
00096 #define EXIT (DBG_MSG_SPACES(-1), std::cout << "<== " << __FILE__\
00097 << ":" << __LINE__ << std::endl)
00098 #endif
00099
00100 class CDebugFunction
00101 {
00102 public:
00103 CDebugFunction(const std::string & AFunctionName, int ALineNumber = 0)
00104 : FFunctionName(AFunctionName)
00105 {
00106 if (ALineNumber > 0)
00107 BEGIN(FFunctionName << ":" << ALineNumber);
00108 else
00109 BEGIN(FFunctionName);
00110 }
00111
00112 ~CDebugFunction() { END(FFunctionName); }
00113
00114 private:
00115 std::string FFunctionName;
00116 };
00117
00118 #ifdef __ASSERT_FUNCTION
00119 #define DEBUG_FUNCTION CDebugFunction DebugFunctionObject(__ASSERT_FUNCTION)
00120 #else
00121 #define DEBUG_FUNCTION CDebugFunction DebugFunctionObject(__FILE__, __LINE__)
00122 #endif
00123
00124 #else // DEBUG_MESSAGES
00125
00126 #define MSG(s)
00127 #define TRACE(s) (s)
00128 #define BEGIN(s)
00129 #define END(s)
00130 #define ENTER
00131 #define EXIT
00132
00133 #define DEBUG_FUNCTION
00134
00135 #endif // DEBUG_MESSAGES
00136
00137
00138
00139 #define WARNING_MESSAGES
00140
00141 #ifdef WARNING_MESSAGES
00142
00143 #define WARN_Y(s) (std::cout << "\033[0;33m" << s << "\033[0m" << std::endl)
00144 #define WARN_B(s) (std::cout << "\033[0;34m" << s << "\033[0m" << std::endl)
00145 #define WARN_R(s) (std::cout << "\033[0;35m" << s << "\033[0m" << std::endl)
00146 #define WARN_BY(s) (std::cout << "\033[1;33m" << s << "\033[0m" << std::endl)
00147 #define WARN_BB(s) (std::cout << "\033[1;34m" << s << "\033[0m" << std::endl)
00148 #define WARN_BR(s) (std::cout << "\033[1;35m" << s << "\033[0m" << std::endl)
00149
00150 #ifdef __ASSERT_FUNCTION
00151 #define FUNC_WARN(s) (std::cerr << "Warning: " << __ASSERT_FUNCTION << ": "\
00152 << s << std::endl)
00153 #else
00154 #define FUNC_WARN(s) (std::cerr << "Warning: " << __FILE__ << ":" << __LINE__\
00155 << ": " << s << std::endl)
00156 #endif
00157
00158 #else // WARNING_MESSAGES
00159
00160 #define WARN_Y(s)
00161 #define WARN_B(s)
00162 #define WARN_R(s)
00163 #define WARN_BY(s)
00164 #define WARN_BB(s)
00165 #define WARN_BR(s)
00166 #define FUNC_WARN(s)
00167
00168 #endif // WARNING_MESSAGES
00169
00170
00171
00172 #endif // MESSAGE_MACROS_HH