38 void set_ostream_ptr(std::ostream *ostream_ptr,
bool delete_later);
39 std::ostream *get_ostream_ptr()
const;
41 typedef bool AssertHandler(
const char *expression,
int line,
42 const char *source_file);
44 void set_assert_handler(AssertHandler *assert_handler);
45 void clear_assert_handler();
46 bool has_assert_handler()
const;
47 AssertHandler *get_assert_handler()
const;
49 INLINE
bool has_assert_failed()
const;
50 INLINE
const std::string &get_assert_error_message()
const;
51 INLINE
void clear_assert_failed();
57 const std::string &parent_fullname);
60 static std::ostream &out();
61 static std::ostream &
null();
62 static void write_string(
const std::string &str);
66 static ios_fmtflags get_literal_flag();
68 bool assert_failure(
const std::string &expression,
int line,
69 const char *source_file);
70 bool assert_failure(
const char *expression,
int line,
71 const char *source_file);
73 static NotifySeverity string_severity(
const std::string &
string);
75 void config_initialized();
78 std::ostream *_ostream_ptr;
79 bool _owns_ostream_ptr;
80 std::ostream *_null_ostream_ptr;
82 AssertHandler *_assert_handler;
84 std::string _assert_error_message;
88 typedef std::map<std::string, NotifyCategory *> Categories;
89 Categories _categories;
91 static Notify *_global_ptr;
100 #define nout (Notify::out())
127 #define _nassert_check(condition) (__builtin_expect(!(condition), 0))
129 #define _nassert_check(condition) (!(condition))
134 #define nassertr(condition, return_value)
135 #define nassertv(condition)
136 #define nassertd(condition) if (false)
139 #define nassertr_always(condition, return_value) \
141 if (_nassert_check(condition)) { \
142 return return_value; \
146 #define nassertv_always(condition) \
148 if (_nassert_check(condition)) { \
153 #define nassert_raise(message) Notify::write_string(message)
157 #define nassertr(condition, return_value) \
159 if (_nassert_check(condition)) { \
160 if (Notify::ptr()->assert_failure(#condition, __LINE__, __FILE__)) { \
161 return return_value; \
166 #define nassertv(condition) \
168 if (_nassert_check(condition)) { \
169 if (Notify::ptr()->assert_failure(#condition, __LINE__, __FILE__)) { \
175 #define nassertd(condition) \
176 if (_nassert_check(condition) && \
177 Notify::ptr()->assert_failure(#condition, __LINE__, __FILE__))
179 #define nassertr_always(condition, return_value) nassertr(condition, return_value)
180 #define nassertv_always(condition) nassertv(condition)
182 #define nassert_raise(message) Notify::ptr()->assert_failure(message, __LINE__, __FILE__)
186 #if __cplusplus >= 201103
187 #define __nassert_static(condition, line, file) static_assert((condition), #condition " at line " #line " of " file)
188 #define _nassert_static(condition, line, file) __nassert_static(condition, line, file)
189 #define nassert_static(condition) _nassert_static(condition, __LINE__, __FILE__)
191 #define __nassert_static(condition, suffix) typedef char nassert_static_ ## suffix [(condition) ? 1 : -1];
192 #define _nassert_static(condition, suffix) __nassert_static(condition, suffix)
193 #define nassert_static(condition) _nassert_static(condition, __COUNTER__)