Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qdebug_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QDEBUG_P_H
5#define QDEBUG_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/private/qglobal_p.h>
19#include "QtCore/qdebug.h"
20#include "QtCore/qmetaobject.h"
21#include "QtCore/qflags.h"
22#include "QtCore/qbytearray.h"
23
25
26namespace QtDebugUtils {
27
28Q_CORE_EXPORT QByteArray toPrintable(const char *data, qint64 len, qsizetype maxSize);
29
30// inline helpers for formatting basic classes.
31
32template <class Point>
33static inline void formatQPoint(QDebug &debug, const Point &point)
34{
35 debug << point.x() << ',' << point.y();
36}
37
38template <class Size>
39static inline void formatQSize(QDebug &debug, const Size &size)
40{
41 debug << size.width() << ", " << size.height();
42}
43
44template <class Rect>
45static inline void formatQRect(QDebug &debug, const Rect &rect)
46{
47 debug << rect.x() << ',' << rect.y() << ' ' << rect.width() << 'x' << rect.height();
48}
49
50template <class Margins>
51static inline void formatQMargins(QDebug &debug, const Margins &margins)
52{
53 debug << margins.left() << ", " << margins.top() << ", " << margins.right()
54 << ", " << margins.bottom();
55}
56
57#ifndef QT_NO_QOBJECT
58template <class QEnum>
59static inline void formatQEnum(QDebug &debug, QEnum value)
60{
61 const QMetaObject *metaObject = qt_getEnumMetaObject(value);
62 const QMetaEnum me = metaObject->enumerator(metaObject->indexOfEnumerator(qt_getEnumName(value)));
63 if (const char *key = me.valueToKey(int(value)))
64 debug << key;
65 else
66 debug << int(value);
67}
68
69template <class QEnum>
70static inline void formatNonNullQEnum(QDebug &debug, const char *prefix, QEnum value)
71{
72 if (value) {
73 debug << prefix;
75 }
76}
77
78template <class Enum>
79static inline void formatQFlags(QDebug &debug, const QFlags<Enum> &value)
80{
81 const QMetaEnum me = QMetaEnum::fromType<QFlags<Enum>>();
82 const QDebugStateSaver saver(debug);
83 debug.noquote();
84 debug << me.valueToKeys(value.toInt());
85}
86
87template <class Enum>
88static inline void formatNonNullQFlags(QDebug &debug, const char *prefix, const QFlags<Enum> &value)
89{
90 if (value) {
91 debug << prefix;
93 }
94}
95
96#endif // !QT_NO_QOBJECT
97
98} // namespace QtDebugUtils
99
101
102#endif // QDEBUG_P_H
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore
const char * valueToKey(int value) const
Returns the string that is used as the name of the given enumeration value, or \nullptr if value is n...
QByteArray valueToKeys(int value) const
Returns a byte array of '|'-separated keys that represents the given value.
rect
[4]
Combined button and popup list for selecting options.
static void formatNonNullQEnum(QDebug &debug, const char *prefix, QEnum value)
Definition qdebug_p.h:70
static void formatQEnum(QDebug &debug, QEnum value)
Definition qdebug_p.h:59
static void formatQRect(QDebug &debug, const Rect &rect)
Definition qdebug_p.h:45
static void formatQMargins(QDebug &debug, const Margins &margins)
Definition qdebug_p.h:51
Q_CORE_EXPORT QByteArray toPrintable(const char *data, qint64 len, qsizetype maxSize)
Definition qdebug.cpp:24
static void formatQFlags(QDebug &debug, const QFlags< Enum > &value)
Definition qdebug_p.h:79
static void formatQSize(QDebug &debug, const Size &size)
Definition qdebug_p.h:39
static void formatQPoint(QDebug &debug, const Point &point)
Definition qdebug_p.h:33
static void formatNonNullQFlags(QDebug &debug, const char *prefix, const QFlags< Enum > &value)
Definition qdebug_p.h:88
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLuint64 key
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum GLsizei len
ptrdiff_t qsizetype
Definition qtypes.h:165
long long qint64
Definition qtypes.h:60
obj metaObject() -> className()
Definition parser.h:19
\inmodule QtCore