Classes | Public Types | Static Public Member Functions | Static Private Attributes

BRDebug Class Reference

#include <brdebug.h>

Collaboration diagram for BRDebug:
Collaboration graph
[legend]

List of all members.

Classes

struct  BRDebugLocals_t

Public Types

enum  DebugTrace_e {
  TRACE_MEMORYLEAKS = 1, TRACE_REZLOAD = 2, TRACE_FILELOAD = 4, TRACE_WARNINGS = 8,
  TRACE_NETWORK = 0x10, TRACE_THEWORKS = 0x1F
}

Static Public Member Functions

static Word BURGER_ANSIAPI Fatal (const char *pFatalMsg,...)
 A fatal error has occured, print message, then exit.
static void BURGER_ANSIAPI NonFatal (const char *pMessage,...)
 Store a non-fatal error message, then return or exit.
static void BURGER_ANSIAPI SetErrorMsg (const char *pMessage,...)
 Update the current error message.
static BURGER_INLINE const char * GetErrorMsg (void)
 Get the pointer to the global error message buffer.
static BURGER_INLINE Word GetTraceFlag (void)
 Get the current debug tracing flag.
static BURGER_INLINE void SetTraceFlag (Word uNewFlag)
 Set the current debug tracing flag.
static BURGER_INLINE Word GetErrorBombFlag (void)
 Get the current flag to treat warnings as fatal errors.
static BURGER_INLINE void SetErrorBombFlag (Word uNewFlag)
 Set the current flag to treat warnings as fatal errors.

Static Private Attributes

static BRDebugLocals_t g_BRDebug

Member Enumeration Documentation

Enumerator:
TRACE_MEMORYLEAKS 

Test and display memory leaks.

TRACE_REZLOAD 

Print the name of a resource file being loaded.

TRACE_FILELOAD 

Print the name of a file being loaded.

TRACE_WARNINGS 

Print possible errors.

TRACE_NETWORK 

Print the network commands.

TRACE_THEWORKS 

GIMME everything!


Member Function Documentation

Word BURGER_ANSIAPI BRDebug::Fatal ( const char *  pFatalMsg,
  ... 
) [static]

A fatal error has occured, print message, then exit.

If the input message pointer is not NULL, then print the message string into the global error string buffer using printf() rules.

This message, if any, will be output through BRDebug::DebugXMessage() which either outputs it to a log file or a debugger's console (If a debugger is present and running).

    if (TestError) {
        BRDebug::Fatal("Fatal error, file %s was not found.",pFileName);
        return;
    }
Note:
This will call exit() with a default error code of 1. You must call BRSystem::SetErrorCode() to change the code to something else.

Secondly, this function won't return unless it was called while BRSystem::Shutdown(), then this function CAN return, so you must add a return statement after calling this function in the case that there is a recursion error in progress.

Parameters:
pFatalMsg Pointer to a string suitable for printf or NULL.
See also:
BRDebug::NonFatal
BRDebug::GetErrorBombFlag ( void   )  [inline, static]

Get the current flag to treat warnings as fatal errors.

When BRDebug::NonFatal is called, it will test the state of this boolean flag and if TRUE, it will abort code execution and exit immediately.

Returns:
TRUE if warnings are treated as errors, FALSE if not. (FALSE is default).
See also:
BRDebug::SetErrorBombFlag(Word)
BRDebug::GetErrorMsg ( void   )  [inline, static]

Get the pointer to the global error message buffer.

Calls to many functions that fail will update this buffer to return verbose output.

Note:
This buffer is modified by functions passing warnings and errors. Copy the string immediately and use the copy.
Do not attempt to modify the buffer the pointer points to.
Returns:
A pointer to a global static buffer.
See also:
BRDebug::SetErrorMsg(const char *,...)
BRDebug::GetTraceFlag ( void   )  [inline, static]

Get the current debug tracing flag.

Several subsystems perform diagnostic logging and this flag enables and/or disables that feature.

Returns:
The trace flag mask. Test against the BRDebug::DebugTrace_e enumerations.
See also:
BRDebug::SetTraceFlag(Word)
void BURGER_ANSIAPI BRDebug::NonFatal ( const char *  pMessage,
  ... 
) [static]

Store a non-fatal error message, then return or exit.

If the input message pointer is not NULL, then store the message string into the global error string buffer using printf() rules. If it's NULL, do nothing to the error message buffer.

If BRSystem::SetErrorCode() was called with TRUE, this function will then treat this warning as an error and call BRDebug::Fatal(const char *pFatalMsg,...) and exit.

    if (TestError) {
        BRDebug::NonFatal("Warning, file %s was not found.",pFileName);
        return;
    }
Note:
The standard behavior is to store the text string and immediately return. Only if an explicit call to BRSystem::SetErrorCode() setting it TRUE will change the operation of this procedure.
Parameters:
pMessage Pointer to a string suitable for printf or NULL.
See also:
BRDebug::Fatal(const char *pFatalMsg,...)
BRDebug::SetErrorBombFlag ( Word  uNewFlag  )  [inline, static]

Set the current flag to treat warnings as fatal errors.

When BRDebug::NonFatal is called, it will test the state of this boolean flag and if TRUE, it will abort code execution and exit immediately.

Parameters:
uNewFlag If non-zero, it will set the flag, zero will clear it.
See also:
BRDebug::GetErrorBombFlag()
void BURGER_ANSIAPI BRDebug::SetErrorMsg ( const char *  pMessage,
  ... 
) [static]

Update the current error message.

If the input message pointer is not NULL, then store the message string into the global error string buffer using printf() rules. If it's NULL, set the string to "".

Parameters:
pMessage Pointer to a string suitable for printf or NULL.
See also:
BRDebug::GetErrorMsg(), BRDebug::Fatal or BRDebug::NonFatal
BRDebug::SetTraceFlag ( Word  uNewFlag  )  [inline, static]

Set the current debug tracing flag.

Several subsystems perform diagnostic logging and this flag enables and/or disables that feature.

Parameters:
uNewFlag The trace flag mask. Generate it with BRDebug::DebugTrace_e enumerations.
See also:
BRDebug::GetTraceFlag()

Member Data Documentation