Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QCborMap::Iterator Class Reference

\inmodule QtCore\reentrant More...

#include <qcbormap.h>

Collaboration diagram for QCborMap::Iterator:

Public Types

typedef std::random_access_iterator_tag iterator_category
 A synonym for {std::random_access_iterator_tag} indicating this iterator is a random-access iterator.
typedef qsizetype difference_type
typedef std::pair< QCborValueConstRef, QCborValueRefvalue_type
typedef std::pair< QCborValueConstRef, QCborValueRefreference
typedef std::pair< QCborValueConstRef, QCborValueRefpointer

Public Member Functions

constexpr Iterator ()=default
 Constructs an uninitialized iterator.
constexpr Iterator (const Iterator &)=default
 Constructs an iterator as a copy of other.
 ~Iterator ()=default
Iteratoroperator= (const Iterator &other)
 Makes this iterator a copy of other and returns a reference to this iterator.
value_type operator* () const
 Returns a pair containing the current item's key and a modifiable reference to the current item's value.
value_type operator[] (qsizetype j) const
QCborValueRefoperator-> ()
const QCborValueConstRefoperator-> () const
 Returns a pointer to a modifiable reference to the current pair's value.
QCborValueConstRef key () const
 Returns the current item's key.
QCborValueConstRef keyRef () const
QCborValueRef value () const
 Returns a modifiable reference to the current item's value.
Iteratoroperator++ ()
 The prefix {++} operator, {++i}, advances the iterator to the next item in the map and returns this iterator.
Iterator operator++ (int)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.The postfix {++} operator, {i++}, advances the iterator to the next item in the map and returns an iterator to the previously current item.
Iteratoroperator-- ()
 The prefix {–} operator, {–i}, makes the preceding item current and returns this iterator.
Iterator operator-- (int)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.The postfix {–} operator, {i–}, makes the preceding item current and returns an iterator pointing to the previously current item.
Iteratoroperator+= (qsizetype j)
 Advances the iterator by j items.
Iteratoroperator-= (qsizetype j)
 Makes the iterator go back by j items.
Iterator operator+ (qsizetype j) const
 Returns an iterator to the item at j positions forward from this iterator.
Iterator operator- (qsizetype j) const
 Returns an iterator to the item at j positions backward from this iterator.
qsizetype operator- (Iterator j) const
 Returns the position of the item at iterator j relative to the item at this iterator.

Friends

class ConstIterator
class QCborMap
bool comparesEqual (const Iterator &lhs, const Iterator &rhs) noexcept
Qt::strong_ordering compareThreeWay (const Iterator &lhs, const Iterator &rhs)
bool comparesEqual (const Iterator &lhs, const ConstIterator &rhs) noexcept
Qt::strong_ordering compareThreeWay (const Iterator &lhs, const ConstIterator &rhs)

Detailed Description

\inmodule QtCore

\reentrant

Since
5.12

The QCborMap::Iterator class provides an STL-style non-const iterator for QCborMap.

\compares strong \compareswith strong ConstIterator \endcompareswith

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

Definition at line 43 of file qcbormap.h.

Member Typedef Documentation

◆ difference_type

Definition at line 50 of file qcbormap.h.

◆ iterator_category

typedef std::random_access_iterator_tag QCborMap::Iterator::iterator_category

A synonym for {std::random_access_iterator_tag} indicating this iterator is a random-access iterator.

Definition at line 49 of file qcbormap.h.

◆ pointer

Definition at line 53 of file qcbormap.h.

◆ reference

Definition at line 52 of file qcbormap.h.

◆ value_type

Definition at line 51 of file qcbormap.h.

Constructor & Destructor Documentation

◆ Iterator() [1/2]

QCborMap::Iterator::Iterator ( )
constexprdefault

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(), QCborMap::end()

◆ Iterator() [2/2]

QCborMap::Iterator::Iterator ( const Iterator & other)
constexprdefault

Constructs an iterator as a copy of other.

◆ ~Iterator()

QCborMap::Iterator::~Iterator ( )
default

Member Function Documentation

◆ key()

QCborValueConstRef QCborMap::Iterator::key ( ) const
inline

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()

Definition at line 75 of file qcbormap.h.

◆ keyRef()

