00001 #ifndef toast_assert_hpp_INCLUDED 00002 #define toast_assert_hpp_INCLUDED 00003 00004 #include <toast/detail/assert.hpp> 00005 00024 #define TOAST_THROW_ASSERTS(statement) TOAST_THROW_ASSERTS_IMPL(statement) 00025 00033 #define TOAST_ASSERT(condition) TOAST_ASSERT_IMPL(condition) 00034 00042 #define TOAST_ASSERT_NOT_NULL(pointer) TOAST_ASSERT_NOT_NULL_IMPL(pointer) 00043 00051 #define TOAST_ASSERT_NULL(pointer) TOAST_ASSERT_NULL_IMPL(pointer) 00052 00060 #define TOAST_ASSERT_MESSAGE(condition, message) TOAST_ASSERT_MESSAGE_IMPL(condition, message) 00061 00062 #ifdef NDEBUG 00063 00070 #define TOAST_ASSERT_D(condition) 00071 00079 #define TOAST_ASSERT_NOT_NULL_D(pointer) 00080 00087 #define TOAST_ASSERT_NULL_D(pointer) 00088 00096 #define TOAST_ASSERT_MESSAGE_D(condition, message) 00097 00098 #else 00099 00106 #define TOAST_ASSERT_D(condition) TOAST_ASSERT(condition) 00107 00115 #define TOAST_ASSERT_NOT_NULL_D(pointer) TOAST_ASSERT_NOT_NULL(pointer) 00116 00123 #define TOAST_ASSERT_NULL_D(pointer) TOAST_ASSERT_NULL(pointer) 00124 00132 #define TOAST_ASSERT_MESSAGE_D(condition, message) TOAST_ASSERT_MESSAGE(condition, message) 00133 #endif 00134 00137 namespace toast { 00138 00150 class assert_exception : public std::exception 00151 { 00152 std::string message_; 00153 public: 00154 assert_exception( std::string const &message ) 00155 : message_(message) {} 00156 char const * what() const throw () { return message_.c_str(); } 00157 ~assert_exception() throw() {} 00158 }; 00159 00162 } 00163 00234 #endif // toast_assert_hpp_INCLUDED