QMetaAssociation Class

The QMetaAssociation class allows type erased access to associative containers. 更多...

頭: #include <QMetaAssociation>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
Since: Qt 6.0
繼承: QMetaContainer

此類 相等可比較 .

公共函數

bool canContainsKey () const
bool canCreateConstIteratorAtKey () const
bool canCreateIteratorAtKey () const
bool canGetKeyAtConstIterator () const
bool canGetKeyAtIterator () const
bool canGetMappedAtConstIterator () const
bool canGetMappedAtIterator () const
bool canGetMappedAtKey () const
bool canInsertKey () const
bool canRemoveKey () const
bool canSetMappedAtIterator () const
bool canSetMappedAtKey () const
bool containsKey (const void * container , const void * key ) const
void * createConstIteratorAtKey (const void * container , const void * key ) const
void * createIteratorAtKey (void * container , const void * key ) const
void insertKey (void * container , const void * key ) const
void keyAtConstIterator (const void * iterator , void * key ) const
void keyAtIterator (const void * iterator , void * key ) const
QMetaType keyMetaType () const
void mappedAtConstIterator (const void * iterator , void * mapped ) const
void mappedAtIterator (const void * iterator , void * mapped ) const
void mappedAtKey (const void * container , const void * key , void * mapped ) const
QMetaType mappedMetaType () const
void removeKey (void * container , const void * key ) const
void setMappedAtIterator (const void * iterator , const void * mapped ) const
void setMappedAtKey (void * container , const void * key , const void * mapped ) const

靜態公共成員

(從 6.0 起) QMetaAssociation fromContainer ()
bool operator!= (const QMetaAssociation & lhs , const QMetaAssociation & rhs )
bool operator== (const QMetaAssociation & lhs , const QMetaAssociation & rhs )

詳細描述

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 QVariant of the respective container or value type, and calling its QVariant::data () 或 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.

另請參閱 QMetaContainer , QMetaSequence , QIterable ,和 QIterator .

成員函數文檔編製

bool QMetaAssociation:: canContainsKey () const

返迴 true if the container can be queried for keys using containsKey (),否則返迴 false .

bool QMetaAssociation:: canCreateConstIteratorAtKey () const

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

bool QMetaAssociation:: canCreateIteratorAtKey () const

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

另請參閱 createIteratorAtKey ().

bool QMetaAssociation:: canGetKeyAtConstIterator () const

返迴 true if a key can be retrieved from a const iterator using keyAtConstIterator (),否則返迴 false .

另請參閱 keyAtConstIterator ().

bool QMetaAssociation:: canGetKeyAtIterator () const

返迴 true if a key can be retrieved from a non-const iterator using keyAtIterator (),否則返迴 false .

另請參閱 keyAtIterator ().

bool QMetaAssociation:: canGetMappedAtConstIterator () const

返迴 true if a mapped value can be retrieved from a const iterator using mappedAtConstIterator (),否則返迴 false .

另請參閱 mappedAtConstIterator ().

bool QMetaAssociation:: canGetMappedAtIterator () const

返迴 true if a mapped value can be retrieved from a non-const iterator using mappedAtIterator (),否則返迴 false .

另請參閱 mappedAtIterator ().

bool QMetaAssociation:: canGetMappedAtKey () const

返迴 true if the container can be queried for values using mappedAtKey (),否則返迴 false .

bool QMetaAssociation:: canInsertKey () const

返迴 true if keys can be added to the container using insertKey (),否則返迴 false .

另請參閱 insertKey ().

bool QMetaAssociation:: canRemoveKey () const

返迴 true if keys can be removed from the container using removeKey (),否則返迴 false .

另請參閱 removeKey ().

bool QMetaAssociation:: canSetMappedAtIterator () const

返迴 true if a mapped value can be set via a non-const iterator using setMappedAtIterator (),否則返迴 false .

另請參閱 setMappedAtIterator ().

bool QMetaAssociation:: canSetMappedAtKey () const

返迴 true if mapped values can be modified in the container using setMappedAtKey (),否則返迴 false .

另請參閱 setMappedAtKey ().

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

返迴 truecontainer can be queried for keys and contains the key ,否則返迴 false .

另請參閱 canContainsKey ().

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

Returns a const iterator pointing to the entry of keycontainer , 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 ().

另請參閱 canCreateConstIteratorAtKey (), constBegin (), constEnd (),和 destroyConstIterator ().

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

Returns a non-const iterator pointing to the entry of keycontainer , 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 ().

另請參閱 canCreateIteratorAtKey (), begin (), end (),和 destroyIterator ().

[static constexpr, since 6.0] template <typename T> QMetaAssociation QMetaAssociation:: fromContainer ()

返迴 QMetaAssociation corresponding to the type given as template parameter.

該函數在 Qt 6.0 引入。

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

插入 keycontainer if possible. If the container has mapped values a default-create mapped value is associated with the key .

另請參閱 canInsertKey ().

void QMetaAssociation:: 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.

另請參閱 canGetKeyAtConstIterator (), constBegin (), constEnd (),和 createConstIteratorAtKey ().

void QMetaAssociation:: 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.

另請參閱 canGetKeyAtIterator (), begin (), end (),和 createIteratorAtKey ().

QMetaType QMetaAssociation:: keyMetaType () const

Returns the meta type for keys in the container.

void QMetaAssociation:: 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.

另請參閱 canGetMappedAtConstIterator (), constBegin (), constEnd (),和 createConstIteratorAtKey ().

void QMetaAssociation:: 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.

另請參閱 setMappedAtIterator (), canGetMappedAtIterator (), begin (), end (),和 createIteratorAtKey ().

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

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

另請參閱 setMappedAtKey () 和 canGetMappedAtKey ().

QMetaType QMetaAssociation:: mappedMetaType () const

Returns the meta type for mapped values in the container.

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

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

另請參閱 canRemoveKey ().

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

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

另請參閱 mappedAtIterator (), canSetMappedAtIterator (), begin (), end (),和 createIteratorAtKey ().

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

Overwrites the value associated with the keycontainer 使用 mapped value passed as argument if that is possible.

另請參閱 mappedAtKey () 和 canSetMappedAtKey ().

相關非成員

[noexcept] bool operator!= (const QMetaAssociation & lhs , const QMetaAssociation & rhs )

返迴 true QMetaAssociation lhs represents a different container type than the QMetaAssociation rhs ,否則返迴 false .

[noexcept] bool operator== (const QMetaAssociation & lhs , const QMetaAssociation & rhs )

返迴 true QMetaAssociation lhs represents the same container type as the QMetaAssociation rhs ,否則返迴 false .