xerus
a general purpose tensor library
check.h File Reference

Header file for CHECK and REQUIRE macros. More...

#include "namedLogger.h"
#include "callStack.h"
#include "containerOutput.h"

Go to the source code of this file.

Macros

#define XERUS_CHECK(condition, level, message)   if(XERUS_IS_LOGGING(level) && !(condition)) { XERUS_LOG(level, #condition " failed msg: " << message); } else void(0)
 Checks whether condition is true and calls XERUS_LOG(level, message) otherwise. More...
 
#define XERUS_IF_CHECK(expression)   expression
 Executes expression only if the compilation was without XERUS_DISABLE_RUNTIME_CHECKS set. More...
 
#define XERUS_IF_NO_CHECK(expression)
 
#define XERUS_INTERNAL_CHECK(condition, message)
 Checks whether condition is true. logs a critical error otherwise via XERUS_LOG(fatal, message). and prints information on how to report a bug. More...
 
#define XERUS_REQUIRE(condition, message)   XERUS_CHECK(condition, error, message)
 Checks whether condition is true. logs an error otherwise via XERUS_LOG(error, message). More...
 
#define XERUS_REQUIRE_TEST   (void)0
 

Detailed Description

Header file for CHECK and REQUIRE macros.

Definition in file check.h.

Macro Definition Documentation

◆ XERUS_CHECK

#define XERUS_CHECK (   condition,
  level,
  message 
)    if(XERUS_IS_LOGGING(level) && !(condition)) { XERUS_LOG(level, #condition " failed msg: " << message); } else void(0)

Checks whether condition is true and calls XERUS_LOG(level, message) otherwise.

The check is omitted if level is not logged anyways.

Definition at line 62 of file check.h.

◆ XERUS_IF_CHECK

#define XERUS_IF_CHECK (   expression)    expression

Executes expression only if the compilation was without XERUS_DISABLE_RUNTIME_CHECKS set.

Definition at line 84 of file check.h.

◆ XERUS_IF_NO_CHECK

#define XERUS_IF_NO_CHECK (   expression)

Definition at line 86 of file check.h.

◆ XERUS_INTERNAL_CHECK

#define XERUS_INTERNAL_CHECK (   condition,
  message 
)
Value:
if(!(condition)) { \
::std::cerr << "\n"\
"########################################################################\n"\
"### AN INTERNAL ERROR OCCURED! ###\n"\
"### Please send the following information to contact@libxerus.org ! ###\n"\
"########################################################################\n"\
"xerus version: " << ::xerus::VERSION_MAJOR << '.' << ::xerus::VERSION_MINOR << '.' << ::xerus::VERSION_REVISION << '-' << ::xerus::VERSION_COMMIT << "\n" \
"at: " __FILE__ " : " XERUS_STRINGIFY(__LINE__) "\n" \
"message: " #condition " failed: " << message << '\n' \
<< "callstack: \n" << ::xerus::misc::get_call_stack() << "\n" \
"########################################################################\n"\
"### thank you :-) ###\n"\
"########################################################################" << std::endl; \
XERUS_LOG(critical, #condition " failed msg: " << message); \
} else void(0)
#define XERUS_STRINGIFY(x)
Definition: namedLogger.h:93
const int VERSION_MINOR
Definition: standard.cpp:29
std::string get_call_stack()
Returns a string representation of the current call-stack (excluding the function itself)...
Definition: callStack.cpp:166
const int VERSION_MAJOR
Definition: standard.cpp:28
const int VERSION_COMMIT
Definition: standard.cpp:31
const int VERSION_REVISION
Definition: standard.cpp:30

Checks whether condition is true. logs a critical error otherwise via XERUS_LOG(fatal, message). and prints information on how to report a bug.

Definition at line 67 of file check.h.

◆ XERUS_REQUIRE

#define XERUS_REQUIRE (   condition,
  message 
)    XERUS_CHECK(condition, error, message)

Checks whether condition is true. logs an error otherwise via XERUS_LOG(error, message).

Definition at line 65 of file check.h.

◆ XERUS_REQUIRE_TEST

#define XERUS_REQUIRE_TEST   (void)0

Definition at line 51 of file check.h.