44 void print_info(std::ostringstream &out)
const override;
51 std::ostringstream &
form_message(std::ostringstream &)
const override;
129 exception_.expression_ = expression;
130 exception_.frames_to_cut_ = {
"feal",
"Assert"};
137 exception_(other.exception_),
138 thrown_(other.thrown_) {}
147 template <
typename T>
149 std::stringstream ss;
150 ss << var_name <<
" : ";
151 ss <<
"'" << var_current_val <<
"'";
152 exception_.current_val_.push_back(ss.str());
158 Assert& set_context(
const char* file_name,
const char*
function,
const int line);
161 void error(std::string error_msg =
"");
164 void warning(std::string warning_msg =
"");
198 template <
typename T>
204 inline void error(std::string error_msg =
"") {}
207 inline void warning(std::string warning_msg =
"") {}
222 #define _FEAL_ASSERT_A(x) _FEAL_ASSERT_OP(x, B) 224 #define _FEAL_ASSERT_B(x) _FEAL_ASSERT_OP(x, A) 226 #define _FEAL_ASSERT_OP(x, next) \ 227 _FEAL_ASSERT_A.add_value((x), #x)._FEAL_ASSERT_ ## next 236 #ifdef FEAL_OVERRIDE_ASSERTS 239 #warning "ASSERT_LT already defined out of FEAL." 244 #ifdef FEAL_OVERRIDE_ASSERTS 247 #warning "ASSERT_LE already defined out of FEAL." 252 #ifdef FEAL_OVERRIDE_ASSERTS 255 #warning "ASSERT_GT already defined out of FEAL." 260 #ifdef FEAL_OVERRIDE_ASSERTS 263 #warning "ASSERT_GE already defined out of FEAL." 268 #ifdef FEAL_OVERRIDE_ASSERTS 271 #warning "ASSERT_EQ already defined out of FEAL." 280 #define FEAL_ASSERT( expr) \ 282 feal::Assert( #expr).set_context( __FILE__, __func__, __LINE__)._FEAL_ASSERT_A 285 #ifdef FLOW123D_DEBUG_ASSERTS 286 #define FEAL_ASSERT_DBG( expr) \ 288 feal::Assert( #expr).set_context( __FILE__, __func__, __LINE__)._FEAL_ASSERT_A 290 #define FEAL_ASSERT_DBG( expr) \ 292 feal::AssertNull()._FEAL_ASSERT_A 296 #define ASSERT_LT(a, b) \ 297 FEAL_ASSERT(a < b)(a)(b) 300 #define ASSERT_LT_DBG(a, b) \ 301 FEAL_ASSERT_DBG(a < b)(a)(b) 304 #define ASSERT_LE(a, b) \ 305 FEAL_ASSERT(a <= b)(a)(b) 308 #define ASSERT_LE_DBG(a, b) \ 309 FEAL_ASSERT_DBG(a <= b)(a)(b) 312 #define ASSERT_GT(a, b) \ 313 FEAL_ASSERT(a > b)(a)(b) 316 #define ASSERT_GT_DBG(a, b) \ 317 FEAL_ASSERT_DBG(a > b)(a)(b) 320 #define ASSERT_GE(a, b) \ 321 FEAL_ASSERT(a >= b)(a)(b) 324 #define ASSERT_GE_DBG(a, b) \ 325 FEAL_ASSERT_DBG(a >= b)(a)(b) 328 #define ASSERT_EQ(a, b) \ 329 FEAL_ASSERT(a == b)(a)(b) 332 #define ASSERT_EQ_DBG(a, b) \ 333 FEAL_ASSERT_DBG(a == b)(a)(b) 336 #define ASSERT_PTR( ptr ) \ 337 FEAL_ASSERT( (ptr) != nullptr ) 340 #define ASSERT_PTR_DBG( ptr ) \ 341 FEAL_ASSERT_DBG( (ptr) != nullptr ) 347 #define ASSERT( expr) FEAL_ASSERT( expr) 350 #define ASSERT_DBG( expr) FEAL_ASSERT_DBG( expr) Class defining debugging messages.
bool thrown_
Flag marked if Assert thrown error, warning, ...
#define _FEAL_ASSERT_A(x)
Internal clever macro A.
void warning(std::string warning_msg="")
Empty method, only guarantees consistent code.
AssertNull & _FEAL_ASSERT_B
clever macro B
Exc_assert exception_
Exception object.
Assert & _FEAL_ASSERT_A
clever macro A
Assert & _FEAL_ASSERT_B
clever macro B
std::ostringstream & form_message(std::ostringstream &) const override
Override ExceptionBase::form_message()
void print_info(std::ostringstream &out) const override
Print formatted assert message.
#define _FEAL_ASSERT_B(x)
Internal clever macro B.
std::string function_
Actual function.
std::string file_name_
Actual file.
std::string what_type_msg() const override
Override ExceptionBase::what_type_msg()
std::string expression_
Assertion expression.
AssertNull & add_value(T var_current_val, const char *var_name)
Empty method, only guarantees consistent code.
std::vector< std::string > current_val_
Formated strings of names and values of given variables.
AssertNull(const Assert &other)
Copy constructor.
Assert(const std::string &expression)
Constructor.
Assert(const Assert &other)
Copy constructor.
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.
void error(std::string error_msg="")
Empty method, only guarantees consistent code.
std::string what_type_msg_
String representation of message type (Program error, Warning, ...)