Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qssgassert_p.h
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5
6#ifndef QSSGASSERT_P_H
7#define QSSGASSERT_P_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is not part of the Qt API. It exists purely as an
14// implementation detail. This header file may change from version to
15// version without notice, or even be removed.
16//
17// We mean it.
18//
19
20#include <QtCore/qglobal.h>
21#include <QtQuick3DUtils/qtquick3dutilsexports.h>
22
23QT_BEGIN_NAMESPACE
24
25Q_QUICK3DUTILS_EXPORT void qssgWriteAssertLocation(const char *msg);
26
27QT_END_NAMESPACE
28
29#ifdef QT_DEBUG
30#define QSSG_DEBUG_COND(cond) (cond)
31#else
32#define QSSG_DEBUG_COND(cond) (true || (cond))
33#endif // QT_DEBUG
34
35#define QSSG_ASSERT_STRINGIFY_HELPER(x) #x
36#define QSSG_ASSERT_STRINGIFY(x) QSSG_ASSERT_STRINGIFY_HELPER(x)
37#define QSSG_ASSERT_STRING_X(msg) QT_PREPEND_NAMESPACE(qssgWriteAssertLocation)(msg)
38#define QSSG_ASSERT_STRING(cond) QSSG_ASSERT_STRING_X(
39 "\"" cond"\" in file " __FILE__ ", line " QSSG_ASSERT_STRINGIFY(__LINE__))
40
41// The 'do {...} while (0)' idiom is not used for the main block here to be
42// able to use 'break' and 'continue' as 'actions'.
43
44#define QSSG_ASSERT(cond, action) if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING(#cond); action; } do {} while (0)
45#define QSSG_ASSERT_X(cond, msg, action) if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING_X(msg); action; } do {} while (0)
46#define QSSG_CHECK(cond) if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING(#cond); } do {} while (0)
47#define QSSG_CHECK_X(cond, msg) if (Q_LIKELY(cond)) {} else { QSSG_ASSERT_STRING_X(msg); } do {} while (0)
48#define QSSG_GUARD(cond) ((Q_LIKELY(cond)) ? true : (QSSG_ASSERT_STRING(#cond), false))
49#define QSSG_GUARD_X(cond, msg) ((Q_LIKELY(cond)) ? true : (QSSG_ASSERT_STRING_X(msg), false))
50
51#endif // QSSGASSERT_P_H
Combined button and popup list for selecting options.
QT_BEGIN_NAMESPACE void qssgWriteAssertLocation(const char *msg)
Collection of assert checks that causes a soft or hard assert depending on the build.
#define QSSG_ASSERT_STRING_X(msg)
#define QSSG_ASSERT_STRINGIFY(x)
#define QSSG_ASSERT_STRINGIFY_HELPER(x)
#define QSSG_ASSERT_STRING(cond)