wavelength 1.0.0
Loading...
Searching...
No Matches
Debug.h
Go to the documentation of this file.
1#pragma once
2
3#include "utl/FileStream.h"
4#include "utl/PrnStream.h"
5
15typedef void (*ModalCallbackFunc)(int &type, const char *message);
16
23class Debug : public PrnStream {
24public:
31
38
44 virtual ~Debug();
45
53 virtual void Print(const char *str);
54
63 void Fail(const char *fmt, ...);
64
71 void Notify(const char *fmt, ...);
72
81 void Modal(int type, const char *message);
82
91 void StartLog(const char *file);
92
98 void StopLog();
99
100 bool mFailing;
102 bool mEnabled;
104 ModalCallbackFunc mModalCallback;
105};
106
112extern Debug TheDebug;
113
122void DebugPrint(const char *fmt, ...);
123
129#define ASSERT(cond) \
130 do { \
131 if (!(cond)) { \
132 TheDebug.Fail("File: %s Line: %d Error: %s\n", __FILE__, __LINE__, #cond); \
133 } \
134 } while (false)
135
143#define ASSERT_RANGE(x, low, high) ASSERT((low) <= (x) && (x) < (high))
void(* ModalCallbackFunc)(int &type, const char *message)
Handler that replaces the message box of Debug::Modal().
Definition Debug.h:15
void DebugPrint(const char *fmt,...)
Format a diagnostic message that this build discards.
Stream for diagnostic text, written to standard output or to a log file.
Definition debug.h:18
void StopLog()
Close the log.
bool mFailing
Definition Debug.h:100
virtual ~Debug()
Close the log.
bool mThrowOnFail
Definition Debug.h:101
ModalType
Kinds of message Modal() shows.
Definition Debug.h:26
@ kModalNotify
Definition Debug.h:28
@ kModalCancelable
Definition Debug.h:29
@ kModalFail
Definition Debug.h:27
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.
Debug()
Create the stream with output enabled and no log.
void StartLog(const char *file)
Close any log and open a new one.
virtual void Print(const char *str)
Write text to the log, converting each line feed to a carriage return and a line feed,...
void Fail(const char *fmt,...)
Report a failure and exit, or throw the message when mThrowOnFail is set.
BinStream that reads or writes a file.
Definition filestream.h:14
Text output stream.
Definition prnstream.h:16
Debug TheDebug
The diagnostic stream.