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
QMetaContainer Class Reference

\inmodule QtCore More...

#include <qmetacontainer.h>

Inheritance diagram for QMetaContainer:
Collaboration diagram for QMetaContainer:

Public Member Functions

 QMetaContainer ()=default
 QMetaContainer (const QtMetaContainerPrivate::QMetaContainerInterface *d)
bool hasInputIterator () const
 Returns true if the underlying container provides at least an input iterator as defined by std::input_iterator_tag, otherwise returns false.
bool hasForwardIterator () const
 Returns true if the underlying container provides at least a forward iterator as defined by std::forward_iterator_tag, otherwise returns false.
bool hasBidirectionalIterator () const
 Returns true if the underlying container provides a bi-directional iterator or a random access iterator as defined by std::bidirectional_iterator_tag and std::random_access_iterator_tag, respectively.
bool hasRandomAccessIterator () const
 Returns true if the underlying container provides a random access iterator as defined by std::random_access_iterator_tag, otherwise returns false.
bool hasSize () const
 Returns true if the container can be queried for its size, false otherwise.
qsizetype size (const void *container) const
 Returns the number of values in the given container if it can be queried for its size.
bool canClear () const
 Returns true if the container can be cleared, false otherwise.
void clear (void *container) const
 Clears the given container if it can be cleared.
bool hasIterator () const
 Returns true if the underlying container offers a non-const iterator, false otherwise.
voidbegin (void *container) const
 Creates and returns a non-const iterator pointing to the beginning of container.
voidend (void *container) const
 Creates and returns a non-const iterator pointing to the end of container.
void destroyIterator (const void *iterator) const
 Destroys a non-const iterator previously created using \l begin() or \l end().
bool compareIterator (const void *i, const void *j) const
 Returns true if the non-const iterators i and j point to the same value in the container they are iterating over, otherwise returns false.
void copyIterator (void *target, const void *source) const
 Copies the non-const iterator source into the non-const iterator target.
void advanceIterator (void *iterator, qsizetype step) const
 Advances the non-const iterator by step steps.
qsizetype diffIterator (const void *i, const void *j) const
 Returns the distance between the non-const iterators i and j, the equivalent of i - j.
bool hasConstIterator () const
 Returns true if the underlying container offers a const iterator, false otherwise.
voidconstBegin (const void *container) const
 Creates and returns a const iterator pointing to the beginning of container.
voidconstEnd (const void *container) const
 Creates and returns a const iterator pointing to the end of container.
void destroyConstIterator (const void *iterator) const
 Destroys a const iterator previously created using \l constBegin() or \l constEnd().
bool compareConstIterator (const void *i, const void *j) const
 Returns true if the const iterators i and j point to the same value in the container they are iterating over, otherwise returns false.
void copyConstIterator (void *target, const void *source) const
 Copies the const iterator source into the const iterator target.
void advanceConstIterator (void *iterator, qsizetype step) const
 Advances the const iterator by step steps.
qsizetype diffConstIterator (const void *i, const void *j) const
 Returns the distance between the const iterators i and j, the equivalent of i - j.

Protected Attributes

const QtMetaContainerPrivate::QMetaContainerInterfaced_ptr = nullptr

Detailed Description

\inmodule QtCore

Since
6.0

The QMetaContainer class provides common functionality for sequential and associative containers.

QMetaContainer is part of Qt's meta-type system that allows type-erased access to container-like types at runtime.

It serves as a common base for accessing properties of containers in a generic way, such as size, iteration, and clearing operations, without knowing the actual container type.

Derived classes, such as QMetaSequence, provide specialized interfaces for sequential containers.

\compares equality

Definition at line 886 of file qmetacontainer.h.

Constructor & Destructor Documentation

◆ QMetaContainer() [1/2]

QMetaContainer::QMetaContainer ( )
default

◆ QMetaContainer() [2/2]

QMetaContainer::QMetaContainer ( const QtMetaContainerPrivate::QMetaContainerInterface * d)
inlineexplicit

Definition at line 890 of file qmetacontainer.h.

Member Function Documentation

◆ advanceConstIterator()

void QMetaContainer::advanceConstIterator ( void * iterator,
qsizetype step ) const

