26 #ifndef XAPIAN_INCLUDED_OMASSERT_H 27 #define XAPIAN_INCLUDED_OMASSERT_H 29 #ifndef XAPIAN_ASSERTIONS 32 # ifdef XAPIAN_ASSERTIONS_PARANOID 33 # error XAPIAN_ASSERTIONS_PARANOID defined without XAPIAN_ASSERTIONS 41 #define XAPIAN_ASSERT_LOCATION__(LINE,MSG) __FILE__":"#LINE": "#MSG 42 #define XAPIAN_ASSERT_LOCATION_(LINE,MSG) XAPIAN_ASSERT_LOCATION__(LINE,MSG) 43 #define XAPIAN_ASSERT_LOCATION(MSG) XAPIAN_ASSERT_LOCATION_(__LINE__,MSG) 48 #ifdef XAPIAN_ASSERTIONS_PARANOID 49 # define AssertParanoid(COND) Assert(COND) 50 # define AssertRelParanoid(A,REL,B) AssertRel(A,REL,B) 51 # define AssertEqParanoid(A,B) AssertEq(A,B) 52 # define AssertEqDoubleParanoid(A,B) AssertEqDouble(A,B) 59 #define Assert(COND) \ 62 throw Xapian::AssertionError(XAPIAN_ASSERT_LOCATION(COND));\ 72 #define AssertRel(A,REL,B) \ 74 if (rare(!((A) REL (B)))) {\ 75 std::string xapian_assertion_msg(XAPIAN_ASSERT_LOCATION(A REL B));\ 76 xapian_assertion_msg += " : values were ";\ 77 xapian_assertion_msg += str(A);\ 78 xapian_assertion_msg += " and ";\ 79 xapian_assertion_msg += str(B);\ 80 throw Xapian::AssertionError(xapian_assertion_msg);\ 91 #define AssertEq(A,B) AssertRel(A,==,B) 96 bool within_DBL_EPSILON(
double a,
double b);
101 #define AssertEqDouble(A,B) \ 103 using Xapian::Internal::within_DBL_EPSILON;\ 104 if (rare(!within_DBL_EPSILON(A, B))) {\ 105 std::string xapian_assertion_msg(XAPIAN_ASSERT_LOCATION(within_DBL_EPSILON(A, B)));\ 106 xapian_assertion_msg += " : values were ";\ 107 xapian_assertion_msg += str(A);\ 108 xapian_assertion_msg += " and ";\ 109 xapian_assertion_msg += str(B);\ 110 throw Xapian::AssertionError(xapian_assertion_msg);\ 122 # define Assert(COND) (void)0 123 # define AssertRel(A,REL,B) (void)0 124 # define AssertEq(A,B) (void)0 125 # define AssertEqDouble(A,B) (void)0 128 #ifndef AssertParanoid 129 # define AssertParanoid(COND) (void)0 130 # define AssertRelParanoid(A,REL,B) (void)0 131 # define AssertEqParanoid(A,B) (void)0 132 # define AssertEqDoubleParanoid(A,B) (void)0 135 #endif // XAPIAN_INCLUDED_OMASSERT_H The Xapian namespace contains public interfaces for the Xapian library.
Convert types to std::string.
Hierarchy of classes which Xapian can throw as exceptions.