diff options
author | Karsten Heimrich <karsten.heimrich@qt.io> | 2020-11-03 15:03:57 +0100 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@qt.io> | 2020-11-07 09:35:11 +0100 |
commit | e9b92c926d56261cb0c78b5413b1132200efc4a8 (patch) | |
tree | 3695a374d56e6227952ffc4d5b9c84aec3762e99 /src/corelib/io | |
parent | 7cad91a7df03d0683c81519ae6839c5f546cfceb (diff) |
QDebug: add op<<(QUtf8StringView)
[ChangeLog][QtCore][QDebug] Added streaming of QUtf8StringViews.
Task-number: QTBUG-88029
Change-Id: Ifcb001cfebddd79ce1cdbfef5bcc19f7c56679ec
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qdebug.cpp | 17 | ||||
-rw-r--r-- | src/corelib/io/qdebug.h | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/src/corelib/io/qdebug.cpp b/src/corelib/io/qdebug.cpp index 28d8548300..b1ebf097cf 100644 --- a/src/corelib/io/qdebug.cpp +++ b/src/corelib/io/qdebug.cpp @@ -663,6 +663,23 @@ QDebug &QDebug::resetFormat() */ /*! + \since 6.0 + \fn QDebug &QDebug::operator<<(QUtf8StringView s) + + Writes the string view, \a s, to the stream and returns a reference to the + stream. + + Normally, QDebug prints the data inside quotes and transforms control or + non-US-ASCII characters to their C escape sequences (\\xAB). This way, the + output is always 7-bit clean and the string can be copied from the output + and pasted back into C++ sources, if necessary. + + To print non-printable characters without transformation, enable the + noquote() functionality. Note that some QDebug backends might not be 8-bit + clean. +*/ + +/*! \fn QDebug &QDebug::operator<<(QLatin1String t) Writes the string, \a t, to the stream and returns a reference to the diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index d127d82711..f730346748 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -144,6 +144,7 @@ public: inline QDebug &operator<<(const QString & t) { putString(t.constData(), uint(t.length())); return maybeSpace(); } #endif inline QDebug &operator<<(QStringView s) { putString(s.data(), size_t(s.size())); return maybeSpace(); } + inline QDebug &operator<<(QUtf8StringView s) { putByteArray(s.data(), s.size(), ContainsBinary); return maybeSpace(); } inline QDebug &operator<<(QLatin1String t) { putByteArray(t.latin1(), t.size(), ContainsLatin1); return maybeSpace(); } inline QDebug &operator<<(const QByteArray & t) { putByteArray(t.constData(), t.size(), ContainsBinary); return maybeSpace(); } inline QDebug &operator<<(QByteArrayView t) { putByteArray(t.constData(), t.size(), ContainsBinary); return maybeSpace(); } |