QCborValueConstRef QCborMap::Iterator::keyRef ( ) const
inline

Definition at line 76 of file qcbormap.h.

◆ operator*()

value_type QCborMap::Iterator::operator* ( ) const
inline

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.

See also
key(), value()

Definition at line 66 of file qcbormap.h.

◆ operator+()

Iterator QCborMap::Iterator::operator+ ( qsizetype j) const
inline

Returns an iterator to the item at j positions forward from this iterator.

If j is negative, the iterator goes backward.

See also
operator-()

Definition at line 99 of file qcbormap.h.

◆ operator++() [1/2]

Iterator & QCborMap::Iterator::operator++ ( )
inline

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--()

Definition at line 93 of file qcbormap.h.

◆ operator++() [2/2]

Iterator QCborMap::Iterator::operator++ ( int )
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.The postfix {++} operator, {i++}, advances the iterator to the next item in the map and returns an iterator to the previously current item.

Definition at line 94 of file qcbormap.h.

◆ operator+=()

Iterator & QCborMap::Iterator::operator+= ( qsizetype j)
inline

Advances the iterator by j items.

If j is negative, the iterator goes backward. Returns a reference to this iterator.

See also
operator-=(), operator+()

Definition at line 97 of file qcbormap.h.

◆ operator-() [1/2]

qsizetype QCborMap::Iterator::operator- ( QCborMap::Iterator j) const
inline

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+()

Definition at line 101 of file qcbormap.h.

◆ operator-() [2/2]

Iterator QCborMap::Iterator::operator- ( qsizetype j) const
inline

Returns an iterator to the item at j positions backward from this iterator.

If j is negative, the iterator goes forward.

See also
operator+()

Definition at line 100 of file qcbormap.h.

◆ operator--() [1/2]

Iterator & QCborMap::Iterator::operator-- ( )
inline

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++()

Definition at line 95 of file qcbormap.h.

◆ operator--() [2/2]

Iterator QCborMap::Iterator::operator-- ( int )
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.The postfix {–} operator, {i–}, makes the preceding item current and returns an iterator pointing to the previously current item.

Definition at line 96 of file qcbormap.h.

◆ operator-=()

Iterator & QCborMap::Iterator::operator-= ( qsizetype j)
inline

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+=(), operator-()

Definition at line 98 of file qcbormap.h.

◆ operator->() [1/2]

QCborValueRef * QCborMap::Iterator::operator-> ( )
inline

Definition at line 68 of file qcbormap.h.

◆ operator->() [2/2]

const QCborValueConstRef * QCborMap::Iterator::operator-> ( ) const
inline

Returns a pointer to a modifiable reference to the current pair's value.

Definition at line 69 of file qcbormap.h.

◆ operator=()

Iterator & QCborMap::Iterator::operator= ( const Iterator & other)
inline

Makes this iterator a copy of other and returns a reference to this iterator.

Definition at line 58 of file qcbormap.h.

◆ operator[]()

value_type QCborMap::Iterator::operator[] ( qsizetype j) const
inline

Definition at line 67 of file qcbormap.h.

◆ value()

QCborValueRef QCborMap::Iterator::value ( ) const
inline

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(), operator*()

Definition at line 77 of file qcbormap.h.

◆ comparesEqual [1/2]

bool comparesEqual ( const Iterator & lhs,
const ConstIterator & rhs )
friend

Definition at line 140 of file qcbormap.h.

◆ comparesEqual [2/2]

bool comparesEqual ( const Iterator & lhs,
const Iterator & rhs )
friend

Definition at line 130 of file qcbormap.h.

◆ compareThreeWay [1/2]

Qt::strong_ordering compareThreeWay ( const Iterator & lhs,
const ConstIterator & rhs )
friend

Definition at line 144 of file qcbormap.h.

◆ compareThreeWay [2/2]

Qt::strong_ordering compareThreeWay ( const Iterator & lhs,
const Iterator & rhs )
friend

Definition at line 134 of file qcbormap.h.

◆ ConstIterator

friend class ConstIterator
friend

Definition at line 45 of file qcbormap.h.

◆ QCborMap

friend class QCborMap
friend

Definition at line 46 of file qcbormap.h.


The documentation for this class was generated from the following files: