Joedb 9.5.0
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
assert.h
Go to the documentation of this file.
1#ifndef JOEDB_DEBUG_ASSERT
2
4
5#include <stdexcept>
6
7#define JOEDB_ASSERT_STRINGIFY(x) #x
8#define JOEDB_ASSERT_TO_STRING(x) JOEDB_ASSERT_STRINGIFY(x)
9#define JOEDB_CHECK(x,e) do\
10{\
11 if (!(x))\
12 throw e("!("#x ")\n File: " __FILE__ "\n Line: " JOEDB_ASSERT_TO_STRING(__LINE__));\
13} while(0)
14
15#if defined (NDEBUG) && !defined(JOEDB_FUZZING)
16/// @ingroup error
17#define JOEDB_DEBUG_ASSERT(x)
18#else
19/// @ingroup error
20#define JOEDB_DEBUG_ASSERT(x) JOEDB_CHECK(x, joedb::Assertion_Failure)
21#endif
22
23/// @ingroup error
24#define JOEDB_RELEASE_ASSERT(x) JOEDB_CHECK(x, joedb::Exception)
25
26namespace joedb
27{
28 /// Indicates a bug in the code, thrown by @ref JOEDB_ASSERT when NDEBUG not defined
29 /// @ingroup error
30 class Assertion_Failure: public std::logic_error
31 {
32 public:
33 explicit Assertion_Failure(const char *what_arg):
34 std::logic_error(what_arg)
35 {
36 }
37 };
38}
39
40#endif
Indicates a bug in the code, thrown by JOEDB_ASSERT when NDEBUG not defined.
Definition assert.h:31
Assertion_Failure(const char *what_arg)
Definition assert.h:33
Definition Blob.h:7