Advances the const iterator by step steps.

If step is negative the iterator is moved backwards, towards the beginning of the container. The behavior is unspecified for negative values of step if \l hasBidirectionalIterator() returns false.

See also
constBegin(), constEnd()

Definition at line 772 of file qmetacontainer.cpp.

◆ advanceIterator()

void QMetaContainer::advanceIterator ( void * iterator,
qsizetype step ) const

Advances the non-const iterator by step steps.

If step is negative the iterator is moved backwards, towards the beginning of the container. The behavior is unspecified for negative values of step if \l hasBidirectionalIterator() returns false.

See also
begin(), end()

Definition at line 524 of file qmetacontainer.cpp.

◆ begin()

void * QMetaContainer::begin ( void * container) const

Creates and returns a non-const iterator pointing to the beginning of container.

The iterator is allocated on the heap using new. It has to be destroyed using \l destroyIterator eventually, to reclaim the memory.

Returns nullptr if the container doesn't offer any non-const iterators.

See also
end(), constBegin(), constEnd(), destroyIterator()

Definition at line 455 of file qmetacontainer.cpp.

◆ canClear()

bool QMetaContainer::canClear ( ) const

Returns true if the container can be cleared, false otherwise.

See also
clear()

Definition at line 295 of file qmetacontainer.cpp.

◆ clear()

void QMetaContainer::clear ( void * container) const

Clears the given container if it can be cleared.

See also
canClear()

Definition at line 305 of file qmetacontainer.cpp.

◆ compareConstIterator()

bool QMetaContainer::compareConstIterator ( const void * i,
const void * j ) const

Returns true if the const iterators i and j point to the same value in the container they are iterating over, otherwise returns false.

See also
constBegin(), constEnd()

Definition at line 747 of file qmetacontainer.cpp.

◆ compareIterator()

bool QMetaContainer::compareIterator ( const void * i,
const void * j ) const

Returns true if the non-const iterators i and j point to the same value in the container they are iterating over, otherwise returns false.

See also
begin(), end()

Definition at line 499 of file qmetacontainer.cpp.

◆ constBegin()

void * QMetaContainer::constBegin ( const void * container) const

Creates and returns a const iterator pointing to the beginning of container.

The iterator is allocated on the heap using new. It has to be destroyed using \l destroyConstIterator eventually, to reclaim the memory.

Returns nullptr if the container doesn't offer any const iterators.

See also
constEnd(), begin(), end(), destroyConstIterator()

Definition at line 703 of file qmetacontainer.cpp.

◆ constEnd()

void * QMetaContainer::constEnd ( const void * container) const

Creates and returns a const iterator pointing to the end of container.

The iterator is allocated on the heap using new. It has to be destroyed using \l destroyConstIterator eventually, to reclaim the memory.

Returns nullptr if the container doesn't offer any const iterators.

See also
constBegin(), begin(), end(), destroyConstIterator()

Definition at line 720 of file qmetacontainer.cpp.

◆ copyConstIterator()

void QMetaContainer::copyConstIterator ( void * target,
const void * source ) const

Copies the const iterator source into the const iterator target.

Afterwards compareConstIterator(target, source) returns true.

See also
constBegin(), constEnd()

Definition at line 758 of file qmetacontainer.cpp.

◆ copyIterator()

void QMetaContainer::copyIterator ( void * target,
const void * source ) const

Copies the non-const iterator source into the non-const iterator target.

Afterwards compareIterator(target, source) returns true.

See also
begin(), end()

Definition at line 510 of file qmetacontainer.cpp.

◆ destroyConstIterator()

void QMetaContainer::destroyConstIterator ( const void * iterator) const

Destroys a const iterator previously created using \l constBegin() or \l constEnd().

See also
constBegin(), constEnd(), destroyIterator()

Definition at line 734 of file qmetacontainer.cpp.

◆ destroyIterator()

void QMetaContainer::destroyIterator ( const void * iterator) const

Destroys a non-const iterator previously created using \l begin() or \l end().

See also
begin(), end(), destroyConstIterator()

Definition at line 486 of file qmetacontainer.cpp.

◆ diffConstIterator()

qsizetype QMetaContainer::diffConstIterator ( const void * i,
const void * j ) const

