42 #define SF_DEBUG_LEVEL 1
46#define SF_RTTI_NAME(self) sf::demangleTypeName(typeid(self).name())
48#define SF_RTTI_FUNCTION SF_RTTI_TYPENAME.append("::").append(__FUNCTION__)
50#define SF_RTTI_TYPENAME SF_RTTI_NAME(*this)
52#define SF_FILENAME (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
57 #define SF_Q_RTTI_NAME(self) QString::fromStdString(SF_RTTI_NAME(self))
59 #define SF_Q_RTTI_TYPENAME SF_Q_RTTI_NAME(*this)
61inline QDebug&
operator<<(QDebug& qd,
const std::string& ss)
63 return qd << QString::fromStdString(ss);
79 static void enable(
bool enabled =
true);
85 static QtMessageHandler _initial;
93 static void _handler(QtMsgType type,
const QMessageLogContext& ctx,
const QString& msg);
194 static_assert(std::is_pointer_v<T>);
212 [[nodiscard]]
const char*
what() const noexcept
override
228 : std::ostringstream()
241#define DO_DEFAULT sf::dotDefault
242#define DO_COUT sf::dotStdOut
243#define DO_CLOG sf::dotStdLog
244#define DO_CERR sf::dotStdErr
245#define DO_MSGBOX sf::dotMessageBox
246#define DO_DBGSTR sf::dotDebugString
247#define DO_DBGBRK sf::dotDebugBreak
250#define SF_CLS_SEP ';'
254#if (SF_DEBUG_LEVEL == 1)
256 #define SF_NORM_NOTIFY(f, a) \
258 sf::debug_ostream(f) << a; \
261 #if defined(__clang__) || defined(__GNUC__)
262 #define SF_FUNC_NOTIFY(f, a) \
264 sf::debug_ostream(f) << __PRETTY_FUNCTION__ << ' ' << a; \
267 #define SF_FUNC_NOTIFY(f, a) \
269 sf::debug_ostream(f) << __FUNCTION__ << "() " << a; \
272 #define SF_RTTI_NOTIFY(f, a) \
274 sf::debug_ostream(f) << SF_RTTI_TYPENAME << "::" << __FUNCTION__ << SF_CLS_SEP << " " << a; \
276 #define SF_COND_NORM_NOTIFY(p, f, a) \
280 SF_NORM_NOTIFY(f, a); \
283 #define SF_COND_FUNC_NOTIFY(p, f, a) \
287 SF_FUNC_NOTIFY(f, a); \
290 #define SF_COND_RTTI_NOTIFY(p, f, a) \
294 SF_RTTI_NOTIFY(f, a); \
298 #define SF_Q_NOTIFY(a) \
304#elif (SF_DEBUG_LEVEL == 2)
306 #define _NORM_NOTIFY(f, a) \
308 sf::debug_ostream(f) << __FUNCTION__ << ' ' << __FILENAME__ << ':' << __LINE__ << '@' << '\t' << a; \
311 #if defined(__clang__) || defined(__GNUC__)
312 #define SF_FUNC_NOTIFY(f, a) \
314 sf::debug_ostream(f) << __PRETTY_FUNCTION__ << ' ' << __FILENAME__ << ':' << __LINE__ << '@' << '\t' << a; \
317 #define SF_FUNC_NOTIFY(f, a) \
319 sf::debug_ostream(f) << __FUNCTION__ << "() " << __FILENAME__ << ':' << __LINE__ << '@' << '\t' << a; \
322 #define _RTTI_NOTIFY(f, a) \
324 sf::debug_ostream(f) << _RTTI_TYPENAME << "::" << __FUNCTION__ << ' ' << SF_CLS_SEP << __FILENAME__ << ':' << __LINE__ << '@' << '\t' << a; \
326 #define _COND_NORM_NOTIFY(p, f, a) \
330 _NORM_NOTIFY(f, a); \
333 #define _COND_FUNC_NOTIFY(p, f, a) \
337 _FUNC_NOTIFY(f, a); \
340 #define _COND_RTTI_NOTIFY(p, f, a) \
344 _RTTI_NOTIFY(f, a); \
348 #define SF_Q_NOTIFY(a) \
356 #define _NORM_NOTIFY(f, a) {}
357 #define _FUNC_NOTIFY(f, a) {}
358 #define _RTTI_NOTIFY(f, a) {}
359 #define _COND_NOTIFY(p, f, a) {}
360 #define _COND_FUNC_NOTIFY(p, f, a) {}
361 #define _COND_RTTI_NOTIFY(p, f, a) {}
363 #define SF_Q_NOTIFY(a) {}
std::ostream & operator<<(std::ostream &os, const sf::TimeSpec &ts)
Operator for writing the sf::TimeSpec to an output-stream.
Definition TimeSpec.h:393
Debug output stream.
Definition dbgutils.h:225
debug_ostream(int type)
Definition dbgutils.h:227
~debug_ostream() override
Definition dbgutils.h:206
notify_exception(std::string s)
Definition dbgutils.h:208
const char * what() const noexcept override
Definition dbgutils.h:212
#define _MISC_FUNC
Definition misc/global.h:39
#define _MISC_CLASS
Definition misc/global.h:40
Definition Application.h:10
_MISC_FUNC void debugBreak()
Causes a break when debugging.
_MISC_FUNC bool isDebuggerActive()
Gets the debugger active status.
std::string getTypeName(const T ptr)
Get the demangled type name of the passed pointer type.
Definition dbgutils.h:191
_MISC_FUNC void SetDefaultDebugOutput(unsigned int type)
Set and get function for the type of output when DO_DEFAULT is passed.
_MISC_FUNC bool isDebug()
Gets the debug status.
_MISC_FUNC void printBacktrace(std::ostream &os)
Prints the backtrace to a stream.
_MISC_FUNC std::string getBacktrace()
Prints the backtrace to a stream.
EDebugOutputType
Definition dbgutils.h:106
@ dotStdErr
Definition dbgutils.h:116
@ dotDefault
Definition dbgutils.h:122
@ dotDebugBreak
Definition dbgutils.h:120
@ dotMessageBox
Definition dbgutils.h:110
@ dotStdOut
Definition dbgutils.h:114
@ dotStdLog
Definition dbgutils.h:112
@ dotThrow
Definition dbgutils.h:108
@ dotDebugString
Definition dbgutils.h:118
_MISC_FUNC unsigned int GetDefaultDebugOutput()
Returns the combination of EDebugOutputType which is the default output.
_MISC_FUNC void UserOutputDebugString(unsigned int type, const char *str) noexcept
Allows the passed string to be presented in various ways.
_MISC_FUNC void freeConsole(bool always=false)
Closes the console window.
_MISC_FUNC std::string demangleTypeName(const char *name)
Demangle the passed rtti mangled type name.