summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qdebug.h
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-02-17 11:25:36 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-02-26 12:16:51 +0000
commitcd46d94906ec0d10acd0fcb086d9177a1b282691 (patch)
treef8f4818e568a09d164ecc591732321056be73f8b /src/corelib/io/qdebug.h
parent9608629d7ee42dd65437d2e7fad5c91438d7de4b (diff)
Output registered enums in qDebug operator for QFlags.
Change-Id: Ia424df234fbd333782c10f0a4422875bb1bfc1f5 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/io/qdebug.h')
-rw-r--r--src/corelib/io/qdebug.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h
index 435e7450c7..7f1cb82f3a 100644
--- a/src/corelib/io/qdebug.h
+++ b/src/corelib/io/qdebug.h
@@ -263,6 +263,7 @@ inline QDebug operator<<(QDebug debug, const QContiguousCache<T> &cache)
#ifndef QT_NO_QOBJECT
Q_CORE_EXPORT QDebug qt_QMetaEnum_debugOperator(QDebug&, int value, const QMetaObject *meta, const char *name);
+Q_CORE_EXPORT QDebug qt_QMetaEnum_flagDebugOperator(QDebug &dbg, quint64 value, const QMetaObject *meta, const char *name);
template<typename T>
typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, QDebug>::Type
@@ -272,10 +273,21 @@ operator<<(QDebug dbg, T value)
const char *name = qt_getEnumName(value);
return qt_QMetaEnum_debugOperator(dbg, typename QFlags<T>::Int(value), obj, name);
}
-#endif
template <class T>
+inline typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, QDebug>::Type operator<<(QDebug debug, const QFlags<T> &flags)
+{
+ const QMetaObject *obj = qt_getEnumMetaObject(T());
+ const char *name = qt_getEnumName(T());
+ return qt_QMetaEnum_flagDebugOperator(debug, quint64(flags), obj, name);
+}
+
+template <class T>
+inline typename QtPrivate::QEnableIf<!QtPrivate::IsQEnumHelper<T>::Value, QDebug>::Type operator<<(QDebug debug, const QFlags<T> &flags)
+#else // !QT_NO_QOBJECT
+template <class T>
inline QDebug operator<<(QDebug debug, const QFlags<T> &flags)
+#endif
{
QDebugStateSaver saver(debug);
debug.resetFormat();