wavelength 1.0.0
Loading...
Searching...
No Matches
Debug Class Reference

Stream for diagnostic text, written to standard output or to a log file. More...

#include <debug.h>

Inheritance diagram for Debug:
Collaboration diagram for Debug:

Public Types

enum  ModalType { kModalFail = 0 , kModalNotify = 1 , kModalCancelable = 2 }
 Kinds of message Modal() shows. More...
typedef void(* ModalCallback) (int *pState, const char *pszMessage)
 Routine that shows a message on the screen and waits for the player.

Public Member Functions

 Debug ()
 Construct an enabled stream with no log file.
 ~Debug () override
 Close the log file and release the stream.
void Print (const char *pszText) override
 Write diagnostic text, to the log file with each newline as a carriage return and a line feed, or to standard output.
void OpenLog (const char *pszFile)
 Write the text to a log file from now on, replacing any log file.
void CloseLog ()
 Close the log file, if any.
void SetModalCallback (ModalCallback pfnCallback)
 Set the routine that shows a message on the screen.
ModalCallback GetModalCallback () const
 Debug ()
 Create the stream with output enabled and no log.
virtual ~Debug ()
 Close the log.
virtual void Print (const char *str)
 Write text to the log, converting each line feed to a carriage return and a line feed, or to the console and the debugger when no log is open.
void Fail (const char *fmt,...)
 Report a failure and exit, or throw the message when mThrowOnFail is set.
void Notify (const char *fmt,...)
 Show a notice.
void Modal (int type, const char *message)
 Show a message through mModalCallback or a message box, and exit when the message remains a failure.
void StartLog (const char *file)
 Close any log and open a new one.
void StopLog ()
 Close the log.
Public Member Functions inherited from PrnStream
 PrnStream ()
 Construct a stream with a dump level of 0.
virtual ~PrnStream ()
 Release the stream.
void Printf (const char *pszFormat,...)
 Format text into the shared format buffer and write the result through Print().
PrnStream & operator<< (const char *pszText)
 Write text.
PrnStream & operator<< (char ch)
 Write a character.
PrnStream & operator<< (short nValue)
 Write a short integer in decimal.
PrnStream & operator<< (int nValue)
 Write an integer in decimal.
PrnStream & operator<< (unsigned char nValue)
 Write a byte as an unsigned integer in decimal.
PrnStream & operator<< (unsigned short nValue)
 Write an unsigned short integer in decimal.
PrnStream & operator<< (unsigned int nValue)
 Write an unsigned integer in decimal.
PrnStream & operator<< (unsigned long long nValue)
 Write an unsigned 64-bit number in decimal.
PrnStream & operator<< (float fValue)
 Write a number with two decimals.
PrnStream & operator<< (bool bValue)
 Write true or false.
void Space (int nCount)
 Write a number of spaces, one Print() call each.
int GetDumpLevel () const
 PrnStream ()
virtual ~PrnStream ()
 Destroy the stream.
void Printf (const char *format,...)
 Format text with printf() conventions and write it.
PrnStream & operator<< (char c)
 Write a character.
PrnStream & operator<< (int i)
 Write an integer in decimal.
PrnStream & operator<< (float f)
 Write a number with two decimal places.
PrnStream & operator<< (const char *str)
 Write text.
void Space (int count)
 Write spaces.

Public Attributes

bool mFailing
bool mThrowOnFail
bool mEnabled
FileStream * mLog
ModalCallbackFunc mModalCallback

Detailed Description

Stream for diagnostic text, written to standard output or to a log file.

Stream for diagnostic text and failure reports.

The RTTI records the class as deriving from PrnStream, and the vtable is at 0x003d68c8. The object is 0x1c bytes.

The RTTI records the class as deriving from PrnStream. The object is 0x14 bytes. Text goes to the log file when one is open, and otherwise to the console and the debugger.

Member Typedef Documentation

◆ ModalCallback

typedef void(* Debug::ModalCallback) (int *pState, const char *pszMessage)

Routine that shows a message on the screen and waits for the player.

The state is the caller's. A state of 2 is cleared when the player presses the button that dismisses the message.

Parameters
pStateThe caller's state.
pszMessageThe message.

