Flow123d
release_3.0.0-968-gc87a28e79
|
Go to the documentation of this file.
43 void print_info(std::ostringstream &out)
const override;
50 std::ostringstream &
form_message(std::ostringstream &)
const override;
146 template <
typename T>
148 std::stringstream ss;
149 ss << var_name <<
" : ";
150 ss <<
"'" << var_current_val <<
"'";
157 Assert&
set_context(
const char* file_name,
const char*
function,
const int line);
160 void error(std::string error_msg =
"");
163 void warning(std::string warning_msg =
"");
197 template <
typename T>
203 inline void error(std::string error_msg =
"") {}
206 inline void warning(std::string warning_msg =
"") {}
221 #define _FEAL_ASSERT_A(x) _FEAL_ASSERT_OP(x, B)
223 #define _FEAL_ASSERT_B(x) _FEAL_ASSERT_OP(x, A)
225 #define _FEAL_ASSERT_OP(x, next) \
226 _FEAL_ASSERT_A.add_value((x), #x)._FEAL_ASSERT_ ## next
235 #ifdef FEAL_OVERRIDE_ASSERTS
238 #warning "ASSERT_LT already defined out of FEAL."
243 #ifdef FEAL_OVERRIDE_ASSERTS
246 #warning "ASSERT_LE already defined out of FEAL."
251 #ifdef FEAL_OVERRIDE_ASSERTS
254 #warning "ASSERT_GT already defined out of FEAL."
259 #ifdef FEAL_OVERRIDE_ASSERTS
262 #warning "ASSERT_GE already defined out of FEAL."
267 #ifdef FEAL_OVERRIDE_ASSERTS
270 #warning "ASSERT_EQ already defined out of FEAL."
279 #define FEAL_ASSERT( expr) \
281 feal::Assert( #expr).set_context( __FILE__, __func__, __LINE__)._FEAL_ASSERT_A
284 #ifdef FLOW123D_DEBUG_ASSERTS
285 #define FEAL_ASSERT_DBG( expr) \
287 feal::Assert( #expr).set_context( __FILE__, __func__, __LINE__)._FEAL_ASSERT_A
289 #define FEAL_ASSERT_DBG( expr) \
291 feal::AssertNull()._FEAL_ASSERT_A
295 #define ASSERT_LT(a, b) \
296 FEAL_ASSERT(a < b)(a)(b)
299 #define ASSERT_LT_DBG(a, b) \
300 FEAL_ASSERT_DBG(a < b)(a)(b)
303 #define ASSERT_LE(a, b) \
304 FEAL_ASSERT(a <= b)(a)(b)
307 #define ASSERT_LE_DBG(a, b) \
308 FEAL_ASSERT_DBG(a <= b)(a)(b)
311 #define ASSERT_GT(a, b) \
312 FEAL_ASSERT(a > b)(a)(b)
315 #define ASSERT_GT_DBG(a, b) \
316 FEAL_ASSERT_DBG(a > b)(a)(b)
319 #define ASSERT_GE(a, b) \
320 FEAL_ASSERT(a >= b)(a)(b)
323 #define ASSERT_GE_DBG(a, b) \
324 FEAL_ASSERT_DBG(a >= b)(a)(b)
327 #define ASSERT_EQ(a, b) \
328 FEAL_ASSERT(a == b)(a)(b)
331 #define ASSERT_EQ_DBG(a, b) \
332 FEAL_ASSERT_DBG(a == b)(a)(b)
335 #define ASSERT_PTR( ptr ) \
336 FEAL_ASSERT( (ptr) != nullptr )
339 #define ASSERT_PTR_DBG( ptr ) \
340 FEAL_ASSERT_DBG( (ptr) != nullptr )
346 #define ASSERT( expr) FEAL_ASSERT( expr)
349 #define ASSERT_DBG( expr) FEAL_ASSERT_DBG( expr)
Assert(const Assert &other)
Copy constructor.
void print_info(std::ostringstream &out) const override
Print formatted assert message.
AssertNull & _FEAL_ASSERT_A
clever macro A
Assert & add_value(T var_current_val, const char *var_name)
Adds name and value of variable.
Base of exceptions used in Flow123d.
Assert & set_context(const char *file_name, const char *function, const int line)
Stores values for printing out line number, function, etc.
std::ostringstream & form_message(std::ostringstream &) const override
Override ExceptionBase::form_message()
AssertNull & add_value(T var_current_val, const char *var_name)
Empty method, only guarantees consistent code.
std::string what_type_msg() const override
Override ExceptionBase::what_type_msg()
AssertNull & _FEAL_ASSERT_B
clever macro B
Assert & _FEAL_ASSERT_B
clever macro B
void warning(std::string warning_msg="")
Empty method, only guarantees consistent code.
Exc_assert exception_
Exception object.
void error(std::string error_msg="")
Empty method, only guarantees consistent code.
Assert & _FEAL_ASSERT_A
clever macro A
Class defining debugging messages.
std::string file_name_
Actual file.
std::string expression_
Assertion expression.
std::vector< std::string > frames_to_cut_
Stacktrace frames, which will be cut, see StackTrace::print method.
std::string what_type_msg_
String representation of message type (Program error, Warning, ...)
AssertNull(const Assert &other)
Copy constructor.
void error(std::string error_msg="")
Generate error with given message.
Assert(const std::string &expression)
Constructor.
std::vector< std::string > current_val_
Formated strings of names and values of given variables.
std::string function_
Actual function.
bool thrown_
Flag marked if Assert thrown error, warning, ...
void warning(std::string warning_msg="")
Generate warning with given message.