diff --git a/src/corelib/serialization/qcborarray.cpp b/src/corelib/serialization/qcborarray.cpp index 05403795b0..921fcf2fca 100644 --- a/src/corelib/serialization/qcborarray.cpp +++ b/src/corelib/serialization/qcborarray.cpp @@ -185,12 +185,22 @@ qsizetype QCborArray::size() const noexcept return d ? d->elements.size() : 0; } +/*! + Empties this array. + + \sa isEmpty() + */ +void QCborArray::clear() +{ + d.reset(); +} + /*! \fn bool QCborArray::isEmpty() const Returns true if this QCborArray is empty (that is if size() is 0). - \sa size() + \sa size(), clear() */ /*! diff --git a/src/corelib/serialization/qcborarray.h b/src/corelib/serialization/qcborarray.h index 6b07b52a02..f24bb41759 100644 --- a/src/corelib/serialization/qcborarray.h +++ b/src/corelib/serialization/qcborarray.h @@ -180,6 +180,7 @@ public: qsizetype size() const noexcept; bool isEmpty() const { return size() == 0; } + void clear(); QCborValue at(qsizetype i) const; QCborValue first() const { return at(0); } diff --git a/src/corelib/serialization/qcbormap.cpp b/src/corelib/serialization/qcbormap.cpp index b18945ded1..33f9249993 100644 --- a/src/corelib/serialization/qcbormap.cpp +++ b/src/corelib/serialization/qcbormap.cpp @@ -270,7 +270,7 @@ QCborMap &QCborMap::operator=(const QCborMap &other) noexcept Returns true if this map is empty (that is, size() is 0). - \sa size() + \sa size(), clear() */ /*! @@ -283,6 +283,16 @@ qsizetype QCborMap::size() const noexcept return d ? d->elements.size() / 2 : 0; } +/*! + Empties this map. + + \sa isEmpty() + */ +void QCborMap::clear() +{ + d.reset(); +} + /*! Returns a list of all keys in this map. diff --git a/src/corelib/serialization/qcbormap.h b/src/corelib/serialization/qcbormap.h index c895abfa59..45ef430e40 100644 --- a/src/corelib/serialization/qcbormap.h +++ b/src/corelib/serialization/qcbormap.h @@ -184,6 +184,7 @@ public: qsizetype size() const noexcept Q_DECL_PURE_FUNCTION; bool isEmpty() const { return size() == 0; } + void clear(); QVector keys() const; QCborValue value(qint64 key) const