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(* callback_t) (void *pThis, const char *pCondition, const char *pFilename, uint32_t uLineNumber)
 Redirect an assert to the application's assert function.
 

Public Member Functions

void set_callback (callback_t pCallback, void *pThis) noexcept
 Overrides the default do_assert function.
 

Static Public Member Functions

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

Public Attributes

callback_t m_pCallback
 Function pointer to the redirected do_assert function.
 
void * m_pThis
 "this" pointer passed to the m_pCallback function
 

Static Public Attributes

static assert_t g_Instance
 Global instance of the do_assert redirection.
 

Detailed Description

Container structure for assert support.


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

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

Member Typedef Documentation

◆ callback_t

typedef int( * Burger::assert_t::callback_t) (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

◆ default_assert()

int BURGER_API Burger::assert_t::default_assert ( 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 do_assert( const char*, const char*, uint32_t)

◆ set_callback()

void BURGER_API Burger::assert_t::set_callback ( callback_t pCallback,
void * pThis )
noexcept

Overrides the default do_assert function.


The normal behavior for do_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 pCallback 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 default_assert(void *pThis, const char *pCondition, const char *pFilename, uint32_t uLineNumber) noexcept
Default assert function.
Definition brassert.cpp:196

Global instance of the do_assert redirection.

Singleton instance for assert_t.


See also
assert_t or assert_t::default_assert

◆ m_pCallback

callback_t Burger::assert_t::m_pCallback

Function pointer to the redirected do_assert function.

◆ m_pThis

void* Burger::assert_t::m_pThis

"this" pointer passed to the m_pCallback function