The Sparta Modeling Framework
|
Set of macros for Sparta assertions. Caught by the framework. More...
#include <exception>
#include <string>
#include <iostream>
#include <sstream>
#include "sparta/utils/SpartaException.hpp"
Go to the source code of this file.
Macros | |
#define | SPARTA_EXPECT_FALSE(x) __builtin_expect(!!(x), false) |
A macro for hinting to the compiler a particular condition should be considered most likely false. | |
#define | SPARTA_EXPECT_TRUE(x) __builtin_expect(!!(x), true) |
A macro for hinting to the compiler a particular condition should be considered most likely true. | |
#define | sparta_assert(...) sparta_assert_impl(VA_NARGS(__VA_ARGS__), __VA_ARGS__) |
Simple variadic assertion that will throw a sparta_exception if the condition fails. | |
#define | sparta_assert_errno(_cond) sparta_assert(_cond, std::string(std::strerror(errno))) |
Simple assert macro that throws a sparta_exception with a string representation of errno. | |
#define | sparta_abort(...) sparta_abort_impl(VA_NARGS(__VA_ARGS__), __VA_ARGS__) |
Simple variatic assertion that will print a message to std::cerr and call std::terminate() | |
Set of macros for Sparta assertions. Caught by the framework.
Definition in file SpartaAssert.hpp.
#define sparta_abort | ( | ... | ) | sparta_abort_impl(VA_NARGS(__VA_ARGS__), __VA_ARGS__) |
Simple variatic assertion that will print a message to std::cerr and call std::terminate()
Use instead of sparta_assert() whenever you need an assertion in a noexcept(true) function (commonly destructors).
How to use:
Mental thought "Make sure that condition is true. If not print message and abort"
Definition at line 145 of file SpartaAssert.hpp.
#define sparta_assert | ( | ... | ) | sparta_assert_impl(VA_NARGS(__VA_ARGS__), __VA_ARGS__) |
Simple variadic assertion that will throw a sparta_exception if the condition fails.
SpartaException | including file and line information if e evaluates to false |
How to use:
Mental thought "Make sure that condition is true. If not send message"
Definition at line 114 of file SpartaAssert.hpp.
#define sparta_assert_errno | ( | _cond | ) | sparta_assert(_cond, std::string(std::strerror(errno))) |
Simple assert macro that throws a sparta_exception with a string representation of errno.
Definition at line 123 of file SpartaAssert.hpp.
#define SPARTA_EXPECT_FALSE | ( | x | ) | __builtin_expect(!!(x), false) |
A macro for hinting to the compiler a particular condition should be considered most likely false.
Definition at line 27 of file SpartaAssert.hpp.
#define SPARTA_EXPECT_TRUE | ( | x | ) | __builtin_expect(!!(x), true) |
A macro for hinting to the compiler a particular condition should be considered most likely true.
Definition at line 38 of file SpartaAssert.hpp.