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

\inmodule QtCore More...

#include <qmetacontainer.h>

Inheritance diagram for QMetaAssociation:
Collaboration diagram for QMetaAssociation:

Public Member Functions

 QMetaAssociation ()=default
 QMetaAssociation (const QtMetaContainerPrivate::QMetaAssociationInterface *d)
QMetaType keyMetaType () const
 Returns the meta type for keys in the container.
QMetaType mappedMetaType () const
 Returns the meta type for mapped values in the container.
bool canInsertKey () const
 Returns true if keys can be added to the container using \l insertKey(), otherwise returns false.
void insertKey (void *container, const void *key) const
 Inserts the key into the container if possible.
bool canRemoveKey () const
 Returns true if keys can be removed from the container using \l removeKey(), otherwise returns false.
void removeKey (void *container, const void *key) const
 Removes the key and its associated mapped value from the container if possible.
bool canContainsKey () const
 Returns true if the container can be queried for keys using \l containsKey(), otherwise returns false.
bool containsKey (const void *container, const void *key) const
 Returns true if the container can be queried for keys and contains the key, otherwise returns false.
bool canGetMappedAtKey () const
 Returns true if the container can be queried for values using \l mappedAtKey(), otherwise returns false.
void mappedAtKey (const void *container, const void *key, void *mapped) const
 Retrieves the mapped value associated with the key in the container and places it in the memory location pointed to by mapped, if that is possible.
bool canSetMappedAtKey () const
 Returns true if mapped values can be modified in the container using \l setMappedAtKey(), otherwise returns false.
void setMappedAtKey (void *container, const void *key, const void *mapped) const
 Overwrites the value associated with the key in the container using the mapped value passed as argument if that is possible.
bool canGetKeyAtIterator () const
 Returns true if a key can be retrieved from a non-const iterator using \l keyAtIterator(), otherwise returns false.
void keyAtIterator (const void *iterator, void *key) const
 Retrieves the key pointed to by the non-const iterator and stores it in the memory location pointed to by key, if possible.
bool canGetKeyAtConstIterator () const
 Returns true if a key can be retrieved from a const iterator using \l keyAtConstIterator(), otherwise returns false.
void keyAtConstIterator (const void *iterator, void *key) const
 Retrieves the key pointed to by the const iterator and stores it in the memory location pointed to by key, if possible.
bool canGetMappedAtIterator () const
 Returns true if a mapped value can be retrieved from a non-const iterator using \l mappedAtIterator(), otherwise returns false.
void mappedAtIterator (const void *iterator, void *mapped) const
 Retrieves the mapped value pointed to by the non-const iterator and stores it in the memory location pointed to by mapped, if possible.
bool canGetMappedAtConstIterator () const
 Returns true if a mapped value can be retrieved from a const iterator using \l mappedAtConstIterator(), otherwise returns false.
void mappedAtConstIterator (const void *iterator, void *mapped) const
 Retrieves the mapped value pointed to by the const iterator and stores it in the memory location pointed to by mapped, if possible.
bool canSetMappedAtIterator () const
 Returns true if a mapped value can be set via a non-const iterator using \l setMappedAtIterator(), otherwise returns false.
void setMappedAtIterator (const void *iterator, const void *mapped) const
 Writes the mapped value to the container location pointed to by the non-const iterator, if possible.
bool canCreateIteratorAtKey () const
 Returns true if an iterator pointing to an entry in the container can be created using \l createIteratorAtKey(), otherwise returns false.
voidcreateIteratorAtKey (void *container, const void *key) const
 Returns a non-const iterator pointing to the entry of key in the container, if possible.
bool canCreateConstIteratorAtKey () const
 Returns true if a const iterator pointing to an entry in the container can be created using \l createConstIteratorAtKey(), otherwise returns false.
voidcreateConstIteratorAtKey (const void *container, const void *key) const
 Returns a const iterator pointing to the entry of key in the container, if possible.
const QtMetaContainerPrivate::QMetaAssociationInterfaceiface () const
Public Member Functions inherited from QMetaContainer
 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.

Static Public Member Functions

template<typename T>
static constexpr QMetaAssociation fromContainer ()

Friends

bool comparesEqual (const QMetaAssociation &lhs, const QMetaAssociation &rhs) noexcept

Additional Inherited Members

Protected Attributes inherited from QMetaContainer
const QtMetaContainerPrivate::QMetaContainerInterfaced_ptr = nullptr

Detailed Description

\inmodule QtCore

Since
6.0

The QMetaAssociation class allows type erased access to associative containers.

\compares equality

The class provides a number of primitive container operations, using void* as operands. This way, you can manipulate a generic container retrieved from a Variant without knowing its type.

QMetaAssociation covers both, containers with mapped values such as QMap or QHash, and containers that only hold keys such as QSet.

