1#ifndef SDL3PP_ASSERT_H_
2#define SDL3PP_ASSERT_H_
4#include <SDL3/SDL_assert.h>
5#include "SDL3pp_stdinc.h"
72#define SDL_ASSERT_LEVEL SomeNumberBasedOnVariousFactors
92#define SDL_TriggerBreakpoint() TriggerABreakpointInAPlatformSpecificManner
101#define SDL_FUNCTION __FUNCTION__
108#define SDL_FILE __FILE__
115#define SDL_LINE __LINE__
135#define SDL_NULL_WHILE_LOOP_CONDITION (0)
151#define SDL_disabled_assert(condition) \
153 (void)sizeof((condition)); \
154 } while (SDL_NULL_WHILE_LOOP_CONDITION)
151#define SDL_disabled_assert(condition) \ …
183 SDL_ASSERTION_IGNORE;
186 SDL_ASSERTION_ALWAYS_IGNORE;
219 return SDL_ReportAssertion(data, func, file, line);
232#define SDL_AssertBreakpoint() SDL_TriggerBreakpoint()
255#define SDL_enabled_assert(condition) \
257 while (!(condition)) { \
258 static struct SDL_AssertData sdl_assert_data = { \
259 0, 0, #condition, 0, 0, 0, 0}; \
260 const SDL_AssertState sdl_assert_state = SDL_ReportAssertion( \
261 &sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
262 if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
264 } else if (sdl_assert_state == SDL_ASSERTION_BREAK) { \
265 SDL_AssertBreakpoint(); \
269 } while (SDL_NULL_WHILE_LOOP_CONDITION)
255#define SDL_enabled_assert(condition) \ …
301#define SDL_assert(condition) \
302 if (assertion_enabled && (condition)) { trigger_assertion; }
301#define SDL_assert(condition) \ …
335#define SDL_assert_release(condition) SDL_disabled_assert(condition)
364#define SDL_assert_paranoid(condition) SDL_disabled_assert(condition)
387#define SDL_assert_always(condition) SDL_enabled_assert(condition)
420 std::function<SDL_AssertState(
const SDL_AssertData*)>;
448 return SDL_SetAssertionHandler(handler, userdata);
477 Wrapper::Wrap(std::move(handler)));
497 return SDL_GetDefaultAssertionHandler();
525 return SDL_GetAssertionHandler(puserdata);
552 void* userdata =
nullptr;
554 if (Wrapper::contains(userdata))
return Wrapper::Unwrap(userdata);
555 return [cb, userdata](
const AssertData* data) {
return cb(data, userdata); };
591 return SDL_GetAssertionReport();
Helpers to use C++ strings parameters.
Definition SDL3pp_strings.h:43
constexpr AssertState ASSERTION_RETRY
Retry the assert immediately.
Definition SDL3pp_assert.h:173
const AssertData * GetAssertionReport()
Get a list of all assertion failures.
Definition SDL3pp_assert.h:589
std::function< SDL_AssertState(const SDL_AssertData *)> AssertionHandlerCB
A callback that fires when an SDL assertion fails.
Definition SDL3pp_assert.h:420
void ResetAssertionReport()
Clear the list of all assertion failures.
Definition SDL3pp_assert.h:610
constexpr AssertState ASSERTION_IGNORE
Ignore the assert.
Definition SDL3pp_assert.h:182
constexpr AssertState ASSERTION_ABORT
Terminate the program.
Definition SDL3pp_assert.h:179
AssertState ReportAssertion(AssertData *data, StringParam func, StringParam file, int line)
Never call this directly.
Definition SDL3pp_assert.h:214
SDL_AssertState AssertState
Possible outcomes from a triggered assertion.
Definition SDL3pp_assert.h:171
AssertionHandler GetDefaultAssertionHandler()
Get the default assertion handler.
Definition SDL3pp_assert.h:495
constexpr AssertState ASSERTION_BREAK
Make the debugger trigger a breakpoint.
Definition SDL3pp_assert.h:176
SDL_AssertionHandler AssertionHandler
A Callback that fires when an SDL assertion fails.
Definition SDL3pp_assert.h:404
constexpr AssertState ASSERTION_ALWAYS_IGNORE
Ignore the assert from now on.
Definition SDL3pp_assert.h:185
SDL_AssertData AssertData
Information about an assertion failure.
Definition SDL3pp_assert.h:197
void SetAssertionHandler(AssertionHandler handler, void *userdata)
Set an application-defined assertion handler.
Definition SDL3pp_assert.h:445
AssertionHandlerCB GetAssertionHandler()
Get the current assertion handler.
Definition SDL3pp_assert.h:549
the main namespace where all SDL3pp public functions and types live
Definition SDL3pp_assert.h:7
Stored Wrapper unique by type result callbacks.
Definition SDL3pp_callbackWrapper.h:242