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/qcborarray.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/corelib/serialization/qcborarray.cpp') diff --git a/src/corelib/serialization/qcborarray.cpp b/src/corelib/serialization/qcborarray.cpp index 71a1ad2e9a..020841d604 100644 --- a/src/corelib/serialization/qcborarray.cpp +++ b/src/corelib/serialization/qcborarray.cpp @@ -1138,4 +1138,18 @@ void QCborArray::detach(qsizetype reserved) Returns the offset of this iterator relative to \a other. */ +#if !defined(QT_NO_DEBUG_STREAM) +QDebug operator<<(QDebug dbg, const QCborArray &a) +{ + QDebugStateSaver saver(dbg); + dbg.nospace() << "QCborArray{"; + const char *comma = ""; + for (auto v : a) { + dbg << comma << v; + comma = ", "; + } + return dbg << '}'; +} +#endif + QT_END_NAMESPACE -- cgit v1.2.3