The void* arguments to the various methods are typically created by using a \l QVariant of the respective container or value type, and calling its \l QVariant::data() or \l QVariant::constData() methods. However, you can also pass plain pointers to objects of the container or value type.

Iterator invalidation follows the rules given by the underlying containers and is not expressed in the API. Therefore, for a truly generic container, any iterators should be considered invalid after any write operation.

See also
QMetaContainer, QMetaSequence, QIterable, QIterator

Definition at line 1002 of file qmetacontainer.h.

Constructor & Destructor Documentation

◆ QMetaAssociation() [1/2]

QMetaAssociation::QMetaAssociation ( )
default

◆ QMetaAssociation() [2/2]

QMetaAssociation::QMetaAssociation ( const QtMetaContainerPrivate::QMetaAssociationInterface * d)
inlineexplicit

Definition at line 1006 of file qmetacontainer.h.

Member Function Documentation

◆ canContainsKey()

bool QMetaAssociation::canContainsKey ( ) const
inline

Returns true if the container can be queried for keys using \l containsKey(), otherwise returns false.

Definition at line 1041 of file qmetacontainer.h.

◆ canCreateConstIteratorAtKey()

bool QMetaAssociation::canCreateConstIteratorAtKey ( ) const
inline

Returns true if a const iterator pointing to an entry in the container can be created using \l createConstIteratorAtKey(), otherwise returns false.

Definition at line 1158 of file qmetacontainer.h.

◆ canCreateIteratorAtKey()

bool QMetaAssociation::canCreateIteratorAtKey ( ) const
inline

Returns true if an iterator pointing to an entry in the container can be created using \l createIteratorAtKey(), otherwise returns false.

See also
createIteratorAtKey()

Definition at line 1144 of file qmetacontainer.h.

◆ canGetKeyAtConstIterator()

bool QMetaAssociation::canGetKeyAtConstIterator ( ) const
inline

Returns true if a key can be retrieved from a const iterator using \l keyAtConstIterator(), otherwise returns false.

See also
keyAtConstIterator()

Definition at line 1092 of file qmetacontainer.h.

◆ canGetKeyAtIterator()

bool QMetaAssociation::canGetKeyAtIterator ( ) const
inline

Returns true if a key can be retrieved from a non-const iterator using \l keyAtIterator(), otherwise returns false.

See also
keyAtIterator()

Definition at line 1079 of file qmetacontainer.h.

◆ canGetMappedAtConstIterator()

bool QMetaAssociation::canGetMappedAtConstIterator ( ) const
inline

Returns true if a mapped value can be retrieved from a const iterator using \l mappedAtConstIterator(), otherwise returns false.

See also
mappedAtConstIterator()

Definition at line 1118 of file qmetacontainer.h.

◆ canGetMappedAtIterator()

bool QMetaAssociation::canGetMappedAtIterator ( ) const
inline

Returns true if a mapped value can be retrieved from a non-const iterator using \l mappedAtIterator(), otherwise returns false.

See also
mappedAtIterator()

Definition at line 1105 of file qmetacontainer.h.

◆ canGetMappedAtKey()

bool QMetaAssociation::canGetMappedAtKey ( ) const
inline

Returns true if the container can be queried for values using \l mappedAtKey(), otherwise returns false.

Definition at line 1055 of file qmetacontainer.h.

◆ canInsertKey()

bool QMetaAssociation::canInsertKey ( ) const
inline

Returns true if keys can be added to the container using \l insertKey(), otherwise returns false.

See also
insertKey()

Definition at line 1017 of file qmetacontainer.h.

◆ canRemoveKey()

bool QMetaAssociation::canRemoveKey ( ) const
inline

Returns true if keys can be removed from the container using \l removeKey(), otherwise returns false.

See also
removeKey()

Definition at line 1029 of file qmetacontainer.h.

◆ canSetMappedAtIterator()

bool QMetaAssociation::canSetMappedAtIterator ( ) const
inline

Returns true if a mapped value can be set via a non-const iterator using \l setMappedAtIterator(), otherwise returns false.

See also
setMappedAtIterator()

Definition at line 1131 of file qmetacontainer.h.

◆ canSetMappedAtKey()

bool QMetaAssociation::canSetMappedAtKey ( ) const
inline

Returns true if mapped values can be modified in the container using \l setMappedAtKey(), otherwise returns false.

See also
setMappedAtKey()

Definition at line 1067 of file qmetacontainer.h.

◆ containsKey()

bool QMetaAssociation::containsKey ( const void * container,
const void * key ) const
inline

Returns true if the container can be queried for keys and contains the key, otherwise returns false.

See also
canContainsKey()

Definition at line 1047 of file qmetacontainer.h.

◆ createConstIteratorAtKey()

void * QMetaAssociation::createConstIteratorAtKey ( const void * container,
const void * key ) const
inline

Returns a const iterator pointing to the entry of key in the container, if possible.

