00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00025 #ifndef DEBUG_H
00026 #define DEBUG_H
00027
00028
00029 #include <iostream>
00030
00031 #include "exceptions.h"
00032
00033
00035
00036 #define DBG(_x_) {}
00037
00038
00040 #define PRINT_SOURCE_POSITION std::cerr << "In file " << __FILE__ << ", line " << __LINE__ << ": "
00041
00042
00050 #define CHECK_POINTER(_x_) \
00051 if ( !(_x_) ) \
00052 { \
00053 PRINT_SOURCE_POSITION; \
00054 std::cerr << "Out of memory" << std::endl; \
00055 throw ExaltNullPointerException(); \
00056 }
00057
00058
00068 #define DELETE(_x_) \
00069 { \
00070 CHECK_POINTER( (_x_) ); \
00071 delete (_x_); \
00072 (_x_) = 0; \
00073 }
00074
00075
00085 #define DELETE_ARRAY(_x_) \
00086 { \
00087 CHECK_POINTER( (_x_) ); \
00088 delete[] (_x_); \
00089 (_x_) = 0; \
00090 }
00091
00092
00093
00103 #define NEW(_p_, _type_) \
00104 { \
00105 (_p_) = new _type_; \
00106 CHECK_POINTER( (_p_) ); \
00107 }
00108
00109
00110 #endif //DEBUG_H
00111
00112
00113