Flow123d
master-a7f2151e0
|
Go to the documentation of this file.
45 void print_info(std::ostringstream &out)
const override;
52 std::ostringstream &
form_message(std::ostringstream &)
const override;
148 template <
typename T>
150 std::stringstream ss;
151 ss << var_name <<
" : ";
152 ss <<
"'" << var_current_val <<
"'";
159 Assert&
set_context(
const char* file_name,
const char*
function,
const int line);
162 void error(std::string error_msg =
"");
165 void warning(std::string warning_msg =
"");
199 template <
typename T>
223 #define _FEAL_ASSERT_A(x) _FEAL_ASSERT_OP(x, B)
225 #define _FEAL_ASSERT_B(x) _FEAL_ASSERT_OP(x, A)
227 #define _FEAL_ASSERT_OP(x, next) \
228 _FEAL_ASSERT_A.add_value((x), #x)._FEAL_ASSERT_ ## next
237 #ifdef FEAL_OVERRIDE_ASSERTS
240 #warning "ASSERT_LT already defined out of FEAL."
245 #ifdef FEAL_OVERRIDE_ASSERTS
248 #warning "ASSERT_LE already defined out of FEAL."
253 #ifdef FEAL_OVERRIDE_ASSERTS
256 #warning "ASSERT_GT already defined out of FEAL."
261 #ifdef FEAL_OVERRIDE_ASSERTS
264 #warning "ASSERT_GE already defined out of FEAL."
269 #ifdef FEAL_OVERRIDE_ASSERTS
272 #warning "ASSERT_EQ already defined out of FEAL."
281 #define FEAL_ASSERT_PERMANENT( expr) \
283 feal::Assert( #expr).set_context( __FILE__, __func__, __LINE__)._FEAL_ASSERT_A
286 #ifdef FLOW123D_DEBUG_ASSERTS
287 #define FEAL_ASSERT( expr) \
289 feal::Assert( #expr).set_context( __FILE__, __func__, __LINE__)._FEAL_ASSERT_A
291 #define FEAL_ASSERT( expr) \
293 feal::AssertNull()._FEAL_ASSERT_A
297 #define ASSERT_PERMANENT_LT(a, b) \
298 FEAL_ASSERT_PERMANENT(a < b)(a)(b)
301 #define ASSERT_LT(a, b) \
302 FEAL_ASSERT(a < b)(a)(b)
305 #define ASSERT_PERMANENT_LE(a, b) \
306 FEAL_ASSERT_PERMANENT(a <= b)(a)(b)
309 #define ASSERT_LE(a, b) \
310 FEAL_ASSERT(a <= b)(a)(b)
313 #define ASSERT_PERMANENT_GT(a, b) \
314 FEAL_ASSERT_PERMANENT(a > b)(a)(b)
317 #define ASSERT_GT(a, b) \
318 FEAL_ASSERT(a > b)(a)(b)
321 #define ASSERT_PERMANENT_GE(a, b) \
322 FEAL_ASSERT_PERMANENT(a >= b)(a)(b)
325 #define ASSERT_GE(a, b) \
326 FEAL_ASSERT(a >= b)(a)(b)
329 #define ASSERT_PERMANENT_EQ(a, b) \
330 FEAL_ASSERT_PERMANENT(a == b)(a)(b)
333 #define ASSERT_EQ(a, b) \
334 FEAL_ASSERT(a == b)(a)(b)
337 #define ASSERT_PERMANENT_PTR( ptr ) \
338 FEAL_ASSERT_PERMANENT( (ptr) != nullptr )
341 #define ASSERT_PTR( ptr ) \
342 FEAL_ASSERT( (ptr) != nullptr )
347 #ifndef ASSERT_PERMANENT
348 #define ASSERT_PERMANENT( expr) FEAL_ASSERT_PERMANENT( expr)
351 #define ASSERT( expr) FEAL_ASSERT( expr)
void warning(FMT_UNUSED std::string warning_msg="")
Empty method, only guarantees consistent code.
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(FMT_UNUSED const Assert &other)
Copy constructor.
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
Exc_assert exception_
Exception object.
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 & add_value(FMT_UNUSED T var_current_val, FMT_UNUSED const char *var_name)
Empty method, only guarantees consistent code.
void error(std::string error_msg="")
Generate error with given message.
Global macros to enhance readability and debugging, general constants.
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 error(FMT_UNUSED std::string error_msg="")
Empty method, only guarantees consistent code.
void warning(std::string warning_msg="")
Generate warning with given message.