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
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _ERRORMACROS_H
00034 #define _ERRORMACROS_H
00035
00036 #include <iostream>
00037
00040 #ifdef NVERBOSE // Not verbose mode
00041 # ifndef REPORT
00042 # define REPORT
00043 # endif
00044 # ifndef MESSAGE
00045 # define MESSAGE(x)
00046 # endif
00047 # ifndef MESSAGE_IF
00048 # define MESSAGE_IF(cond, m)
00049 # endif
00050 #else // Verbose mode
00051 # ifndef REPORT
00052 # define REPORT std::cerr << "\nIn file " << __FILE__ << ", line " << __LINE__ << std::endl
00053 # endif
00054 # ifndef MESSAGE
00055 # define MESSAGE(x) std::cerr << "\nIn file " << __FILE__ << ", line " << __LINE__ << ": " << x << std::endl
00056 # endif
00057 # ifndef MESSAGE_IF
00058 # define MESSAGE_IF(cond, m) do {if(cond) MESSAGE(m);} while(0)
00059 # endif
00060 #endif
00061
00062 #ifndef GO_NO_CHECKS
00063 #define GO_NO_CHECKS
00064 #endif
00065
00067 #ifndef THROW
00068 # define THROW(x) MESSAGE(x), throw std::exception()
00069 #endif
00070
00071 #define ALWAYS_ERROR_IF(condition, message) do {if(condition){ THROW(message);}} while(0)
00072
00076 #ifdef NDEBUG // Not in debug mode
00077 # ifndef ASSERT
00078 # define ASSERT(x)
00079 # endif
00080 # ifndef ASSERT2
00081 # define ASSERT2(cond, x)
00082 # endif
00083 # ifndef DEBUG_ERROR_IF
00084 # define DEBUG_ERROR_IF(cond, x)
00085 # endif
00086 #else // Debug mode
00087 # ifndef ASSERT
00088 # define ASSERT(cond) if (!(cond)) THROW("Assertion \'" #cond "\' failed.")
00089 # endif
00090 # ifndef ASSERT2
00091 # define ASSERT2(cond, x) do { if (!(cond)) THROW(x);} while(0)
00092 # endif
00093 # ifndef DEBUG_ERROR_IF
00094
00095 # define DEBUG_ERROR_IF(cond, x) do { if (cond) THROW(x); } while(0)
00096 # endif
00097 #endif
00098
00099
00100 #endif // _ERRORMACROS_H
00101
00102
00103
00104
00105