From 71e41d7230650e4b25cfe0f2ac8e3c87e8e4119e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 25 Jan 2018 14:11:33 -0800 Subject: CBOR: Add QDebug operators for the Qt CBOR value-like types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I added a function that returns the string identifiers for QCborKnownTags and QCborSimpleType, in order to facilitate writing a QTest::toString for those types, as neither enum is part of a Q_OBJECT or Q_GADGET class. Change-Id: I56b444f9d6274221a3b7fffd150d2d26a1925c19 Reviewed-by: MÃ¥rten Nordheim --- src/corelib/serialization/qcbormap.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/corelib/serialization/qcbormap.cpp') diff --git a/src/corelib/serialization/qcbormap.cpp b/src/corelib/serialization/qcbormap.cpp index f7d58ca90b..46ac9c1ec8 100644 --- a/src/corelib/serialization/qcbormap.cpp +++ b/src/corelib/serialization/qcbormap.cpp @@ -1550,4 +1550,18 @@ void QCborMap::detach(qsizetype reserved) \sa operator+=(), operator-() */ +#if !defined(QT_NO_DEBUG_STREAM) +QDebug operator<<(QDebug dbg, const QCborMap &m) +{ + QDebugStateSaver saver(dbg); + dbg.nospace() << "QCborMap{"; + const char *open = "{"; + for (auto pair : m) { + dbg << open << pair.first << ", " << pair.second << '}'; + open = ", {"; + } + return dbg << '}'; +} +#endif + QT_END_NAMESPACE -- cgit v1.2.3