QJsonValue: add rvalue overloads for QJsonArray and QJsonObject ctors
These can be noexcept. Requires to add rvalue overloads for QCborMap::fromJsonObject() and QCborArray::fromJsonArray(), too. [ChangeLog][QtCore][QJsonValue] Added constructors taking rvalue QJsonArray and rvalue QJsonObject. [ChangeLog][QtCore][QCborMap] Added rvalue overload of fromJsonObject(). [ChangeLog][QtCore][QCborArray] Added rvalue overload of fromJsonArray(). Change-Id: I523c9a41166ea932fba4dd204072bd39d2192d2e Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
6deb28f35a
commit
ff77930c25
@ -267,6 +267,7 @@ public:
|
||||
static QCborArray fromStringList(const QStringList &list);
|
||||
static QCborArray fromVariantList(const QVariantList &list);
|
||||
static QCborArray fromJsonArray(const QJsonArray &array);
|
||||
static QCborArray fromJsonArray(QJsonArray &&array) noexcept;
|
||||
QVariantList toVariantList() const;
|
||||
QJsonArray toJsonArray() const;
|
||||
|
||||
|
@ -318,6 +318,7 @@ public:
|
||||
static QCborMap fromVariantMap(const QVariantMap &map);
|
||||
static QCborMap fromVariantHash(const QVariantHash &hash);
|
||||
static QCborMap fromJsonObject(const QJsonObject &o);
|
||||
static QCborMap fromJsonObject(QJsonObject &&o) noexcept;
|
||||
QVariantMap toVariantMap() const;
|
||||
QVariantHash toVariantHash() const;
|
||||
QJsonObject toJsonObject() const;
|
||||
|
@ -875,6 +875,18 @@ QCborArray QCborArray::fromJsonArray(const QJsonArray &array)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
\since 6.3
|
||||
*/
|
||||
QCborArray QCborArray::fromJsonArray(QJsonArray &&array) noexcept
|
||||
{
|
||||
QCborArray result;
|
||||
result.d = std::exchange(array.a, {});
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
Converts the CBOR values to QVariant using QCborValue::toVariant() and
|
||||
"stringifies" all the CBOR keys in this map, returning the QVariantMap that
|
||||
@ -989,4 +1001,15 @@ QCborMap QCborMap::fromJsonObject(const QJsonObject &obj)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
\since 6.3
|
||||
*/
|
||||
QCborMap QCborMap::fromJsonObject(QJsonObject &&obj) noexcept
|
||||
{
|
||||
QCborMap result;
|
||||
result.d = std::exchange(obj.o, {});
|
||||
return result;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -222,6 +222,15 @@ QJsonValue::QJsonValue(const QJsonArray &a)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
\since 6.3
|
||||
*/
|
||||
QJsonValue::QJsonValue(QJsonArray &&a) noexcept
|
||||
: value(QCborArray::fromJsonArray(std::move(a)))
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates a value of type Object, with value \a o.
|
||||
*/
|
||||
@ -230,6 +239,15 @@ QJsonValue::QJsonValue(const QJsonObject &o)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
\since 6.3
|
||||
*/
|
||||
QJsonValue::QJsonValue(QJsonObject &&o) noexcept
|
||||
: value(QCborMap::fromJsonObject(std::move(o)))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Destroys the value.
|
||||
|
@ -81,7 +81,9 @@ public:
|
||||
: QJsonValue(QString::fromUtf8(s)) {}
|
||||
#endif
|
||||
QJsonValue(const QJsonArray &a);
|
||||
QJsonValue(QJsonArray &&a) noexcept;
|
||||
QJsonValue(const QJsonObject &o);
|
||||
QJsonValue(QJsonObject &&o) noexcept;
|
||||
|
||||
~QJsonValue();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user