diff options
Diffstat (limited to 'src/corelib/io/qdebug.h')
-rw-r--r-- | src/corelib/io/qdebug.h | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 421c5d933b..e14d31f38a 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -111,10 +111,10 @@ class Q_CORE_EXPORT QDebug void putString(const QChar *begin, size_t length); void putByteArray(const char *begin, size_t length, Latin1Content content); public: - inline QDebug(QIODevice *device) : stream(new Stream(device)) {} - inline QDebug(QString *string) : stream(new Stream(string)) {} - inline QDebug(QtMsgType t) : stream(new Stream(t)) {} - inline QDebug(const QDebug &o):stream(o.stream) { ++stream->ref; } + explicit QDebug(QIODevice *device) : stream(new Stream(device)) {} + explicit QDebug(QString *string) : stream(new Stream(string)) {} + explicit QDebug(QtMsgType t) : stream(new Stream(t)) {} + QDebug(const QDebug &o) : stream(o.stream) { ++stream->ref; } QDebug(QDebug &&other) noexcept : stream{qExchange(other.stream, nullptr)} {} inline QDebug &operator=(const QDebug &other); QDebug &operator=(QDebug &&other) noexcept @@ -173,6 +173,24 @@ public: inline QDebug &operator<<(QTextStreamManipulator m) { stream->ts << m; return *this; } + + template <typename T> + static QString toString(const T &object) + { + QString buffer; + QDebug stream(&buffer); + stream.nospace() << object; + return buffer; + } + + template <typename T> + static QString toString(const T *object) + { + QString buffer; + QDebug stream(&buffer); + stream.nospace() << object; + return buffer; + } }; Q_DECLARE_SHARED(QDebug) @@ -234,12 +252,6 @@ inline QDebug printSequentialContainer(QDebug debug, const char *which, const Se } // namespace QtPrivate -template <class T> -inline QDebug operator<<(QDebug debug, const QList<T> &list) -{ - return QtPrivate::printSequentialContainer(debug, "" /*for historical reasons*/, list); -} - template <typename T> inline QDebug operator<<(QDebug debug, const QVector<T> &vec) { |