summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qdebug.h
diff options
context:
space:
mode:
authorHarald Fernengel <harald.fernengel@nokia.com>2010-05-21 14:14:38 (GMT)
committerHarald Fernengel <harald.fernengel@nokia.com>2010-05-21 14:14:38 (GMT)
commite06bc69870d1ef79466557dd716ec1edb0e48fee (patch)
tree763391df7e0b45f097530cb6496f58e029f91e6c /src/corelib/io/qdebug.h
parent634e3646cfbc53e85b66b42d2a75fb1fd4dab164 (diff)
downloadQt-e06bc69870d1ef79466557dd716ec1edb0e48fee.zip
Qt-e06bc69870d1ef79466557dd716ec1edb0e48fee.tar.gz
Qt-e06bc69870d1ef79466557dd716ec1edb0e48fee.tar.bz2
QDebug operator for QFlags
Output the flags one by one instead of just an integer Reviewed-by: Robert Griebl
Diffstat (limited to 'src/corelib/io/qdebug.h')
-rw-r--r--src/corelib/io/qdebug.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h
index bc68599..093312f 100644
--- a/src/corelib/io/qdebug.h
+++ b/src/corelib/io/qdebug.h
@@ -254,6 +254,29 @@ inline QDebug operator<<(QDebug debug, const QContiguousCache<T> &cache)
return debug.space();
}
+#if defined(FORCE_UREF)
+template <class T>
+inline QDebug &operator<<(QDebug debug, const QFlags<T> &flags)
+#else
+template <class T>
+inline QDebug operator<<(QDebug debug, const QFlags<T> &flags)
+#endif
+{
+ debug.nospace() << "QFlags(";
+ bool needSeparator = false;
+ for (uint i = 0; i < sizeof(T) * 8; ++i) {
+ if (flags.testFlag(T(1 << i))) {
+ if (needSeparator)
+ debug.nospace() << '|';
+ else
+ needSeparator = true;
+ debug.nospace() << "0x" << QByteArray::number(T(1 << i), 16).constData();
+ }
+ }
+ debug << ')';
+ return debug.space();
+}
+
#if !defined(QT_NO_DEBUG_STREAM)
Q_CORE_EXPORT_INLINE QDebug qDebug() { return QDebug(QtDebugMsg); }