diff options
Diffstat (limited to 'src/corelib/serialization/qjsonobject.cpp')
-rw-r--r-- | src/corelib/serialization/qjsonobject.cpp | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/src/corelib/serialization/qjsonobject.cpp b/src/corelib/serialization/qjsonobject.cpp index 419021a798..0c4af59163 100644 --- a/src/corelib/serialization/qjsonobject.cpp +++ b/src/corelib/serialization/qjsonobject.cpp @@ -106,7 +106,7 @@ QT_BEGIN_NAMESPACE /*! \typedef QJsonObject::size_type - Typedef for int. Provided for STL compatibility. + Typedef for qsizetype. Provided for STL compatibility. */ @@ -272,7 +272,7 @@ QStringList QJsonObject::keys() const QStringList keys; if (o) { keys.reserve(o->elements.length() / 2); - for (int i = 0, end = o->elements.length(); i < end; i += 2) + for (qsizetype i = 0, end = o->elements.length(); i < end; i += 2) keys.append(o->stringAt(i)); } return keys; @@ -281,7 +281,7 @@ QStringList QJsonObject::keys() const /*! Returns the number of (key, value) pairs stored in the object. */ -int QJsonObject::size() const +qsizetype QJsonObject::size() const { return o ? o->elements.length() / 2 : 0; } @@ -297,8 +297,8 @@ bool QJsonObject::isEmpty() const } template<typename String> -static int indexOf(const QExplicitlySharedDataPointer<QCborContainerPrivate> &o, - String key, bool *keyExists) +static qsizetype indexOf(const QExplicitlySharedDataPointer<QCborContainerPrivate> &o, + String key, bool *keyExists) { const auto begin = QJsonPrivate::ConstKeyIterator(o->elements.constBegin()); const auto end = QJsonPrivate::ConstKeyIterator(o->elements.constEnd()); @@ -355,7 +355,7 @@ QJsonValue QJsonObject::valueImpl(T key) const return QJsonValue(QJsonValue::Undefined); bool keyExists; - int i = indexOf(o, key, &keyExists); + auto i = indexOf(o, key, &keyExists); if (!keyExists) return QJsonValue(QJsonValue::Undefined); return QJsonPrivate::Value::fromTrustedCbor(o->valueAt(i + 1)); @@ -439,7 +439,7 @@ QJsonValueRef QJsonObject::atImpl(T key) o = new QCborContainerPrivate; bool keyExists = false; - int index = indexOf(o, key, &keyExists); + auto index = indexOf(o, key, &keyExists); if (!keyExists) { detach(o->elements.length() / 2 + 1); o->insertAt(index, key); @@ -498,7 +498,7 @@ QJsonObject::iterator QJsonObject::insertImpl(T key, const QJsonValue &value) return end(); } bool keyExists = false; - int pos = o ? indexOf(o, key, &keyExists) : 0; + auto pos = o ? indexOf(o, key, &keyExists) : 0; return insertAt(pos, key, value, keyExists); } @@ -506,7 +506,7 @@ QJsonObject::iterator QJsonObject::insertImpl(T key, const QJsonValue &value) \internal */ template <typename T> -QJsonObject::iterator QJsonObject::insertAt(int pos, T key, const QJsonValue &value, bool keyExists) +QJsonObject::iterator QJsonObject::insertAt(qsizetype pos, T key, const QJsonValue &value, bool keyExists) { if (o) detach(o->elements.length() / 2 + (keyExists ? 0 : 1)); @@ -562,7 +562,7 @@ void QJsonObject::removeImpl(T key) return; bool keyExists; - int index = indexOf(o, key, &keyExists); + auto index = indexOf(o, key, &keyExists); if (!keyExists) return; @@ -613,7 +613,7 @@ QJsonValue QJsonObject::takeImpl(T key) return QJsonValue(QJsonValue::Undefined); bool keyExists; - int index = indexOf(o, key, &keyExists); + auto index = indexOf(o, key, &keyExists); if (!keyExists) return QJsonValue(QJsonValue::Undefined); @@ -681,7 +681,7 @@ bool QJsonObject::operator==(const QJsonObject &other) const if (o->elements.length() != other.o->elements.length()) return false; - for (int i = 0, end = o->elements.length(); i < end; ++i) { + for (qsizetype i = 0, end = o->elements.length(); i < end; ++i) { if (o->valueAt(i) != other.o->valueAt(i)) return false; } @@ -706,8 +706,8 @@ bool QJsonObject::operator!=(const QJsonObject &other) const */ QJsonObject::iterator QJsonObject::erase(QJsonObject::iterator it) { - if (it.item.o != this || it.item.index < 0 || it.item.index >= o->elements.length()) - return {this, int(o->elements.length())}; + if (it.item.o != this || qsizetype(it.item.index) >= o->elements.length()) + return {this, o->elements.length()}; removeAt(it.item.index); @@ -754,7 +754,7 @@ template <typename T> QJsonObject::iterator QJsonObject::findImpl(T key) { bool keyExists = false; - int index = o ? indexOf(o, key, &keyExists) : 0; + auto index = o ? indexOf(o, key, &keyExists) : 0; if (!keyExists) return end(); detach(); @@ -819,20 +819,20 @@ template <typename T> QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const { bool keyExists = false; - int index = o ? indexOf(o, key, &keyExists) : 0; + auto index = o ? indexOf(o, key, &keyExists) : 0; if (!keyExists) return end(); return {this, index / 2}; } -/*! \fn int QJsonObject::count() const +/*! \fn qsizetype QJsonObject::count() const \overload Same as size(). */ -/*! \fn int QJsonObject::length() const +/*! \fn qsizetype QJsonObject::length() const \overload @@ -956,7 +956,7 @@ QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const \sa QJsonObject::begin(), QJsonObject::end() */ -/*! \fn QJsonObject::iterator::iterator(QJsonObject *obj, int index) +/*! \fn QJsonObject::iterator::iterator(QJsonObject *obj, qsizetype index) \internal */ @@ -1007,7 +1007,7 @@ QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const Returns a pointer to a modifiable reference to the current item. */ -/*! \fn const QJsonValueRef QJsonObject::iterator::operator[](int j) +/*! \fn const QJsonValueRef QJsonObject::iterator::operator[](qsizetype j) Returns a modifiable reference to the item at offset \a j from the item pointed to by this iterator (the item at position \c{*this + j}). @@ -1116,7 +1116,7 @@ QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const current item. */ -/*! \fn QJsonObject::iterator QJsonObject::iterator::operator+(int j) const +/*! \fn QJsonObject::iterator QJsonObject::iterator::operator+(qsizetype j) const Returns an iterator to the item at \a j positions forward from this iterator. If \a j is negative, the iterator goes backward. @@ -1125,7 +1125,7 @@ QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const */ -/*! \fn QJsonObject::iterator QJsonObject::iterator::operator-(int j) const +/*! \fn QJsonObject::iterator QJsonObject::iterator::operator-(qsizetype j) const Returns an iterator to the item at \a j positions backward from this iterator. If \a j is negative, the iterator goes forward. @@ -1133,7 +1133,7 @@ QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const \sa operator+() */ -/*! \fn QJsonObject::iterator &QJsonObject::iterator::operator+=(int j) +/*! \fn QJsonObject::iterator &QJsonObject::iterator::operator+=(qsizetype j) Advances the iterator by \a j items. If \a j is negative, the iterator goes backward. @@ -1141,7 +1141,7 @@ QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const \sa operator-=(), operator+() */ -/*! \fn QJsonObject::iterator &QJsonObject::iterator::operator-=(int j) +/*! \fn QJsonObject::iterator &QJsonObject::iterator::operator-=(qsizetype j) Makes the iterator go back by \a j items. If \a j is negative, the iterator goes forward. @@ -1149,7 +1149,7 @@ QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const \sa operator+=(), operator-() */ -/*! \fn int QJsonObject::iterator::operator-(iterator other) const +/*! \fn qsizetype QJsonObject::iterator::operator-(iterator other) const Returns the number of items between the item pointed to by \a other and the item pointed to by this iterator. @@ -1221,7 +1221,7 @@ QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const \sa QJsonObject::constBegin(), QJsonObject::constEnd() */ -/*! \fn QJsonObject::const_iterator::const_iterator(const QJsonObject *obj, int index) +/*! \fn QJsonObject::const_iterator::const_iterator(const QJsonObject *obj, qsizetype index) \internal */ @@ -1258,7 +1258,7 @@ QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const Returns a pointer to the current item. */ -/*! \fn const QJsonValue QJsonObject::const_iterator::operator[](int j) +/*! \fn const QJsonValue QJsonObject::const_iterator::operator[](qsizetype j) Returns the item at offset \a j from the item pointed to by this iterator (the item at position \c{*this + j}). @@ -1356,7 +1356,7 @@ QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const current item. */ -/*! \fn QJsonObject::const_iterator QJsonObject::const_iterator::operator+(int j) const +/*! \fn QJsonObject::const_iterator QJsonObject::const_iterator::operator+(qsizetype j) const Returns an iterator to the item at \a j positions forward from this iterator. If \a j is negative, the iterator goes backward. @@ -1366,7 +1366,7 @@ QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const \sa operator-() */ -/*! \fn QJsonObject::const_iterator QJsonObject::const_iterator::operator-(int j) const +/*! \fn QJsonObject::const_iterator QJsonObject::const_iterator::operator-(qsizetype j) const Returns an iterator to the item at \a j positions backward from this iterator. If \a j is negative, the iterator goes forward. @@ -1376,7 +1376,7 @@ QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const \sa operator+() */ -/*! \fn QJsonObject::const_iterator &QJsonObject::const_iterator::operator+=(int j) +/*! \fn QJsonObject::const_iterator &QJsonObject::const_iterator::operator+=(qsizetype j) Advances the iterator by \a j items. If \a j is negative, the iterator goes backward. @@ -1386,7 +1386,7 @@ QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const \sa operator-=(), operator+() */ -/*! \fn QJsonObject::const_iterator &QJsonObject::const_iterator::operator-=(int j) +/*! \fn QJsonObject::const_iterator &QJsonObject::const_iterator::operator-=(qsizetype j) Makes the iterator go back by \a j items. If \a j is negative, the iterator goes forward. @@ -1396,7 +1396,7 @@ QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const \sa operator+=(), operator-() */ -/*! \fn int QJsonObject::const_iterator::operator-(const_iterator other) const +/*! \fn qsizetype QJsonObject::const_iterator::operator-(const_iterator other) const Returns the number of items between the item pointed to by \a other and the item pointed to by this iterator. @@ -1406,7 +1406,7 @@ QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const /*! \internal */ -bool QJsonObject::detach(uint reserve) +bool QJsonObject::detach(qsizetype reserve) { if (!o) return true; @@ -1417,7 +1417,7 @@ bool QJsonObject::detach(uint reserve) /*! \internal */ -QString QJsonObject::keyAt(int i) const +QString QJsonObject::keyAt(qsizetype i) const { Q_ASSERT(o && i >= 0 && i * 2 < o->elements.length()); return o->stringAt(i * 2); @@ -1426,7 +1426,7 @@ QString QJsonObject::keyAt(int i) const /*! \internal */ -QJsonValue QJsonObject::valueAt(int i) const +QJsonValue QJsonObject::valueAt(qsizetype i) const { if (!o || i < 0 || 2 * i + 1 >= o->elements.length()) return QJsonValue(QJsonValue::Undefined); @@ -1436,7 +1436,7 @@ QJsonValue QJsonObject::valueAt(int i) const /*! \internal */ -void QJsonObject::setValueAt(int i, const QJsonValue &val) +void QJsonObject::setValueAt(qsizetype i, const QJsonValue &val) { Q_ASSERT(o && i >= 0 && 2 * i + 1 < o->elements.length()); detach(); @@ -1451,7 +1451,7 @@ void QJsonObject::setValueAt(int i, const QJsonValue &val) /*! \internal */ -void QJsonObject::removeAt(int index) +void QJsonObject::removeAt(qsizetype index) { detach(); o->removeAt(2 * index + 1); |