17 #define _QX_DEBUG_BREAK __debugbreak()
19 #define _QX_DEBUG_BREAK __builtin_debugtrap()
22 #define _QX_DEBUG_BREAK raise(SIGTRAP)
24 #define _QX_DEBUG_BREAK QX_EMPTY_MACRO
30 template<verbosity eVerbosity>
31 void resolve_assert_proceeding(
33 const category& fileCategory,
34 string_view svFunction,
37 string_view svCondition)
39 QX_LOGGER_INSTANCE.log(eVerbosity, QX_TEXT(
"[{}] "), fileCategory, svFile, svFunction, nLine, svCondition);
40 QX_LOGGER_INSTANCE.flush();
43 template<verbosity eVerbosity>
44 void resolve_assert_proceeding(
46 const category& fileCategory,
47 string_view svFunction,
50 string_view svCondition,
52 const category& category)
55 sMessage.append_format(QX_TEXT(
"[{}] "), svCondition);
56 QX_LOGGER_INSTANCE.log(eVerbosity, sMessage, category, svFile, svFunction, nLine);
57 QX_LOGGER_INSTANCE.flush();
60 template<verbosity eVerbosity,
class... args_t>
61 requires log_acceptable_args<args_t...>
62 void resolve_assert_proceeding(
64 const category& fileCategory,
65 string_view svFunction,
68 string_view svCondition,
70 format_string_strong_checks<args_t...> sFormat,
71 const args_t&... args)
74 sMessage.append_format(QX_TEXT(
"[{}] "), svCondition);
75 sMessage.append_format(sFormat, args...);
76 QX_LOGGER_INSTANCE.log(eVerbosity, sMessage, fileCategory, svFile, svFunction, nLine);
77 QX_LOGGER_INSTANCE.flush();
80 template<verbosity eVerbosity>
81 void resolve_assert_proceeding(
83 const category& fileCategory,
84 string_view svFunction,
87 string_view svCondition,
89 string_view svMessage)
92 sMessage.append_format(QX_TEXT(
"[{}] {}"), svCondition, svMessage);
93 QX_LOGGER_INSTANCE.log(eVerbosity, sMessage, fileCategory, svFile, svFunction, nLine);
94 QX_LOGGER_INSTANCE.flush();
97 template<verbosity eVerbosity,
class... args_t>
98 requires log_acceptable_args<args_t...>
99 void resolve_assert_proceeding(
101 const category& fileCategory,
102 string_view svFunction,
105 string_view svCondition,
107 const category& category,
108 format_string_strong_checks<args_t...> sFormat,
109 const args_t&... args)
112 sMessage.append_format(QX_TEXT(
"[{}] "), svCondition);
113 sMessage.append_format(sFormat, args...);
114 QX_LOGGER_INSTANCE.log(eVerbosity, sMessage, category, svFile, svFunction, nLine);
115 QX_LOGGER_INSTANCE.flush();
118 template<verbosity eVerbosity>
119 void resolve_assert_proceeding(
121 const category& fileCategory,
122 string_view svFunction,
125 string_view svCondition,
127 const category& category,
128 string_view svMessage)
131 sMessage.append_format(QX_TEXT(
"[{}] {}"), svCondition, svMessage);
132 QX_LOGGER_INSTANCE.log(eVerbosity, sMessage, category, svFile, svFunction, nLine);
133 QX_LOGGER_INSTANCE.flush();
140 #ifndef QX_DEBUG_BREAK
141 #define QX_DEBUG_BREAK _QX_DEBUG_BREAK
144 #ifndef QX_EXPECT_BEFORE_DEBUG_BREAK
145 #define QX_EXPECT_BEFORE_DEBUG_BREAK(condition, ...) \
146 qx::details::resolve_assert_proceeding<qx::verbosity::error>( \
147 QX_FILE_CATEGORY(), \
148 qx::to_string(__FUNCTION__), \
151 QX_TEXT(#condition), \
155 #ifndef QX_EXPECT_DEBUG_BREAK
156 #if QX_DEBUG || QX_REL_WITH_DEBUG_INFO
157 #define QX_EXPECT_DEBUG_BREAK QX_DEBUG_BREAK
159 #define QX_EXPECT_DEBUG_BREAK QX_EMPTY_MACRO
163 #ifndef QX_EXPECT_AFTER_DEBUG_BREAK
164 #define QX_EXPECT_AFTER_DEBUG_BREAK(condition, ...) QX_EMPTY_MACRO
167 #ifndef QX_ASSERT_BEFORE_DEBUG_BREAK
168 #define QX_ASSERT_BEFORE_DEBUG_BREAK(condition, ...) \
169 qx::details::resolve_assert_proceeding<qx::verbosity::critical>( \
170 QX_FILE_CATEGORY(), \
171 qx::to_string(__FUNCTION__), \
174 QX_TEXT(#condition), \
178 #ifndef QX_ASSERT_DEBUG_BREAK
179 #if QX_DEBUG || QX_REL_WITH_DEBUG_INFO
180 #define QX_ASSERT_DEBUG_BREAK QX_DEBUG_BREAK
182 #define QX_ASSERT_DEBUG_BREAK QX_EMPTY_MACRO
186 #ifndef QX_ASSERT_AFTER_DEBUG_BREAK
187 #define QX_ASSERT_AFTER_DEBUG_BREAK(condition, ...) std::terminate()
192 #define _QX_ASSERT(before_debug_break, debug_break, after_debug_break, condition, ...) \
195 QX_PUSH_SUPPRESS_MSVC_WARNINGS(4702); \
196 if (!(condition)) [[unlikely]] \
198 before_debug_break(condition, ##__VA_ARGS__); \
200 after_debug_break(condition, ##__VA_ARGS__); \
207 QX_POP_SUPPRESS_WARNINGS(); \
210 #define _QX_ASSERT_NO_ENTRY(before_debug_break, debug_break, after_debug_break, ...) \
211 _QX_ASSERT(before_debug_break, debug_break, after_debug_break, !QX_TEXT("No entry"), ##__VA_ARGS__)
213 #define _QX_ASSERT_CONTINUE(before_debug_break, debug_break, after_debug_break, condition, ...) \
214 if (!_QX_ASSERT(before_debug_break, debug_break, after_debug_break, condition, ##__VA_ARGS__)) [[unlikely]] \
219 #define _QX_ASSERT_BREAK(before_debug_break, debug_break, after_debug_break, condition, ...) \
220 if (!_QX_ASSERT(before_debug_break, debug_break, after_debug_break, condition, ##__VA_ARGS__)) [[unlikely]] \
225 #define _QX_ASSERT_RETURN( \
226 before_debug_break, \
233 if (!_QX_ASSERT(before_debug_break, debug_break, after_debug_break, condition, ##__VA_ARGS__)) [[unlikely]] \
234 return_keyword return_value; \
250 #define QX_ASSERT(condition, ...) \
252 QX_ASSERT_BEFORE_DEBUG_BREAK, \
253 QX_ASSERT_DEBUG_BREAK, \
254 QX_ASSERT_AFTER_DEBUG_BREAK, \
267 #define QX_ASSERT_NO_ENTRY(...) \
268 _QX_ASSERT_NO_ENTRY(QX_ASSERT_BEFORE_DEBUG_BREAK, QX_ASSERT_DEBUG_BREAK, QX_ASSERT_AFTER_DEBUG_BREAK, ##__VA_ARGS__)
280 #define QX_EXPECT(condition, ...) \
282 QX_EXPECT_BEFORE_DEBUG_BREAK, \
283 QX_EXPECT_DEBUG_BREAK, \
284 QX_EXPECT_AFTER_DEBUG_BREAK, \
297 #define QX_EXPECT_NO_ENTRY(...) \
298 _QX_ASSERT_NO_ENTRY(QX_EXPECT_BEFORE_DEBUG_BREAK, QX_EXPECT_DEBUG_BREAK, QX_EXPECT_AFTER_DEBUG_BREAK, ##__VA_ARGS__)
310 #define QX_EXPECT_CONTINUE(condition, ...) \
311 _QX_ASSERT_CONTINUE( \
312 QX_EXPECT_BEFORE_DEBUG_BREAK, \
313 QX_EXPECT_DEBUG_BREAK, \
314 QX_EXPECT_AFTER_DEBUG_BREAK, \
328 #define QX_EXPECT_BREAK(condition, ...) \
330 QX_EXPECT_BEFORE_DEBUG_BREAK, \
331 QX_EXPECT_DEBUG_BREAK, \
332 QX_EXPECT_AFTER_DEBUG_BREAK, \
347 #define QX_EXPECT_RETURN(condition, return_value, ...) \
349 QX_EXPECT_BEFORE_DEBUG_BREAK, \
350 QX_EXPECT_DEBUG_BREAK, \
351 QX_EXPECT_AFTER_DEBUG_BREAK, \
367 #define QX_EXPECT_RETURN_VOID(condition, ...) \
369 QX_EXPECT_BEFORE_DEBUG_BREAK, \
370 QX_EXPECT_DEBUG_BREAK, \
371 QX_EXPECT_AFTER_DEBUG_BREAK, \
388 #define QX_EXPECT_CO_RETURN(condition, return_value, ...) \
390 QX_EXPECT_BEFORE_DEBUG_BREAK, \
391 QX_EXPECT_DEBUG_BREAK, \
392 QX_EXPECT_AFTER_DEBUG_BREAK, \
408 #define QX_EXPECT_CO_RETURN_VOID(condition, ...) \
410 QX_EXPECT_BEFORE_DEBUG_BREAK, \
411 QX_EXPECT_DEBUG_BREAK, \
412 QX_EXPECT_AFTER_DEBUG_BREAK, \