Go to the documentation of this file.
27 #ifndef ANTIOCH_ASSERTS_H
28 #define ANTIOCH_ASSERTS_H
32 #include "antioch_config.h"
41 #define antioch_here() do { std::cerr << __FILE__ << ", line " << __LINE__ << ", compiled " << __DATE__ << " at " << __TIME__ << std::endl; } while (0)
48 #define antioch_assert(asserted) ((void) 0)
49 #define antioch_assert_msg(asserted, msg) ((void) 0)
50 #define antioch_assert_equal_to(expr1,expr2) ((void) 0)
51 #define antioch_assert_not_equal_to(expr1,expr2) ((void) 0)
52 #define antioch_assert_less(expr1,expr2) ((void) 0)
53 #define antioch_assert_greater(expr1,expr2) ((void) 0)
54 #define antioch_assert_less_equal(expr1,expr2) ((void) 0)
55 #define antioch_assert_greater_equal(expr1,expr2) ((void) 0)
58 #define antioch_assert(asserted) do { if (!(asserted)) { std::cerr << "Assertion `" #asserted "' failed." << std::endl; antioch_error(); } } while(0)
63 #ifdef ANTIOCH_HAVE_CXX11
64 #define antioch_assert_equal_to(expr1,expr2) do { typedef decltype(expr1) type1; typedef decltype(expr2) type2; if (!((expr1 == static_cast<type1>(expr2)) && static_cast<type2>(expr1) == expr2)) { std::cerr << "Assertion `" #expr1 " == " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << std::endl; antioch_error(); } } while(0)
65 #define antioch_assert_not_equal_to(expr1,expr2) do { typedef decltype(expr1) type1; typedef decltype(expr2) type2; if (!((expr1 != static_cast<type1>(expr2)) && (static_cast<type2>(expr1) != expr2))) { std::cerr << "Assertion `" #expr1 " != " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << std::endl; antioch_error(); } } while(0)
66 #define antioch_assert_less(expr1,expr2) do { typedef decltype(expr1) type1; typedef decltype(expr2) type2; if (!((static_cast<type2>(expr1) < expr2) && (expr1 < static_cast<type1>(expr2)))) { std::cerr << "Assertion `" #expr1 " < " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << std::endl; antioch_error(); } } while(0)
67 #define antioch_assert_greater(expr1,expr2) do { typedef decltype(expr1) type1; typedef decltype(expr2) type2; if (!((static_cast<type2>(expr1) > expr2) && (expr1 > static_cast<type1>(expr2)))) { std::cerr << "Assertion `" #expr1 " > " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << std::endl; antioch_error(); } } while(0)
68 #define antioch_assert_less_equal(expr1,expr2) do { typedef decltype(expr1) type1; typedef decltype(expr2) type2; if (!((static_cast<type2>(expr1) <= expr2) && (expr1 <= static_cast<type1>(expr2)))) { std::cerr << "Assertion `" #expr1 " <= " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << std::endl; antioch_error(); } } while(0)
69 #define antioch_assert_greater_equal(expr1,expr2) do { typedef decltype(expr1) type1; typedef decltype(expr2) type2; if (!((static_cast<type2>(expr1) >= expr2) && (expr1 >= static_cast<type1>(expr2)))) { std::cerr << "Assertion `" #expr1 " >= " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << std::endl; antioch_error(); } } while(0)
74 #define antioch_assert_equal_to(expr1,expr2) do { if (!(expr1 == expr2)) { std::cerr << "Assertion `" #expr1 " == " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << std::endl; antioch_error(); } } while(0)
75 #define antioch_assert_not_equal_to(expr1,expr2) do { if (!(expr1 != expr2)) { std::cerr << "Assertion `" #expr1 " != " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << std::endl; antioch_error(); } } while(0)
76 #define antioch_assert_less(expr1,expr2) do { if (!(expr1 < expr2)) { std::cerr << "Assertion `" #expr1 " < " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << std::endl; antioch_error(); } } while(0)
77 #define antioch_assert_greater(expr1,expr2) do { if (!(expr1 > expr2)) { std::cerr << "Assertion `" #expr1 " > " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << std::endl; antioch_error(); } } while(0)
78 #define antioch_assert_less_equal(expr1,expr2) do { if (!(expr1 <= expr2)) { std::cerr << "Assertion `" #expr1 " <= " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << std::endl; antioch_error(); } } while(0)
79 #define antioch_assert_greater_equal(expr1,expr2) do { if (!(expr1 >= expr2)) { std::cerr << "Assertion `" #expr1 " >= " #expr2 "' failed.\n" #expr1 " = " << (expr1) << "\n" #expr2 " = " << (expr2) << std::endl; antioch_error(); } } while(0)
88 #undef antioch_do_once
89 #define antioch_do_once(do_this) \
91 static bool did_this_already = false; \
92 if (!did_this_already) { \
93 did_this_already = true; \
99 #define antioch_warning(message) \
100 antioch_do_once(std::cout << message \
101 << __FILE__ << ", line " << __LINE__ << ", compiled " << __DATE__ << " at " << __TIME__ << " ***" << std::endl;)
104 #define antioch_error() do { antioch_here(); ANTIOCH_THROW(Antioch::LogicError()); } while(0)
105 #define antioch_not_implemented() do { antioch_here(); ANTIOCH_THROW(Antioch::NotImplemented()); } while(0)
106 #define antioch_file_error(filename) do { antioch_here(); ANTIOCH_THROW(Antioch::FileError(filename)); } while(0)
107 #define antioch_unit_error(description) do { antioch_here(); ANTIOCH_THROW(Antioch::UnitError(description)); } while(0)
108 #define antioch_parsing_error(description) do { antioch_here(); ANTIOCH_THROW(Antioch::ParsingError(description)); } while(0)
110 #define antioch_parameter_required(parameter,defaultpar) \
111 antioch_warning("\n*** Warning, The parameter " << parameter << " is not provided\n" << "default parameter is " << defaultpar << std::endl)
113 #define antioch_unit_required(parameter,defaultunit) \
114 antioch_warning("\n*** Warning, The parameter " << parameter << " is not given a unit\n" << "default unit given is " << defaultunit << std::endl)
117 #define antioch_deprecated() \
118 antioch_warning( "\n*** Warning, This code is deprecated, and likely to be removed in future library versions!\n")
122 #define antioch_msg(errmsg) do {std::cerr << errmsg << std::endl;} while(0)
123 #define antioch_error_msg(errmsg) do {antioch_msg(errmsg); antioch_error();} while(0)
124 #define antioch_not_implemented_msg(errmsg) do {antioch_msg(errmsg); antioch_not_implemented();} while(0)
127 #ifdef ANTIOCH_HAVE_CXX_STATIC_ASSERT
128 #define antioch_static_assert(cond,errmsg) static_assert(cond,errmsg)
130 #define antioch_static_assert(cond,errmsg) ((void) 0)
136 #ifdef ANTIOCH_HAVE_CXX_STATIC_ASSERT
137 #define antioch_static_assert_runtime_fallback(cond,errmsg) static_assert( cond, errmsg )
139 #define antioch_static_assert_runtime_fallback(cond,errmsg) \
141 antioch_msg_error(errmsg)
144 #endif // ANTIOCH_ASSERTS_H
Generated on Thu Jul 7 2016 11:09:46 for antioch-0.4.0
by
doxygen
1.8.8