diff options
author | Kurt Pattyn <pattyn.kurt@gmail.com> | 2013-12-22 12:33:33 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-24 13:21:56 +0100 |
commit | a2131d6c2f0b2048815e24ca0abbe3e50709acf0 (patch) | |
tree | 568ebf3afb26ab141c277774867ca868d267ee6b | |
parent | 954bb6c35ff38ca836fcfdaade4df4724f3cf1f3 (diff) |
Retain space setting
Change-Id: I4584de9ba51610907c917a0e0ddf5f6f28d304a0
Reviewed-by: David Faure <david.faure@kdab.com>
-rw-r--r-- | src/corelib/io/qdebug.h | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/src/corelib/io/qdebug.h b/src/corelib/io/qdebug.h index b316c2866e..00177b659e 100644 --- a/src/corelib/io/qdebug.h +++ b/src/corelib/io/qdebug.h @@ -174,6 +174,7 @@ template <class T> inline QDebug operator<<(QDebug debug, const QList<T> &list) #endif { + const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << '('; for (typename QList<T>::size_type i = 0; i < list.count(); ++i) { if (i) @@ -181,7 +182,8 @@ inline QDebug operator<<(QDebug debug, const QList<T> &list) debug << list.at(i); } debug << ')'; - return debug.space(); + debug.setAutoInsertSpaces(oldSetting); + return debug.maybeSpace(); } #if defined(FORCE_UREF) @@ -192,7 +194,9 @@ template <typename T> inline QDebug operator<<(QDebug debug, const QVector<T> &vec) #endif { + const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << "QVector"; + debug.setAutoInsertSpaces(oldSetting); return operator<<(debug, vec.toList()); } @@ -204,13 +208,15 @@ template <class aKey, class aT> inline QDebug operator<<(QDebug debug, const QMap<aKey, aT> &map) #endif { + const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << "QMap("; for (typename QMap<aKey, aT>::const_iterator it = map.constBegin(); it != map.constEnd(); ++it) { debug << '(' << it.key() << ", " << it.value() << ')'; } debug << ')'; - return debug.space(); + debug.setAutoInsertSpaces(oldSetting); + return debug.maybeSpace(); } #if defined(FORCE_UREF) @@ -221,12 +227,14 @@ template <class aKey, class aT> inline QDebug operator<<(QDebug debug, const QHash<aKey, aT> &hash) #endif { + const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << "QHash("; for (typename QHash<aKey, aT>::const_iterator it = hash.constBegin(); it != hash.constEnd(); ++it) debug << '(' << it.key() << ", " << it.value() << ')'; debug << ')'; - return debug.space(); + debug.setAutoInsertSpaces(oldSetting); + return debug.maybeSpace(); } #if defined(FORCE_UREF) @@ -237,14 +245,18 @@ template <class T1, class T2> inline QDebug operator<<(QDebug debug, const QPair<T1, T2> &pair) #endif { + const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << "QPair(" << pair.first << ',' << pair.second << ')'; - return debug.space(); + debug.setAutoInsertSpaces(oldSetting); + return debug.maybeSpace(); } template <typename T> inline QDebug operator<<(QDebug debug, const QSet<T> &set) { + const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << "QSet"; + debug.setAutoInsertSpaces(oldSetting); return operator<<(debug, set.toList()); } @@ -256,6 +268,7 @@ template <class T> inline QDebug operator<<(QDebug debug, const QContiguousCache<T> &cache) #endif { + const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << "QContiguousCache("; for (int i = cache.firstIndex(); i <= cache.lastIndex(); ++i) { debug << cache[i]; @@ -263,7 +276,8 @@ inline QDebug operator<<(QDebug debug, const QContiguousCache<T> &cache) debug << ", "; } debug << ')'; - return debug.space(); + debug.setAutoInsertSpaces(oldSetting); + return debug.maybeSpace(); } #if defined(FORCE_UREF) @@ -274,6 +288,7 @@ template <class T> inline QDebug operator<<(QDebug debug, const QFlags<T> &flags) #endif { + const bool oldSetting = debug.autoInsertSpaces(); debug.nospace() << "QFlags("; bool needSeparator = false; for (uint i = 0; i < sizeof(T) * 8; ++i) { @@ -286,7 +301,8 @@ inline QDebug operator<<(QDebug debug, const QFlags<T> &flags) } } debug << ')'; - return debug.space(); + debug.setAutoInsertSpaces(oldSetting); + return debug.maybeSpace(); } QT_END_NAMESPACE |