Defines the Exception class and macros for throwing exceptions and doing assertions.
More...
#include <exception>
#include <stdexcept>
#include <string>
#include <iostream>
Go to the source code of this file.
Namespaces |
namespace | dai |
| Namespace for libDAI.
|
Macros |
#define | DAI_QUOTE(x) #x |
| Used by DAI_THROW.
|
#define | DAI_TOSTRING(x) DAI_QUOTE(x) |
| Used by DAI_THROW.
|
#define | FUNCTION_NAME __func__ |
| Macro that simplifies throwing an exception with a useful default error message.
|
#define | DAI_THROW(cod) throw dai::Exception(dai::Exception::cod, __FILE__, FUNCTION_NAME, DAI_TOSTRING(__LINE__), "") |
#define | DAI_THROWE(cod, msg) throw dai::Exception(dai::Exception::cod, __FILE__, FUNCTION_NAME, DAI_TOSTRING(__LINE__), msg) |
| Macro that simplifies throwing an exception with a user-defined error message.
|
#define | DAI_ASSERT(condition) ((condition) ? ((void)0) : DAI_THROWE(ASSERTION_FAILED, std::string("Assertion \"" #condition "\" failed"))) |
| Assertion mechanism, similar to the standard assert() macro. It is always active, even if NDEBUG is defined.
|
#define | DAI_DEBASSERT(x) do {DAI_ASSERT(x);} while(0) |
| Assertion mechanism similar to DAI_ASSERT which is only active if DAI_DEBUG is defined.
|
Detailed Description
Defines the Exception class and macros for throwing exceptions and doing assertions.
Macro Definition Documentation
#define DAI_QUOTE |
( |
|
x | ) |
#x |
#define FUNCTION_NAME __func__ |
Macro that simplifies throwing an exception with a useful default error message.
The error message consists of a description of the exception, the source code file and line number where the exception has been thrown.
- Parameters
-
- Example:
DAI_THROW(NOT_IMPLEMENTED);
Macro that simplifies throwing an exception with a user-defined error message.
- Parameters
-
cod | Corresponds to one of the enum values of dai::Exception::Code |
msg | Detailed error message that will be written to std::cerr. |
- Example:
DAI_THROWE(NOT_IMPLEMENTED,
"Detailed error message");
- Examples:
- uai2010-aie-solver.cpp.
#define DAI_ASSERT |
( |
|
condition | ) |
((condition) ? ((void)0) : DAI_THROWE(ASSERTION_FAILED, std::string("Assertion \"" #condition "\" failed"))) |
#define DAI_DEBASSERT |
( |
|
x | ) |
do {DAI_ASSERT(x);} while(0) |
Assertion mechanism similar to DAI_ASSERT which is only active if DAI_DEBUG is defined.