43 void print_info(std::ostringstream &out)
const override;
50 std::ostringstream &
form_message(std::ostringstream &)
const override;
128 exception_.expression_ = expression;
129 exception_.frames_to_cut_ = {
"feal",
"Assert"};
136 exception_(other.exception_),
137 thrown_(other.thrown_) {}
146 template <
typename T>
148 std::stringstream ss;
149 ss << var_name <<
" : ";
150 ss <<
"'" << var_current_val <<
"'";
151 exception_.current_val_.push_back(ss.str());
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) 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, ...)