diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-11-18 14:32:38 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-01-11 03:40:38 +0100 |
commit | 2c01d402e19b6137cf24794cbc4533a2b8b2d816 (patch) | |
tree | d0c0aaa93128a007b604fa3fcd25b8d9c5008723 /src/corelib/io/qdebug.h | |
parent | e00d8ad86b8961e514fc91534127f5aa62c3b22f (diff) |
QDebug: pretty-print QStrings and QStringRefs
[ChangeLog][QtCore][QDebug] Printing of QStrings and QStringRefs
whenever "noquote" is not active now prints the strings in a format that
can be copied back to C++ code. All characters that aren't printable in
US-ASCII are escaped (this includes printable Unicode characters outside
of US-ASCII). Pretty-printing will not respect QTextFormat padding or
field widths.
Change-Id: I169a8a0508e24693f5652f0129defe7f709e5d08
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qdebug.h')
-rw-r--r-- | src/corelib/io/qdebug.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index 99c2909aa0..a2d6598bce 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -78,6 +78,7 @@ class Q_CORE_EXPORT QDebug } *stream; void putUcs4(uint ucs4); + void putString(const QChar *begin, size_t length); public: inline QDebug(QIODevice *device) : stream(new Stream(device)) {} inline QDebug(QString *string) : stream(new Stream(string)) {} @@ -118,8 +119,8 @@ public: inline QDebug &operator<<(float t) { stream->ts << t; return maybeSpace(); } inline QDebug &operator<<(double t) { stream->ts << t; return maybeSpace(); } inline QDebug &operator<<(const char* t) { stream->ts << QString::fromUtf8(t); return maybeSpace(); } - inline QDebug &operator<<(const QString & t) { maybeQuote(); stream->ts << t; maybeQuote(); return maybeSpace(); } - inline QDebug &operator<<(const QStringRef & t) { return operator<<(t.toString()); } + inline QDebug &operator<<(const QString & t) { putString(t.constData(), uint(t.length())); return maybeSpace(); } + inline QDebug &operator<<(const QStringRef & t) { putString(t.constData(), uint(t.length())); return maybeSpace(); } inline QDebug &operator<<(QLatin1String t) { maybeQuote(); stream->ts << t; maybeQuote(); return maybeSpace(); } inline QDebug &operator<<(const QByteArray & t) { maybeQuote(); stream->ts << t; maybeQuote(); return maybeSpace(); } inline QDebug &operator<<(const void * t) { stream->ts << t; return maybeSpace(); } |