Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QCborArray::Iterator Class Reference

\inmodule QtCore More...

#include <qcborarray.h>

+ Collaboration diagram for QCborArray::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 QCborValue value_type
 
typedef QCborValueRef reference
 
typedef QCborValueRef * pointer
 

Public Member Functions

constexpr Iterator ()=default
 Constructs an uninitialized iterator.
 
constexpr Iterator (const Iterator &)=default
 Makes a copy of other.
 
Iteratoroperator= (const Iterator &other)
 Makes this iterator a copy of other and returns a reference to this iterator.
 
QCborValueRef operator* () const
 Returns a modifiable reference to the current item.
 
QCborValueRef * operator-> ()
 
const QCborValueConstRefoperator-> () const
 Returns a pointer to a modifiable reference to the current item.
 
QCborValueRef operator[] (qsizetype j) const
 Returns a modifiable reference to the item at a position j steps forward from the item pointed to by this iterator.
 
Iteratoroperator++ ()
 The prefix {++} operator, {++it}, advances the iterator to the next item in the array 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, {it++}, advances the iterator to the next item in the array and returns an iterator to the previously current item.
 
Iteratoroperator-- ()
 The prefix {–} operator, {–it}, 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, {it–}, makes the preceding item current and returns an iterator to the previously current item.
 
Iteratoroperator+= (qsizetype j)
 Advances the iterator by j positions.
 
Iteratoroperator-= (qsizetype j)
 Makes the iterator go back by j positions.
 
Iterator operator+ (qsizetype j) const
 Returns an iterator to the item at position j steps forward from this iterator.
 
Iterator operator- (qsizetype j) const
 Returns an iterator to the item at position j steps backward from this iterator.
 
qsizetype operator- (Iterator j) const
 Returns the offset of this iterator relative to other.
 

Friends

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

Detailed Description

\inmodule QtCore

Since
5.12

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

\compares strong \compareswith strong QCborArray::ConstIterator \endcompareswith

QCborArray::Iterator allows you to iterate over a QCborArray and to modify the array item associated with the iterator. If you want to iterate over a const QCborArray, use QCborArray::ConstIterator instead. It is generally a good practice to use QCborArray::ConstIterator on a non-const QCborArray as well, unless you need to change the QCborArray through the iterator. Const iterators are slightly faster and improve code readability.

Iterators are initialized by using a QCborArray function like QCborArray::begin(), QCborArray::end(), or QCborArray::insert(). Iteration is only possible after that.

Most QCborArray functions accept an integer index rather than an iterator. For that reason, iterators are rarely useful in connection with QCborArray. One place where STL-style iterators do make sense is as arguments to \l{generic algorithms}.

Multiple iterators can be used on the same array. However, be aware that any non-const function call performed on the QCborArray will render all existing iterators undefined.

See also
QCborArray::ConstIterator

Definition at line 23 of file qcborarray.h.

Member Typedef Documentation

◆ difference_type

◆ iterator_category

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

Definition at line 29 of file qcborarray.h.

◆ pointer

Definition at line 33 of file qcborarray.h.

◆ reference

Definition at line 32 of file qcborarray.h.

◆ value_type

Definition at line 31 of file qcborarray.h.

Constructor & Destructor Documentation

◆ Iterator() [1/2]

QCborArray::Iterator::Iterator ( )
constexprdefault

Constructs an uninitialized iterator.

Functions like operator*() and operator++() should not be called on an uninitialized iterator. Use operator=() to assign a value to it before using it.

See also
QCborArray::begin(), QCborArray::end()

◆ Iterator() [2/2]

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

Makes a copy of other.

Member Function Documentation

◆ operator*()

QCborValueRef QCborArray::Iterator::operator* ( ) const
inline

Returns a modifiable reference to the current item.

You can change the value of an item by using operator*() 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.

Definition at line 45 of file qcborarray.h.

References item.

◆ operator+()

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

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

If j is negative, the iterator goes backward.

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

Definition at line 69 of file qcborarray.h.

References item, and j.

◆ operator++() [1/2]

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

The prefix {++} operator, {++it}, advances the iterator to the next item in the array and returns this iterator.

Calling this function on QCborArray::end() leads to undefined results.

See also
operator--()

Definition at line 63 of file qcborarray.h.

References item.

◆ operator++() [2/2]

QCborArray::Iterator QCborArray::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, {it++}, advances the iterator to the next item in the array and returns an iterator to the previously current item.

Definition at line 64 of file qcborarray.h.

References item.

◆ operator+=()

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

Advances the iterator by j positions.

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

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

Definition at line 67 of file qcborarray.h.

References item, and j.

◆ operator-() [1/2]

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

Returns the offset of this iterator relative to other.

Definition at line 71 of file qcborarray.h.

References item, and j.

◆ operator-() [2/2]

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

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

If j is negative, the iterator goes forward.

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

Definition at line 70 of file qcborarray.h.

References item, and j.

◆ operator--() [1/2]

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

The prefix {–} operator, {–it}, makes the preceding item current and returns this iterator.

Calling this function on QCborArray::begin() leads to undefined results.

See also
operator++()

Definition at line 65 of file qcborarray.h.

References item.

◆ operator--() [2/2]

QCborArray::Iterator QCborArray::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, {it–}, makes the preceding item current and returns an iterator to the previously current item.

Definition at line 66 of file qcborarray.h.

References item.

◆ operator-=()

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

Makes the iterator go back by j positions.

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

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

Definition at line 68 of file qcborarray.h.

References item, and j.

◆ operator->() [1/2]

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

Definition at line 46 of file qcborarray.h.

References item.

◆ operator->() [2/2]

QCborValueRef * QCborArray::Iterator::operator-> ( ) const
inline

Returns a pointer to a modifiable reference to the current item.

Definition at line 47 of file qcborarray.h.

References item.

◆ operator=()

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

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

Definition at line 37 of file qcborarray.h.

References item, and other().

+ Here is the call graph for this function:

◆ operator[]()

QCborValueRef QCborArray::Iterator::operator[] ( qsizetype j) const
inline

Returns a modifiable reference to the item at a position j steps forward from the item pointed to by this iterator.

This function is provided to make QCborArray iterators behave like C++ pointers.

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

Definition at line 48 of file qcborarray.h.

References item, and j.

Friends And Related Symbol Documentation

◆ comparesEqual [1/2]

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

Definition at line 109 of file qcborarray.h.

◆ comparesEqual [2/2]

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

Definition at line 99 of file qcborarray.h.

◆ compareThreeWay [1/2]

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

Definition at line 113 of file qcborarray.h.

◆ compareThreeWay [2/2]

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

Definition at line 103 of file qcborarray.h.

◆ ConstIterator

friend class ConstIterator
friend

Definition at line 25 of file qcborarray.h.

◆ QCborArray

friend class QCborArray
friend

Definition at line 26 of file qcborarray.h.


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