![]() |
Qt 6.x
The Qt SDK
|
#include <QtCore/qglobal.h>
#include <QtQuick3DUtils/private/qtquick3dutilsexports_p.h>
Go to the source code of this file.
Macros | |
#define | QSSG_ASSERT_STRINGIFY_HELPER(x) #x |
#define | QSSG_ASSERT_STRINGIFY(x) QSSG_ASSERT_STRINGIFY_HELPER(x) |
#define | QSSG_ASSERT_STRING_X(msg) QT_PREPEND_NAMESPACE(qssgWriteAssertLocation)(msg) |
#define | QSSG_ASSERT_STRING(cond) |
#define | QSSG_ASSERT(cond, action) if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING(#cond); action; } do {} while (0) |
#define | QSSG_ASSERT_X(cond, msg, action) if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING_X(msg); action; } do {} while (0) |
#define | QSSG_CHECK(cond) if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING(#cond); } do {} while (0) |
#define | QSSG_CHECK_X(cond, msg) if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING_X(msg); } do {} while (0) |
#define | QSSG_GUARD(cond) ((Q_LIKELY(cond)) ? true : (QSSG_ASSERT_STRING(#cond), false)) |
#define | QSSG_GUARD_X(cond, msg) ((Q_LIKELY(cond)) ? true : (QSSG_ASSERT_STRING_X(msg), false)) |
Functions | |
QT_BEGIN_NAMESPACE Q_QUICK3DUTILS_PRIVATE_EXPORT void | qssgWriteAssertLocation (const char *msg) |
Collection of assert checks that causes a soft or hard assert depending on the build. | |
#define QSSG_ASSERT | ( | cond, | |
action | |||
) | if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING(#cond); action; } do {} while (0) |
Definition at line 36 of file qssgassert_p.h.
#define QSSG_ASSERT_STRING | ( | cond | ) |
Definition at line 30 of file qssgassert_p.h.
#define QSSG_ASSERT_STRING_X | ( | msg | ) | QT_PREPEND_NAMESPACE(qssgWriteAssertLocation)(msg) |
Definition at line 29 of file qssgassert_p.h.
#define QSSG_ASSERT_STRINGIFY | ( | x | ) | QSSG_ASSERT_STRINGIFY_HELPER(x) |
Definition at line 28 of file qssgassert_p.h.
Definition at line 27 of file qssgassert_p.h.
#define QSSG_ASSERT_X | ( | cond, | |
msg, | |||
action | |||
) | if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING_X(msg); action; } do {} while (0) |
Definition at line 37 of file qssgassert_p.h.
#define QSSG_CHECK | ( | cond | ) | if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING(#cond); } do {} while (0) |
Definition at line 38 of file qssgassert_p.h.
#define QSSG_CHECK_X | ( | cond, | |
msg | |||
) | if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING_X(msg); } do {} while (0) |
Definition at line 39 of file qssgassert_p.h.
#define QSSG_GUARD | ( | cond | ) | ((Q_LIKELY(cond)) ? true : (QSSG_ASSERT_STRING(#cond), false)) |
Definition at line 40 of file qssgassert_p.h.
#define QSSG_GUARD_X | ( | cond, | |
msg | |||
) | ((Q_LIKELY(cond)) ? true : (QSSG_ASSERT_STRING_X(msg), false)) |
Definition at line 41 of file qssgassert_p.h.
QT_BEGIN_NAMESPACE Q_QUICK3DUTILS_PRIVATE_EXPORT void qssgWriteAssertLocation | ( | const char * | msg | ) |
Collection of assert checks that causes a soft or hard assert depending on the build.
Unlike Q_ASSERT(), which is a no-op for non-debug build, QSSG_ASSERT() etc., will print a warning in non-developer builds (soft assert) or terminate on developer-build (hard assert).
\macro QSSG_ASSERT(condition, action)
The assert will be fatal in developer builds if condition is not met. In non-developer builds the assert is "soft" and will instead print a warning with the reason and location of the assert before execution action. The action can be for example be: return
, break
or continue
.
For example, writing:
\badcode QSSG_ASSERT(ptr != nullptr, return);
other actions are of course possible, e.g., in a loop it might be better to do:
\badcode QSSG_ASSERT(ptr != nullptr, continue);
is the equivalent to:
\badcode Q_ASSERT(ptr != nullptr); if (ptr != nullptr) { qWarning() << "Something unexpected here, proceeding will be fatal!"; return; }
\macro QSSG_ASSERT_X(condition, message, action)
Same as \l QSSG_ASSERT() but with a custom message that will be print if condition is not met.
\macro QSSG_CHECK(condition)
Similar to \l QSSG_ASSERT but without an action. Convenient when the condition is expected to be valid, but it's not immediately fatal if the current code path continues.
\badcode QSSG_CHECK(ptr != nullptr);
is the equivalent to:
\badcode Q_ASSERT(ptr != nullptr); if (ptr != nullptr) qWarning() << "Something unexpected here, will probably not work as expected!";
\macro QSSG_CHECK_X(condition, message)
Same as \l QSSG_CHECK() but with a custom message that will be print if condition is not met.
\macro QSSG_GUARD(condition)
Check that returns the result of condition. As with the other assert functions, a call to QSSG_GUARD, when condition is not met, is fatal for developer builds.
\badcode
if (QSSG_GUARD(ptr != nullptr)) { ... // OK } else { ... // We shouldn't be here! }
is the equivalent to:
\badcode if (ptr != nullptr) { ... // OK } else { Q_ASSERT(ptr != nullptr); qWarning() << "Something unexpected here!"; }
\macro QSSG_GUARD_X(condition, message)
Same as \l QSSG_GUARD() but with a custom message that will be print if condition is not met.
Definition at line 119 of file qssgassert.cpp.