Member Enumeration Documentation

◆ ModalType

Kinds of message Modal() shows.

Enumerator
kModalFail 

A failure. The program exits after the message.

kModalNotify 

A notice the user acknowledges.

kModalCancelable 

A notice the user may turn into a failure with Cancel.

Constructor & Destructor Documentation

◆ Debug() [1/2]

Debug::Debug ( )

Construct an enabled stream with no log file.

Ghidra address:
NTSC-U/C: 0x00289020
Ghidra address:
PAL: 0x00292818

◆ ~Debug() [1/2]

Debug::~Debug ( )
override

Close the log file and release the stream.

Ghidra address:
NTSC-U/C: 0x00289050
Ghidra address:
PAL: 0x00292848

◆ Debug() [2/2]

Debug::Debug ( )

Create the stream with output enabled and no log.

Ghidra address:
0x1000a5b0

◆ ~Debug() [2/2]

virtual Debug::~Debug ( )
virtual

Close the log.

Ghidra address:
0x1000a5f0

Member Function Documentation

◆ Print() [1/2]

void Debug::Print ( const char * pszText)
overridevirtual

Write diagnostic text, to the log file with each newline as a carriage return and a line feed, or to standard output.

A disabled stream writes nothing.

Parameters
pszTextThe text.
Ghidra address:
NTSC-U/C: 0x00288e60
Ghidra address:
PAL: 0x00292678

Implements PrnStream.

◆ OpenLog()

void Debug::OpenLog ( const char * pszFile)

Write the text to a log file from now on, replacing any log file.

A file that cannot be opened reports a notice and leaves no log file.

The name is inferred.

Parameters
pszFileThe file.
Ghidra address:
NTSC-U/C: 0x00288f38

◆ CloseLog()

void Debug::CloseLog ( )

Close the log file, if any.

The name is inferred.

Ghidra address:
NTSC-U/C: 0x00288fd8
Ghidra address:
PAL: 0x002927c8

◆ SetModalCallback()

void Debug::SetModalCallback ( ModalCallback pfnCallback)
inline

Set the routine that shows a message on the screen.

Parameters
pfnCallbackThe routine the renderer installs, or null.

◆ GetModalCallback()

ModalCallback Debug::GetModalCallback ( ) const
inline
Returns
The routine that shows a message on the screen, or null.

◆ Print() [2/2]

virtual void Debug::Print ( const char * str)
virtual

Write text to the log, converting each line feed to a carriage return and a line feed, or to the console and the debugger when no log is open.

Parameters
strThe text.
Ghidra address:
0x1000a440

Implements PrnStream.

◆ Fail()

void Debug::Fail ( const char * fmt,
... )

Report a failure and exit, or throw the message when mThrowOnFail is set.

A failure while one is being reported is ignored.

Parameters
fmtThe printf format.
Ghidra address:
0x1000a310

◆ Notify()

void Debug::Notify ( const char * fmt,
... )

Show a notice.

Parameters
fmtThe printf format.
Ghidra address:
0x1000a2f0

◆ Modal()

void Debug::Modal ( int type,
const char * message )

Show a message through mModalCallback or a message box, and exit when the message remains a failure.

Parameters
typeThe kind of message, one of ModalType.
messageThe text.
Ghidra address:
0x1000a360

◆ StartLog()

void Debug::StartLog ( const char * file)

Close any log and open a new one.

When the file does not open, the stream reports it and continues without a log.

Parameters
fileThe path of the log.
Ghidra address:
0x1000a4b0

◆ StopLog()

void Debug::StopLog ( )

Close the log.

Ghidra address:
0x1000a550

Member Data Documentation

◆ mFailing

bool Debug::mFailing

Whether a failure is being reported.

◆ mThrowOnFail

bool Debug::mThrowOnFail

Whether Fail() throws the message instead of exiting.

◆ mEnabled

bool Debug::mEnabled

Whether Print() writes anything.

◆ mLog

FileStream* Debug::mLog

The log, or null.

◆ mModalCallback

ModalCallbackFunc Debug::mModalCallback

The handler of Modal(), or null for message boxes.


The documentation for this class was generated from the following files: