Flow123d
JS_before_hm-1804-gf2ad740aa
|
Go to the documentation of this file.
44 void print_info(std::ostringstream &out)
const override;
51 std::ostringstream &
form_message(std::ostringstream &)
const override;
147 template <
typename T>
149 std::stringstream ss;
150 ss << var_name <<
" : ";
151 ss <<
"'" << var_current_val <<
"'";
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>
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)
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.
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.