Iterator Class
class QCborMap::IteratorThe QCborMap::Iterator class provides an STL-style non-const iterator for QCborMap. More...
- List of all members, including inherited members
- Iterator is part of CBOR Support in Qt.
This class is strongly comparable.
This class is strongly comparable with ConstIterator.
Public Types
Public Functions
Iterator() | |
Iterator(const QCborMap::Iterator &other) | |
QCborValue | key() const |
QCborValueRef | value() const |
QCborMap::Iterator::value_type | operator*() const |
QCborMap::Iterator | operator+(qsizetype j) const |
QCborMap::Iterator & | operator++() |
QCborMap::Iterator | operator++(int) |
QCborMap::Iterator & | operator+=(qsizetype j) |
qsizetype | operator-(QCborMap::Iterator j) const |
QCborMap::Iterator | operator-(qsizetype j) const |
QCborMap::Iterator & | operator--() |
QCborMap::Iterator | operator--(int) |
QCborMap::Iterator & | operator-=(qsizetype j) |
const QCborValueConstRef * | operator->() const |
QCborMap::Iterator & | operator=(const QCborMap::Iterator &other) |
Related Non-Members
bool | operator!=(const QCborMap::Iterator &lhs, const QCborMap::ConstIterator &rhs) |
bool | operator!=(const QCborMap::Iterator &lhs, const QCborMap::Iterator &rhs) |
bool | operator<(const QCborMap::Iterator &lhs, const QCborMap::ConstIterator &rhs) |
bool | operator<(const QCborMap::Iterator &lhs, const QCborMap::Iterator &rhs) |
bool | operator<=(const QCborMap::Iterator &lhs, const QCborMap::ConstIterator &rhs) |
bool | operator<=(const QCborMap::Iterator &lhs, const QCborMap::Iterator &rhs) |
bool | operator==(const QCborMap::Iterator &lhs, const QCborMap::ConstIterator &rhs) |
bool | operator==(const QCborMap::Iterator &lhs, const QCborMap::Iterator &rhs) |
bool | operator>(const QCborMap::Iterator &lhs, const QCborMap::ConstIterator &rhs) |
bool | operator>(const QCborMap::Iterator &lhs, const QCborMap::Iterator &rhs) |
bool | operator>=(const QCborMap::Iterator &lhs, const QCborMap::ConstIterator &rhs) |
bool | operator>=(const QCborMap::Iterator &lhs, const QCborMap::Iterator &rhs) |
Detailed Description
QCborMap::Iterator allows you to iterate over a QCborMap and to modify the value (but not the key) stored under a particular key. If you want to iterate over a const QCborMap, you should use QCborMap::ConstIterator. It is generally good practice to use QCborMap::ConstIterator on a non-const QCborMap as well, unless you need to change the QCborMap through the iterator. Const iterators are slightly faster, and improve code readability.
You must initialize the iterator using a QCborMap function like QCborMap::begin(), QCborMap::end(), or QCborMap::find() before you can start iterating..
Multiple iterators can be used on the same object. Existing iterators will however become dangling once the object gets modified.
See also QCborMap::ConstIterator.
Member Type Documentation
Iterator::iterator_category
A synonym for std::random_access_iterator_tag indicating this iterator is a random-access iterator.
Member Function Documentation
[constexpr noexcept]
Iterator::Iterator()
Constructs an uninitialized iterator.
Functions like key(), value(), and operator++() must not be called on an uninitialized iterator. Use operator=() to assign a value to it before using it.
See also QCborMap::begin() and QCborMap::end().
[constexpr noexcept]
Iterator::Iterator(const QCborMap::Iterator &other)
Constructs an iterator as a copy of other.
QCborValue Iterator::key() const
Returns the current item's key.
There is no direct way of changing an item's key through an iterator, although it can be done by calling QCborMap::erase() followed by QCborMap::insert().
See also value().
QCborValueRef Iterator::value() const
Returns a modifiable reference to the current item's value.
You can change the value for a key by using value() on the left side of an assignment.
The return value is of type QCborValueRef, a helper class for QCborArray and QCborMap. When you get an object of type QCborValueRef, you can use it as if it were a reference to a QCborValue. If you assign to it, the assignment will apply to the element in the QCborArray or QCborMap from which you got the reference.
See also key() and operator*().
QCborMap::Iterator::value_type Iterator::operator*() const
Returns a pair containing the current item's key and a modifiable reference to the current item's value.
The second element of the pair is of type QCborValueRef, a helper class for QCborArray and QCborMap. When you get an object of type QCborValueRef, you can use it as if it were a reference to a QCborValue. If you assign to it, the assignment will apply to the element in the QCborArray or QCborMap from which you got the reference.
QCborMap::Iterator Iterator::operator+(qsizetype j) const
Returns an iterator to the item at j positions forward from this iterator. If j is negative, the iterator goes backward.
See also operator-().
QCborMap::Iterator &Iterator::operator++()
The prefix ++
operator, ++i
, advances the iterator to the next item in the map and returns this iterator.
Calling this function on QCborMap::end() leads to undefined results.
See also operator--().
QCborMap::Iterator Iterator::operator++(int)
This is an overloaded function.
The postfix ++
operator, i++
, advances the iterator to the next item in the map and returns an iterator to the previously current item.
QCborMap::Iterator &Iterator::operator+=(qsizetype j)
Advances the iterator by j items. If j is negative, the iterator goes backward. Returns a reference to this iterator.
See also operator-=() and operator+().
qsizetype Iterator::operator-(QCborMap::Iterator j) const
Returns the position of the item at iterator j relative to the item at this iterator. If the item at j is forward of this time, the returned value is negative.
See also operator+().
QCborMap::Iterator Iterator::operator-(qsizetype j) const
Returns an iterator to the item at j positions backward from this iterator. If j is negative, the iterator goes forward.
See also operator+().
QCborMap::Iterator &Iterator::operator--()
The prefix --
operator, --i
, makes the preceding item current and returns this iterator.
Calling this function on QCborMap::begin() leads to undefined results.
See also operator++().
QCborMap::Iterator Iterator::operator--(int)
This is an overloaded function.
The postfix --
operator, i--
, makes the preceding item current and returns an iterator pointing to the previously current item.
QCborMap::Iterator &Iterator::operator-=(qsizetype j)
Makes the iterator go back by j items. If j is negative, the iterator goes forward. Returns a reference to this iterator.
See also operator+=() and operator-().
const QCborValueConstRef *Iterator::operator->() const
Returns a pointer to a modifiable reference to the current pair's value.
QCborMap::Iterator &Iterator::operator=(const QCborMap::Iterator &other)
Makes this iterator a copy of other and returns a reference to this iterator.
Related Non-Members
[noexcept]
bool operator==(const QCborMap::Iterator &lhs, const QCborMap::ConstIterator &rhs)
[noexcept]
bool operator==(const QCborMap::Iterator &lhs, const QCborMap::Iterator &rhs)
Returns true
if lhs points to the same entry in the map as rhs iterator; otherwise returns false
.
See also operator!=().
[noexcept]
bool operator!=(const QCborMap::Iterator &lhs, const QCborMap::ConstIterator &rhs)
[noexcept]
bool operator!=(const QCborMap::Iterator &lhs, const QCborMap::Iterator &rhs)
Returns true
if lhs points to a different entry in the map than rhs iterator; otherwise returns false
.
See also operator==().
[noexcept]
bool operator<(const QCborMap::Iterator &lhs, const QCborMap::ConstIterator &rhs)
[noexcept]
bool operator<(const QCborMap::Iterator &lhs, const QCborMap::Iterator &rhs)
Returns true
if the entry in the map pointed to by lhs iterator occurs before the entry pointed to by the rhs iterator.
[noexcept]
bool operator<=(const QCborMap::Iterator &lhs, const QCborMap::ConstIterator &rhs)
[noexcept]
bool operator<=(const QCborMap::Iterator &lhs, const QCborMap::Iterator &rhs)
Returns true
if the entry in the map pointed to by lhs iterator occurs before or is the same entry as is pointed to by the rhs iterator.
[noexcept]
bool operator>(const QCborMap::Iterator &lhs, const QCborMap::ConstIterator &rhs)
[noexcept]
bool operator>(const QCborMap::Iterator &lhs, const QCborMap::Iterator &rhs)
Returns true
if the entry in the map pointed to by lhs iterator occurs after the entry pointed to by the rhs iterator.
[noexcept]
bool operator>=(const QCborMap::Iterator &lhs, const QCborMap::ConstIterator &rhs)
[noexcept]
bool operator>=(const QCborMap::Iterator &lhs, const QCborMap::Iterator &rhs)
Returns true
if the entry in the map pointed to by lhs iterator occurs after or is the same entry as is pointed to by the rhs iterator.