diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2014-08-15 15:41:44 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2014-08-25 16:03:42 +0200 |
commit | 7dce96220003e3fa3f932341aaecd8e7f55f4d95 (patch) | |
tree | a8bafd0eca632b98f84b2a1f8b5424d8a13dccf0 /src/corelib/json/qjsonobject.h | |
parent | f16de5c1fd8cf0e9d6a37aaa771144ccc4220fba (diff) |
Add operator-> to QJson iterators
The iterators for QJsonArray and QJsonObject are currently lacking an
operator-> definition. Unfortunately it is not possible to do in clean
way without redefining either the iterators or QJsonValueRef class.
This patch instead adds two fake pointer classes that are only used
to handle the operator-> return value.
Task-number: QTBUG-29573
Change-Id: Ief785a6afbbedc9e89cf3b6f3958c2c755997a66
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/corelib/json/qjsonobject.h')
-rw-r--r-- | src/corelib/json/qjsonobject.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/corelib/json/qjsonobject.h b/src/corelib/json/qjsonobject.h index 92dd19af5e..7973b8ab92 100644 --- a/src/corelib/json/qjsonobject.h +++ b/src/corelib/json/qjsonobject.h @@ -107,7 +107,6 @@ public: typedef std::bidirectional_iterator_tag iterator_category; typedef int difference_type; typedef QJsonValue value_type; -// typedef T *pointer; typedef QJsonValueRef reference; Q_DECL_CONSTEXPR inline iterator() : o(0), i(0) {} @@ -116,7 +115,11 @@ public: inline QString key() const { return o->keyAt(i); } inline QJsonValueRef value() const { return QJsonValueRef(o, i); } inline QJsonValueRef operator*() const { return QJsonValueRef(o, i); } - //inline T *operator->() const { return &concrete(i)->value; } +#ifdef Q_QDOC + inline QJsonValueRef* operator->() const; +#else + inline QJsonValueRefPtr operator->() const { return QJsonValueRefPtr(o, i); } +#endif inline bool operator==(const iterator &other) const { return i == other.i; } inline bool operator!=(const iterator &other) const { return i != other.i; } @@ -157,7 +160,11 @@ public: inline QString key() const { return o->keyAt(i); } inline QJsonValue value() const { return o->valueAt(i); } inline QJsonValue operator*() const { return o->valueAt(i); } - //inline const T *operator->() const { return &concrete(i)->value; } +#ifdef Q_QDOC + inline QJsonValue* operator->() const; +#else + inline QJsonValuePtr operator->() const { return QJsonValuePtr(o->valueAt(i)); } +#endif inline bool operator==(const const_iterator &other) const { return i == other.i; } inline bool operator!=(const const_iterator &other) const { return i != other.i; } |