Add assignment operator for QJsonValueRef
The implicit cast to QJsonValue was being ignored probably because the compiler was generating a default QJsonValueRef assignment operator Change-Id: I3a041595497308868dd7e4aab71027ce21bf8f0b Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
parent
427fe6c2fd
commit
e483b9bf37
@ -548,6 +548,16 @@ QJsonValueRef &QJsonValueRef::operator =(const QJsonValue &val)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJsonValueRef &QJsonValueRef::operator =(const QJsonValueRef &ref)
|
||||||
|
{
|
||||||
|
if (is_object)
|
||||||
|
o->setValueAt(index, ref);
|
||||||
|
else
|
||||||
|
a->replace(index, ref);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
QJsonArray QJsonValueRef::toArray() const
|
QJsonArray QJsonValueRef::toArray() const
|
||||||
{
|
{
|
||||||
return toValue().toArray();
|
return toValue().toArray();
|
||||||
|
@ -147,6 +147,7 @@ public:
|
|||||||
|
|
||||||
inline operator QJsonValue() const { return toValue(); }
|
inline operator QJsonValue() const { return toValue(); }
|
||||||
QJsonValueRef &operator = (const QJsonValue &val);
|
QJsonValueRef &operator = (const QJsonValue &val);
|
||||||
|
QJsonValueRef &operator = (const QJsonValueRef &val);
|
||||||
|
|
||||||
inline QJsonValue::Type type() const { return toValue().type(); }
|
inline QJsonValue::Type type() const { return toValue().type(); }
|
||||||
inline bool isNull() const { return type() == QJsonValue::Null; }
|
inline bool isNull() const { return type() == QJsonValue::Null; }
|
||||||
|
@ -550,6 +550,11 @@ void TestQtJson::testValueRef()
|
|||||||
QJsonValue val = object[QLatin1String("null")];
|
QJsonValue val = object[QLatin1String("null")];
|
||||||
QCOMPARE(val.toDouble(), 100.);
|
QCOMPARE(val.toDouble(), 100.);
|
||||||
QCOMPARE(object.size(), 2);
|
QCOMPARE(object.size(), 2);
|
||||||
|
|
||||||
|
array[1] = array[2] = object[QLatin1String("key")] = 42;
|
||||||
|
QCOMPARE(array[1], array[2]);
|
||||||
|
QCOMPARE(array[2], object[QLatin1String("key")]);
|
||||||
|
QCOMPARE(object.value(QLatin1String("key")), QJsonValue(42));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestQtJson::testObjectIteration()
|
void TestQtJson::testObjectIteration()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user