summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qjsonobject.cpp
diff options
context:
space:
mode:
authorTatiana Borisova <tatiana.borisova@qt.io>2024-03-20 17:43:22 +0100
committerTatiana Borisova <tatiana.borisova@qt.io>2024-03-25 23:29:31 +0100
commit25652c281960aa5647bc137dcee54b7e712e4897 (patch)
tree2e533d2c6fc208b2e455a9d24c6d7f1a5ce45b87 /src/corelib/serialization/qjsonobject.cpp
parentf5d5a42dc3fba2a3a9d911e8ddc589d191f7d247 (diff)
QJsonObject: use new comparison helper macros
Replace public operators operator==(), operator!=() of QJsonObject to friend methods comparesEqual(). Use QT_CORE_REMOVED_SINCE and removed_api.cpp to get rid of current comparison methods and replace them with a friend. Add friend method comparesEqual(QJsonObject, QJsonValue) to the QJsonObject class, to support comparison between QJsonObject and QJsonValue elements, see test-case valueEquals(). Task-number: QTBUG-120300 Change-Id: Ibab0b4b39966205447e31c41e94e7e1a4e31e553 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'src/corelib/serialization/qjsonobject.cpp')
-rw-r--r--src/corelib/serialization/qjsonobject.cpp38
1 files changed, 21 insertions, 17 deletions
diff --git a/src/corelib/serialization/qjsonobject.cpp b/src/corelib/serialization/qjsonobject.cpp
index fb81599e33a..2fbac931dc0 100644
--- a/src/corelib/serialization/qjsonobject.cpp
+++ b/src/corelib/serialization/qjsonobject.cpp
@@ -31,6 +31,10 @@ QT_BEGIN_NAMESPACE
\brief The QJsonObject class encapsulates a JSON object.
+ \compares equality
+ \compareswith equality QJsonValue
+ \endcompareswith
+
A JSON object is a list of key value pairs, where the keys are unique strings
and the values are represented by a QJsonValue.
@@ -613,22 +617,24 @@ bool QJsonObject::containsImpl(T key) const
}
/*!
- Returns \c true if \a other is equal to this object.
- */
-bool QJsonObject::operator==(const QJsonObject &other) const
+ \fn bool QJsonObject::operator==(const QJsonObject &lhs, const QJsonObject &rhs)
+
+ Returns \c true if \a lhs object is equal to \a rhs, \c false otherwise.
+*/
+bool comparesEqual(const QJsonObject &lhs, const QJsonObject &rhs) noexcept
{
- if (o == other.o)
+ if (lhs.o == rhs.o)
return true;
- if (!o)
- return !other.o->elements.size();
- if (!other.o)
- return !o->elements.size();
- if (o->elements.size() != other.o->elements.size())
+ if (!lhs.o)
+ return !rhs.o->elements.size();
+ if (!rhs.o)
+ return !lhs.o->elements.size();
+ if (lhs.o->elements.size() != rhs.o->elements.size())
return false;
- for (qsizetype i = 0, end = o->elements.size(); i < end; ++i) {
- if (o->valueAt(i) != other.o->valueAt(i))
+ for (qsizetype i = 0, end = lhs.o->elements.size(); i < end; ++i) {
+ if (lhs.o->valueAt(i) != rhs.o->valueAt(i))
return false;
}
@@ -636,12 +642,10 @@ bool QJsonObject::operator==(const QJsonObject &other) const
}
/*!
- Returns \c true if \a other is not equal to this object.
- */
-bool QJsonObject::operator!=(const QJsonObject &other) const
-{
- return !(*this == other);
-}
+ \fn bool QJsonObject::operator!=(const QJsonObject &lhs, const QJsonObject &rhs)
+
+ Returns \c true if \a lhs object is not equal to \a rhs, \c false otherwise.
+*/
/*!
Removes the (key, value) pair pointed to by the iterator \a it