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::ConstIterator Class Reference

\inmodule QtCore More...

#include <qcborarray.h>

+ Collaboration diagram for QCborArray::ConstIterator:

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 const QCborValue value_type
 
typedef const QCborValueRef reference
 
typedef const QCborValueRef * pointer
 

Public Member Functions

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

Friends

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

Detailed Description

\inmodule QtCore

Since
5.12

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

\compares strong \compareswith strong QCborArray::Iterator \endcompareswith

QCborArray::ConstIterator allows you to iterate over a QCborArray. If you want to modify the QCborArray as you iterate over it, use QCborArray::Iterator instead. It is generally good practice to use QCborArray::ConstIterator, even on a non-const QCborArray, when you don't need to change the QCborArray through the iterator. Const iterators are slightly faster and improves code readability.

Iterators are initialized by using a QCborArray function like QCborArray::begin() or QCborArray::end(). 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::Iterator

Definition at line 121 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 127 of file qcborarray.h.

◆ pointer

◆ reference

◆ value_type

Constructor & Destructor Documentation

◆ ConstIterator() [1/2]

QCborArray::ConstIterator::ConstIterator ( )
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::constBegin(), QCborArray::constEnd()

◆ ConstIterator() [2/2]

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

Constructs a copy of other.

Member Function Documentation

◆ operator*()

QCborValue QCborArray::ConstIterator::operator* ( ) const
inline

Returns the current item.

Definition at line 143 of file qcborarray.h.

References item.

◆ operator+()

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

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

If j is negative, the iterator goes backward.

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

Definition at line 166 of file qcborarray.h.

References item, and j.

◆ operator++() [1/2]

QCborArray::ConstIterator & QCborArray::ConstIterator::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 160 of file qcborarray.h.

References item.

◆ operator++() [2/2]

QCborArray::ConstIterator QCborArray::ConstIterator::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 161 of file qcborarray.h.

References item.

◆ operator+=()

QCborArray::ConstIterator & QCborArray::ConstIterator::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 164 of file qcborarray.h.

References item, and j.

◆ operator-() [1/2]

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

Returns the offset of this iterator relative to other.

Definition at line 168 of file qcborarray.h.

References item, and j.

◆ operator-() [2/2]

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

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

If j is negative, the iterator goes forward.

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

Definition at line 167 of file qcborarray.h.

References item, and j.

◆ operator--() [1/2]

QCborArray::ConstIterator & QCborArray::ConstIterator::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 162 of file qcborarray.h.

References item.

◆ operator--() [2/2]

QCborArray::ConstIterator QCborArray::ConstIterator::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 163 of file qcborarray.h.

References item.

◆ operator-=()

QCborArray::ConstIterator & QCborArray::ConstIterator::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 165 of file qcborarray.h.

References item, and j.

◆ operator->()

const QCborValue * QCborArray::ConstIterator::operator-> ( ) const
inline

Returns a pointer to the current item.

Definition at line 144 of file qcborarray.h.

References item.

◆ operator=()

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

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

Definition at line 135 of file qcborarray.h.

References item, and other().

+ Here is the call graph for this function:

◆ operator[]()

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

Returns 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.

See also
operator+()

Definition at line 145 of file qcborarray.h.

References item, and j.

Friends And Related Symbol Documentation

◆ comparesEqual

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

Definition at line 184 of file qcborarray.h.

◆ compareThreeWay

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

Definition at line 188 of file qcborarray.h.

◆ Iterator

friend class Iterator
friend

Definition at line 123 of file qcborarray.h.

◆ QCborArray

friend class QCborArray
friend

Definition at line 124 of file qcborarray.h.


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