00001
00027
00028
00029
00030
00031
00032
00033 #ifndef __assert__
00034 # define __assert__
00035
00036
00037 #include <iostream>
00038 #include <cstdlib>
00039 #include <string>
00040 #include "Tracer.hpp"
00041
00042 using namespace std;
00043
00044
00045
00046
00047
00048 class MyException {
00049 public:
00050 MyException (const char* file, int line);
00051 MyException (const char* msg);
00052 MyException (const string& msg);
00053 virtual ~MyException () {}
00054
00055 virtual void cry (ostream& str);
00056
00057 private:
00058 string _file;
00059 int _line;
00060 };
00061
00062
00063
00064
00065
00066 class MemoryException {
00067 public:
00068 MemoryException (const char* file, int line);
00069 void cry (ostream& str);
00070
00071 private:
00072 const char* _file;
00073 int _line;
00074 };
00075
00076
00077 #define NO_MEMORY \
00078 throw MemoryException (__FILE__,__LINE__);
00079
00080
00081
00082
00083 #if DEBUG_PREPRO
00084
00085 #define EXCEPTION(Class) \
00086 class Class : \
00087 public MyException \
00088 { \
00089 public: \
00090 Class (const char* file, int line) \
00091 : MyException (file, line) {} \
00092 }
00093
00094
00095 #define ASS(Cond) \
00096 if (! (Cond)) { \
00097 MyTracer::printStack (cerr); \
00098 MyTracer::printStack (cout); \
00099 throw MyException (__FILE__,__LINE__); \
00100 }
00101
00102
00103 #define IF( Switch, Statement ) \
00104 if ( (Switch) ) { \
00105 Statement; \
00106 } \
00107 else {}
00108
00109 #else // ! DEBUG_PREPRO
00110 #define ASS(Cond)
00111 #endif
00112
00113
00114 #endif // __assert__
00115
00116