File containing Exception class and assertion macros. More...
#include "cgatools/core.hpp"
#include <cstdlib>
#include <exception>
#include <string>
#include <iostream>
Go to the source code of this file.
Classes | |
class | cgatools::util::Exception |
A basic exception type. More... | |
Namespaces | |
namespace | cgatools |
Namespace containing the libcgatools API. | |
namespace | cgatools::util |
Namespace for general-purpose utilities. | |
Defines | |
#define | CGATOOLS_UTIL_EXCEPTION_HPP_ 1 |
#define | CGA_ASSERT_MSG(expr, message) |
Assertion that always runs. On failure, crash. | |
#define | CGA_WARN_MSG(expr, message) |
#define | CGA_ASSERT(expr) CGA_ASSERT_MSG(expr, "") |
#define | CGA_DBG_ASSERT(expr) CGA_ASSERT(expr) |
Debug-only assert. | |
#define | CGA_VOUT(var) "{"<<#var<<"="<<var<<"}" |
#define | CGA_ASSERT_EQ(var1, var2) CGA_ASSERT_MSG((var1)==(var2), CGA_VOUT(var1)<<CGA_VOUT(var2)) |
#define | CGA_ASSERT_NEQ(var1, var2) CGA_ASSERT_MSG((var1)!=(var2), CGA_VOUT(var1)<<CGA_VOUT(var2)) |
#define | CGA_ASSERT_L(var1, var2) CGA_ASSERT_MSG((var1)<(var2), CGA_VOUT(var1)<<CGA_VOUT(var2)) |
#define | CGA_ASSERT_LE(var1, var2) CGA_ASSERT_MSG((var1)<=(var2), CGA_VOUT(var1)<<CGA_VOUT(var2)) |
#define | CGA_ERROR_EX(m_message) |
File containing Exception class and assertion macros.
#define CGA_ASSERT_MSG | ( | expr, | |||
message | ) |
do \ { \ if (!(expr)) { \ std::cerr << "assert failed: " << \ __FILE__ << ":" << \ __LINE__ << ": " << \ #expr << std::endl << \ message << std::endl; \ volatile char *p = 0, ch = *p; \ if (ch == '\0') *p = ch; p++; ch = *p; \ std::exit(1); \ } \ } while (0)
Assertion that always runs. On failure, crash.
#define CGA_ERROR_EX | ( | m_message | ) |
{ \ std::stringstream stx; \ stx << m_message; \ throw cgatools::util::Exception(stx.str()); \ }
#define CGA_WARN_MSG | ( | expr, | |||
message | ) |
do \ { \ if (!(expr)) { \ std::cerr << "Warning. Assertion failed: " << \ __FILE__ << ":" << \ __LINE__ << ": " << \ #expr << std::endl << \ message << std::endl; \ } \ } while (0)