Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Burger::Assert_t Struct Reference

Container structure for Assert support. More...

Collaboration diagram for Burger::Assert_t:

Public Types

typedef int(*) CallbackProc(void *pThis, const char *pCondition, const char *pFilename, uint32_t uLineNumber)
 Redirect an assert to the application's assert function.
 

Public Member Functions

void SetCallback (CallbackProc pCallback, void *pThis) noexcept
 Overrides the default Assert function.
 

Static Public Member Functions

static int DefaultAssert (void *pThis, const char *pCondition, const char *pFilename, uint32_t uLineNumber) noexcept
 Default assert function.
 

Public Attributes

CallbackProc m_pCallback
 Function pointer to the redirected Assert function.
 
void * m_pThis
 "this" pointer passed to the m_pProcAssert function
 

Static Public Attributes

static Assert_t g_Instance
 Global instance of the Assert redirection.
 

Detailed Description

Container structure for Assert support.


This global assert structure is used for supporting the ability to redirect an Assert(const char *,const char *,uint32_t) call.

See also
Assert(const char *,const char *,uint32_t), or BURGER_ASSERT

Member Typedef Documentation

◆ CallbackProc

int( *) Burger::Assert_t::CallbackProc(void *pThis, const char *pCondition, const char *pFilename, uint32_t uLineNumber)

Redirect an assert to the application's assert function.


When an assert is fired from the use of the macro BURGER_ASSERT this function is called which redirects to the currently logged assert function.

Parameters
pThisPointer to the application supplied data pointer
pConditionString of the test condition that fired off the assert
pFilenameThe value of the "__FILE__" macro at the location of the BURGER_ASSERT macro
uLineNumberThe value of the "__LINE__" macro at the location of the BURGER_ASSERT macro
Returns
FALSE. Only return a non-false value if a very special case requires it because it may cause unexpected behavior from the use of the BURGER_ASSERT macro

Member Function Documentation

◆ DefaultAssert()

int BURGER_API Burger::Assert_t::DefaultAssert ( void * pThis,
const char * pCondition,
const char * pFilename,
uint32_t uLineNumber )
staticnoexcept

Default assert function.


Prints the message "Assertion from \"%%s\\" in file %s at line %u.\n", pCondition, pFilename, uLineNumber using Debug::Message(), and then calls invoke_debugger(). If execution continues, it will call Debug::Fatal() with the same message and exit the application.

Note
This function normally does not return and calls Debug::Fatal(). If the function returns, usually via manual user input in a debugger, it will return a conditional override which is 0 to match the condition that triggered the assert.
Parameters
pThisIgnored
pConditionMessage to print do denote the cause of the assertion
pFilenamePointer to a "C" string of the source file name that triggered the assert
uLineNumberLine number in the source file that triggered the assert
Returns
0 (However, this function should never return)
See also
Debug::Message(), Debug::Fatal(), and Assert( const char *,const char *,uint32_t)

◆ SetCallback()

void BURGER_API Burger::Assert_t::SetCallback ( CallbackProc pCallback,
void * pThis )
noexcept

Overrides the default Assert function.


The normal behavior for Assert(const char *,const char *,uint32_t) is to call printf() with the failure condition and then call Debug::Fatal(). This behavior can be overridden by passing a new function pointer via this call.

The default behavior can be restored by passing nullptr for the pAssert parameter.

Parameters
pCallbackFunction to call when an assert is triggered, nullptr restores defaults
pThisvoid * of data to be passed to the assert function if triggered

Member Data Documentation

◆ g_Instance

Burger::Assert_t Burger::Assert_t::g_Instance
static
Initial value:
= {
nullptr
}
static int DefaultAssert(void *pThis, const char *pCondition, const char *pFilename, uint32_t uLineNumber) noexcept
Default assert function.
Definition brassert.cpp:198

Global instance of the Assert redirection.

Singleton instance for Assert_t.


See also
Assert_t or Assert_t::DefaultAssert

◆ m_pCallback

CallbackProc Burger::Assert_t::m_pCallback

Function pointer to the redirected Assert function.

◆ m_pThis

void* Burger::Assert_t::m_pThis

"this" pointer passed to the m_pProcAssert function