Returns the distance between the const iterators i and j, the equivalent of i - j.

If j is closer to the end of the container than i, the returned value is negative. The behavior is unspecified in this case if \l hasBidirectionalIterator() returns false.

See also
constBegin(), constEnd()

Definition at line 786 of file qmetacontainer.cpp.

◆ diffIterator()

qsizetype QMetaContainer::diffIterator ( const void * i,
const void * j ) const

Returns the distance between the non-const iterators i and j, the equivalent of i - j.

If j is closer to the end of the container than i, the returned value is negative. The behavior is unspecified in this case if \l hasBidirectionalIterator() returns false.

See also
begin(), end()

Definition at line 538 of file qmetacontainer.cpp.

◆ end()

void * QMetaContainer::end ( void * container) const

Creates and returns a non-const iterator pointing to the end of container.

The iterator is allocated on the heap using new. It has to be destroyed using \l destroyIterator eventually, to reclaim the memory.

Returns nullptr if the container doesn't offer any non-const iterators.

See also
hasIterator(), begin(), constBegin(), constEnd(), destroyIterator()

Definition at line 472 of file qmetacontainer.cpp.

◆ hasBidirectionalIterator()

bool QMetaContainer::hasBidirectionalIterator ( ) const

Returns true if the underlying container provides a bi-directional iterator or a random access iterator as defined by std::bidirectional_iterator_tag and std::random_access_iterator_tag, respectively.

Otherwise returns false.

QMetaSequence assumes that const and non-const iterators for the same container have the same iterator traits.

Definition at line 105 of file qmetacontainer.cpp.

◆ hasConstIterator()

bool QMetaContainer::hasConstIterator ( ) const

Returns true if the underlying container offers a const iterator, false otherwise.

See also
constBegin(), constEnd(), destroyConstIterator(), compareConstIterator(), diffConstIterator(), advanceConstIterator(), copyConstIterator()

Definition at line 682 of file qmetacontainer.cpp.

◆ hasForwardIterator()

bool QMetaContainer::hasForwardIterator ( ) const

Returns true if the underlying container provides at least a forward iterator as defined by std::forward_iterator_tag, otherwise returns false.

Bi-directional iterators and random access iterators are specializations of forward iterators. This method will also return true if the container provides one of those.

QMetaSequence assumes that const and non-const iterators for the same container have the same iterator traits.

Definition at line 89 of file qmetacontainer.cpp.

◆ hasInputIterator()

bool QMetaContainer::hasInputIterator ( ) const

Returns true if the underlying container provides at least an input iterator as defined by std::input_iterator_tag, otherwise returns false.

Forward, Bi-directional, and random access iterators are specializations of input iterators. This method will also return true if the container provides one of those.

QMetaSequence assumes that const and non-const iterators for the same container have the same iterator traits.

Definition at line 72 of file qmetacontainer.cpp.

◆ hasIterator()

bool QMetaContainer::hasIterator ( ) const

Returns true if the underlying container offers a non-const iterator, false otherwise.

See also
begin(), end(), destroyIterator(), compareIterator(), diffIterator(), advanceIterator(), copyIterator()

Definition at line 434 of file qmetacontainer.cpp.

◆ hasRandomAccessIterator()

bool QMetaContainer::hasRandomAccessIterator ( ) const

Returns true if the underlying container provides a random access iterator as defined by std::random_access_iterator_tag, otherwise returns false.

QMetaSequence assumes that const and non-const iterators for the same container have the same iterator traits.

Definition at line 120 of file qmetacontainer.cpp.

◆ hasSize()

bool QMetaContainer::hasSize ( ) const

Returns true if the container can be queried for its size, false otherwise.

See also
size()

Definition at line 274 of file qmetacontainer.cpp.

◆ size()

qsizetype QMetaContainer::size ( const void * container) const

Returns the number of values in the given container if it can be queried for its size.

Otherwise returns -1.

See also
hasSize()

Definition at line 285 of file qmetacontainer.cpp.

Member Data Documentation

◆ d_ptr

const QtMetaContainerPrivate::QMetaContainerInterface* QMetaContainer::d_ptr = nullptr
protected

Definition at line 922 of file qmetacontainer.h.


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