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
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
00069
00070
00071
00072
00073
00074
00075 #ifndef Foundation_Bugcheck_INCLUDED
00076 #define Foundation_Bugcheck_INCLUDED
00077
00078
00079 #include "VMS/Foundation.h"
00080 #include <string>
00081
00082
00083 namespace Poco {
00084
00085
00086 class Foundation_API Bugcheck
00094 {
00095 public:
00096 static void assertion(const char* cond, const char* file, int line);
00099
00100 static void nullPointer(const char* ptr, const char* file, int line);
00103
00104 static void bugcheck(const char* file, int line);
00107
00108 static void bugcheck(const char* msg, const char* file, int line);
00111
00112 static void debugger(const char* file, int line);
00115
00116 static void debugger(const char* msg, const char* file, int line);
00119
00120 protected:
00121 static std::string what(const char* msg, const char* file, int line);
00122 };
00123
00124
00125 }
00126
00127
00128
00129
00130
00131 #if defined(_DEBUG)
00132 #define poco_assert_dbg(cond) \
00133 if (!(cond)) Poco::Bugcheck::assertion(#cond, __FILE__, __LINE__); else (void) 0
00134 #else
00135 #define poco_assert_dbg(cond)
00136 #endif
00137
00138
00139 #define poco_assert(cond) \
00140 if (!(cond)) Poco::Bugcheck::assertion(#cond, __FILE__, __LINE__); else (void) 0
00141
00142
00143 #define poco_check_ptr(ptr) \
00144 if (!(ptr)) Poco::Bugcheck::nullPointer(#ptr, __FILE__, __LINE__); else (void) 0
00145
00146
00147 #define poco_bugcheck() \
00148 Poco::Bugcheck::bugcheck(__FILE__, __LINE__)
00149
00150
00151 #define poco_bugcheck_msg(msg) \
00152 Poco::Bugcheck::bugcheck(msg, __FILE__, __LINE__)
00153
00154
00155 #define poco_debugger() \
00156 Poco::Bugcheck::debugger(__FILE__, __LINE__)
00157
00158
00159 #define poco_debugger_msg(msg) \
00160 Poco::Bugcheck::debugger(msg, __FILE__, __LINE__)
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170 template <bool x>
00171 struct POCO_STATIC_ASSERTION_FAILURE;
00172
00173
00174 template <>
00175 struct POCO_STATIC_ASSERTION_FAILURE<true>
00176 {
00177 enum
00178 {
00179 value = 1
00180 };
00181 };
00182
00183
00184 template <int x>
00185 struct poco_static_assert_test
00186 {
00187 };
00188
00189
00190 #if defined(__GNUC__) && (__GNUC__ == 3) && ((__GNUC_MINOR__ == 3) || (__GNUC_MINOR__ == 4))
00191 #define poco_static_assert(B) \
00192 typedef char POCO_JOIN(poco_static_assert_typedef_, __LINE__) \
00193 [POCO_STATIC_ASSERTION_FAILURE<(bool) (B)>::value]
00194 #else
00195 #define poco_static_assert(B) \
00196 typedef poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) (B)>)> \
00197 POCO_JOIN(poco_static_assert_typedef_, __LINE__)
00198 #endif
00199
00200
00201 #endif // Foundation_Bugcheck_INCLUDED