If the entry doesn't exist, creates a const iterator pointing to the end of the container. If no const iterator can be created, returns nullptr.

The const iterator has to be destroyed using destroyConstIterator().

See also
canCreateConstIteratorAtKey(), constBegin(), constEnd(), destroyConstIterator()

Definition at line 1165 of file qmetacontainer.h.

◆ createIteratorAtKey()

void * QMetaAssociation::createIteratorAtKey ( void * container,
const void * key ) const
inline

Returns a non-const iterator pointing to the entry of key in the container, if possible.

If the entry doesn't exist, creates a non-const iterator pointing to the end of the container. If no non-const iterator can be created, returns nullptr.

The non-const iterator has to be destroyed using destroyIterator().

See also
canCreateIteratorAtKey(), begin(), end(), destroyIterator()

Definition at line 1151 of file qmetacontainer.h.

◆ fromContainer()

template<typename T>
constexpr QMetaAssociation QMetaAssociation::fromContainer ( )
inlinestaticconstexpr
Since
6.0

Returns the QMetaAssociation corresponding to the type given as template parameter.

Definition at line 1009 of file qmetacontainer.h.

◆ iface()

const QtMetaContainerPrivate::QMetaAssociationInterface * QMetaAssociation::iface ( ) const
inline

Definition at line 1172 of file qmetacontainer.h.

◆ insertKey()

void QMetaAssociation::insertKey ( void * container,
const void * key ) const
inline

Inserts the key into the container if possible.

If the container has mapped values a default-create mapped value is associated with the key.

See also
canInsertKey()

Definition at line 1023 of file qmetacontainer.h.

◆ keyAtConstIterator()

void QMetaAssociation::keyAtConstIterator ( const void * iterator,
void * key ) const
inline

Retrieves the key pointed to by the const iterator and stores it in the memory location pointed to by key, if possible.

See also
canGetKeyAtConstIterator(), constBegin(), constEnd(), createConstIteratorAtKey()

Definition at line 1099 of file qmetacontainer.h.

◆ keyAtIterator()

void QMetaAssociation::keyAtIterator ( const void * iterator,
void * key ) const
inline

Retrieves the key pointed to by the non-const iterator and stores it in the memory location pointed to by key, if possible.

See also
canGetKeyAtIterator(), begin(), end(), createIteratorAtKey()

Definition at line 1086 of file qmetacontainer.h.

◆ keyMetaType()

QMetaType QMetaAssociation::keyMetaType ( ) const

Returns the meta type for keys in the container.

Definition at line 48 of file qmetaassociation.cpp.

◆ mappedAtConstIterator()

void QMetaAssociation::mappedAtConstIterator ( const void * iterator,
void * mapped ) const
inline

Retrieves the mapped value pointed to by the const iterator and stores it in the memory location pointed to by mapped, if possible.

See also
canGetMappedAtConstIterator(), constBegin(), constEnd(), createConstIteratorAtKey()

Definition at line 1125 of file qmetacontainer.h.

◆ mappedAtIterator()

void QMetaAssociation::mappedAtIterator ( const void * iterator,
void * mapped ) const
inline

Retrieves the mapped value pointed to by the non-const iterator and stores it in the memory location pointed to by mapped, if possible.

See also
canGetMappedAtIterator(), begin(), end(), createIteratorAtKey()

Definition at line 1112 of file qmetacontainer.h.

◆ mappedAtKey()

void QMetaAssociation::mappedAtKey ( const void * container,
const void * key,
void * mapped ) const
inline

Retrieves the mapped value associated with the key in the container and places it in the memory location pointed to by mapped, if that is possible.

See also
canGetMappedAtKey()

Definition at line 1061 of file qmetacontainer.h.

◆ mappedMetaType()

QMetaType QMetaAssociation::mappedMetaType ( ) const

Returns the meta type for mapped values in the container.

Definition at line 58 of file qmetaassociation.cpp.

◆ removeKey()

void QMetaAssociation::removeKey ( void * container,
const void * key ) const
inline

Removes the key and its associated mapped value from the container if possible.

See also
canRemoveKey()

Definition at line 1035 of file qmetacontainer.h.

◆ setMappedAtIterator()

void QMetaAssociation::setMappedAtIterator ( const void * iterator,
const void * mapped ) const
inline

Writes the mapped value to the container location pointed to by the non-const iterator, if possible.

See also
canSetMappedAtIterator(), begin(), end(), createIteratorAtKey()

Definition at line 1138 of file qmetacontainer.h.

◆ setMappedAtKey()

void QMetaAssociation::setMappedAtKey ( void * container,
const void * key,
const void * mapped ) const
inline

Overwrites the value associated with the key in the container using the mapped value passed as argument if that is possible.

See also
canSetMappedAtKey()

Definition at line 1073 of file qmetacontainer.h.

◆ comparesEqual

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

Definition at line 1175 of file qmetacontainer.h.


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