summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qdebug.cpp28
-rw-r--r--src/corelib/io/qdebug.h13
2 files changed, 37 insertions, 4 deletions
diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp
index b0ee715c75..f55f68f9b3 100644
--- a/src/corelib/io/qdebug.cpp
+++ b/src/corelib/io/qdebug.cpp
@@ -40,6 +40,7 @@
#endif
#include "qdebug.h"
+#include "qmetaobject.h"
#include <private/qtextstream_p.h>
#include <private/qtools_p.h>
@@ -284,12 +285,12 @@ void QDebug::putString(const QChar *begin, size_t length)
if (stream->testFlag(Stream::NoQuotes)) {
// no quotes, write the string directly too (no pretty-printing)
// this respects the QTextStream state, though
- stream->ts.d_ptr->putString(begin, length);
+ stream->ts.d_ptr->putString(begin, int(length));
} else {
// we'll reset the QTextStream formatting mechanisms, so save the state
QDebugStateSaver saver(*this);
stream->ts.d_ptr->params.reset();
- putEscapedString(stream->ts.d_ptr.data(), reinterpret_cast<const ushort *>(begin), length);
+ putEscapedString(stream->ts.d_ptr.data(), reinterpret_cast<const ushort *>(begin), int(length));
}
}
@@ -302,14 +303,14 @@ void QDebug::putByteArray(const char *begin, size_t length, Latin1Content conten
if (stream->testFlag(Stream::NoQuotes)) {
// no quotes, write the string directly too (no pretty-printing)
// this respects the QTextStream state, though
- QString string = content == ContainsLatin1 ? QString::fromLatin1(begin, length) : QString::fromUtf8(begin, length);
+ QString string = content == ContainsLatin1 ? QString::fromLatin1(begin, int(length)) : QString::fromUtf8(begin, int(length));
stream->ts.d_ptr->putString(string);
} else {
// we'll reset the QTextStream formatting mechanisms, so save the state
QDebugStateSaver saver(*this);
stream->ts.d_ptr->params.reset();
putEscapedString(stream->ts.d_ptr.data(), reinterpret_cast<const uchar *>(begin),
- length, content == ContainsLatin1);
+ int(length), content == ContainsLatin1);
}
}
@@ -643,4 +644,23 @@ QDebugStateSaver::~QDebugStateSaver()
d->restoreState();
}
+#ifndef QT_NO_QOBJECT
+/*!
+ \internal
+ */
+QDebug qt_QMetaEnum_debugOperator(QDebug &dbg, int value, const QMetaObject *meta, const char *name)
+{
+ QDebugStateSaver saver(dbg);
+ QMetaEnum me = meta->enumerator(meta->indexOfEnumerator(name));
+ const char *key = me.valueToKey(value);
+ dbg.nospace() << meta->className() << "::" << name << '(';
+ if (key)
+ dbg << key;
+ else
+ dbg << value;
+ dbg << ')';
+ return dbg;
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h
index 56a5e1fa74..435e7450c7 100644
--- a/src/corelib/io/qdebug.h
+++ b/src/corelib/io/qdebug.h
@@ -261,6 +261,19 @@ inline QDebug operator<<(QDebug debug, const QContiguousCache<T> &cache)
return debug.maybeSpace();
}
+#ifndef QT_NO_QOBJECT
+Q_CORE_EXPORT QDebug qt_QMetaEnum_debugOperator(QDebug&, int value, const QMetaObject *meta, const char *name);
+
+template<typename T>
+typename QtPrivate::QEnableIf<QtPrivate::IsQEnumHelper<T>::Value, QDebug>::Type
+operator<<(QDebug dbg, T value)
+{
+ const QMetaObject *obj = qt_getEnumMetaObject(value);
+ const char *name = qt_getEnumName(value);
+ return qt_QMetaEnum_debugOperator(dbg, typename QFlags<T>::Int(value), obj, name);
+}
+#endif
+
template <class T>
inline QDebug operator<<(QDebug debug, const QFlags<T> &flags)
{