22 #ifndef UTILS_CHECKUTILS_H
23 #define UTILS_CHECKUTILS_H
30 #define reportFalseReal(val) \
31 (val ? true : (reportAssertStack(__FILE__, __LINE__, __func__, \
32 "Detected false value", #val), false))
34 #define reportTrueReal(val) \
35 (val ? (reportAssertStack(__FILE__, __LINE__, __func__, \
36 "Detected false value", #val), true) : false)
38 #define reportAlwaysReal(...) \
40 logger->log("Assert:"); \
43 reportLogStack(__FILE__, __LINE__, __func__); \
46 #define returnFalseVReal(val) \
49 reportAssertStack(__FILE__, __LINE__, __func__, \
50 "Detected false value", #val); \
54 #define returnTrueVReal(val) \
57 reportAssertStack(__FILE__, __LINE__, __func__, \
58 "Detected true value", #val); \
62 #define returnFalseReal(ret, val) \
65 reportAssertStack(__FILE__, __LINE__, __func__, \
66 "Detected false value", #val); \
70 #define returnTrueReal(ret, val) \
73 reportAssertStack(__FILE__, __LINE__, __func__, \
74 "Detected true value", #val); \
78 #define returnNullptrVReal(val) \
79 if ((val) == nullptr) \
81 reportAssertStack(__FILE__, __LINE__, __func__, \
82 "Detected null value", #val); \
86 #define returnNullptrReal(ret, val) \
87 if ((val) == nullptr) \
89 reportAssertStack(__FILE__, __LINE__, __func__, \
90 "Detected null value", #val); \
94 #define failFalse(val) \
95 (val ? true : (reportAssertStack(__FILE__, __LINE__, __func__, \
96 "Detected false value", #val), \
97 throw new std::exception(), false))
99 #define failTrue(val) \
100 (val ? (reportAssertStack(__FILE__, __LINE__, __func__, \
101 "Detected false value", #val), \
102 throw new std::exception(), true) : false)
104 #define returnFailFalseV(val) \
107 reportAssertStack(__FILE__, __LINE__, __func__, \
108 "Detected false value", #val); \
109 throw new std::exception(); \
112 #define returnFailTrueV(val) \
115 reportAssertStack(__FILE__, __LINE__, __func__, \
116 "Detected true value", #val); \
117 throw new std::exception(); \
120 #define returnFailFalse(ret, val) \
123 reportAssertStack(__FILE__, __LINE__, __func__, \
124 "Detected false value", #val); \
125 throw new std::exception(); \
128 #define returnFailTrue(ret, val) \
131 reportAssertStack(__FILE__, __LINE__, __func__, \
132 "Detected true value", #val); \
133 throw new std::exception(); \
136 #define returnFailNullptrV(val) \
137 if ((val) == nullptr) \
139 reportAssertStack(__FILE__, __LINE__, __func__, \
140 "Detected null value", #val); \
141 throw new std::exception(); \
144 #define returnFailNullptr(ret, val) \
145 if ((val) == nullptr) \
147 reportAssertStack(__FILE__, __LINE__, __func__, \
148 "Detected null value", #val); \
149 throw new std::exception(); \
152 #define failAlways(...) \
154 logger->log("Assert:"); \
157 reportLogStack(__FILE__, __LINE__, __func__); \
158 throw new std::exception(); \
161 void reportAssertStack(
const char *
const file,
162 const unsigned int line,
163 const char *
const func,
164 const char *
const name,
165 const char *
const text);
167 void reportLogStack(
const char *
const file,
168 const unsigned int line,
169 const char *
const func);
175 #define reportFalseReal(val) (val)
176 #define reportTrueReal(val) (val)
178 #define reportAlwaysReal(...) \
180 logger->log("Error:"); \
185 #define returnFalseVReal(val) \
189 #define returnTrueVReal(val) \
193 #define returnFalseReal(ret, val) \
197 #define returnTrueReal(ret, val) \
201 #define returnNullptrVReal(val) \
202 if ((val) == nullptr) \
205 #define returnNullptrReal(ret, val) \
206 if ((val) == nullptr) \
209 #define failFalse(val) (val)
210 #define failTrue(val) (val)
212 #define returnFailFalseV(val) \
216 #define returnFailTrueV(val) \
220 #define returnFailFalse(ret, val) \
224 #define returnFailTrue(ret, val) \
228 #define returnFailNullptrV(val) \
229 if ((val) == nullptr) \
232 #define returnFailNullptr(ret, val) \
233 if ((val) == nullptr) \
236 #define failAlways(...) ;
241 #define reportFalse(val) failFalse(val)
242 #define reportTrue(val) failTrue(val)
243 #define reportAlways(...) failAlways(__VA_ARGS__)
244 #define returnFalseV(val) returnFailFalseV(val)
245 #define returnTrueV(val) returnFailTrueV(val)
246 #define returnFalse(ret, val) returnFailFalse(ret, val)
247 #define returnTrue(ret, val) returnFailTrue(ret, val)
248 #define returnNullptrV(val) returnFailNullptrV(val)
249 #define returnNullptr(ret, val) returnFailNullptr(ret, val)
251 #define reportFalse(val) reportFalseReal(val)
252 #define reportTrue(val) reportTrueReal(val)
253 #define reportAlways(...) reportAlwaysReal(__VA_ARGS__)
254 #define returnFalseV(val) returnFalseVReal(val)
255 #define returnTrueV(val) returnTrueVReal(val)
256 #define returnFalse(ret, val) returnFalseReal(ret, val)
257 #define returnTrue(ret, val) returnTrueReal(ret, val)
258 #define returnNullptrV(val) returnNullptrVReal(val)
259 #define returnNullptr(ret, val) returnNullptrReal(ret, val)