summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qcborvalue.h
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2018-09-14 14:59:21 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2018-11-01 15:02:46 +0000
commit779a73762de6addb2a2e3fee5b98d00d64101b92 (patch)
tree71f69f8a2b18f369ee7ed4bab385b8cc2c4b6ad4 /src/corelib/serialization/qcborvalue.h
parentf09fc1f35294827245e74ced48274387d5ed346f (diff)
Fully support operator[] on QCborValue and QCborValueRef
Added operator[] to QCborValueRef and mutating operator[] both there and in QCborValue. If the value (referenced) is not a container, it is replaced with a map and a reference into the result is returned. If the value is an array and the key is a string, negative, or more than 0xffff, the array is first converted to a map. Change-Id: Ibbc9e480fb25eb3d05547c8a1b99e762b2a68b68 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/serialization/qcborvalue.h')
-rw-r--r--src/corelib/serialization/qcborvalue.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h
index 5c7f9a3791..1088558074 100644
--- a/src/corelib/serialization/qcborvalue.h
+++ b/src/corelib/serialization/qcborvalue.h
@@ -77,6 +77,7 @@ struct QCborParserError
QString errorString() const { return error.toString(); }
};
+class QCborValueRef;
class QCborContainerPrivate;
class Q_CORE_EXPORT QCborValue
{
@@ -246,6 +247,9 @@ public:
const QCborValue operator[](const QString &key) const;
const QCborValue operator[](QLatin1String key) const;
const QCborValue operator[](qint64 key) const;
+ QCborValueRef operator[](qint64 key);
+ QCborValueRef operator[](QLatin1String key);
+ QCborValueRef operator[](const QString & key);
int compare(const QCborValue &other) const;
#if 0 && QT_HAS_INCLUDE(<compare>)
@@ -387,6 +391,13 @@ public:
QCborMap toMap() const;
QCborMap toMap(const QCborMap &m) const;
+ const QCborValue operator[](const QString &key) const;
+ const QCborValue operator[](QLatin1String key) const;
+ const QCborValue operator[](qint64 key) const;
+ QCborValueRef operator[](qint64 key);
+ QCborValueRef operator[](QLatin1String key);
+ QCborValueRef operator[](const QString & key);
+
int compare(const QCborValue &other) const
{ return concrete().compare(other); }
#if 0 && QT_HAS_INCLUDE(<compare>)
@@ -417,6 +428,7 @@ public:
{ return concrete().toDiagnosticNotation(opt); }
private:
+ friend class QCborValue;
friend class QCborArray;
friend class QCborMap;
friend class QCborContainerPrivate;