QMetaAssociation Class
Die Klasse QMetaAssociation ermöglicht den typgelöschten Zugriff auf assoziative Container. Mehr...
| Kopfzeile: | #include <QMetaAssociation> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core)target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
| Seit: | Qt 6.0 |
| Vererbt: | QMetaContainer |
Diese Klasse ist gleichwertig vergleichbar.
Öffentliche Funktionen
| 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 |
Statische öffentliche Mitglieder
(since 6.0) QMetaAssociation | fromContainer() |
Verwandte Nicht-Mitglieder
| bool | operator!=(const QMetaAssociation &lhs, const QMetaAssociation &rhs) |
| bool | operator==(const QMetaAssociation &lhs, const QMetaAssociation &rhs) |
Detaillierte Beschreibung
Die Klasse bietet eine Reihe von primitiven Containeroperationen, die void* als Operanden verwenden. Auf diese Weise können Sie einen generischen Container, der von einer Variante abgerufen wird, manipulieren, ohne seinen Typ zu kennen.
QMetaAssociation umfasst sowohl Container mit zugeordneten Werten wie QMap oder QHash als auch Container, die nur Schlüssel enthalten wie QSet.
Die void*-Argumente für die verschiedenen Methoden werden in der Regel durch die Verwendung eines QVariant des jeweiligen Container- oder Wertetyps und den Aufruf seiner Methoden QVariant::data() oder QVariant::constData() erzeugt. Sie können jedoch auch einfache Zeiger auf Objekte des Container- oder Wertetyps übergeben.
Die Invalidierung von Iteratoren folgt den Regeln, die von den zugrunde liegenden Containern vorgegeben werden, und wird nicht in der API ausgedrückt. Daher sollten bei einem wirklich generischen Container alle Iteratoren nach jedem Schreibvorgang als ungültig betrachtet werden.
Siehe auch QMetaContainer, QMetaSequence, QIterable, und QIterator.
Dokumentation der Mitgliedsfunktionen
bool QMetaAssociation::canContainsKey() const
Gibt true zurück, wenn der Container mit containsKey() nach Schlüsseln abgefragt werden kann, andernfalls wird false zurückgegeben.
bool QMetaAssociation::canCreateConstIteratorAtKey() const
Gibt true zurück, wenn ein konstanter Iterator, der auf einen Eintrag im Container zeigt, mit createConstIteratorAtKey() erstellt werden kann, andernfalls wird false zurückgegeben.
bool QMetaAssociation::canCreateIteratorAtKey() const
Gibt true zurück, wenn ein Iterator, der auf einen Eintrag im Container zeigt, mit createIteratorAtKey() erstellt werden kann, andernfalls wird false zurückgegeben.
Siehe auch createIteratorAtKey().
bool QMetaAssociation::canGetKeyAtConstIterator() const
Gibt true zurück, wenn ein Schlüssel von einem const-Iterator mit keyAtConstIterator() abgerufen werden kann, andernfalls false.
Siehe auch keyAtConstIterator().
bool QMetaAssociation::canGetKeyAtIterator() const
Gibt true zurück, wenn ein Schlüssel von einem nicht-konstanten Iterator mit keyAtIterator() abgerufen werden kann, andernfalls wird false zurückgegeben.
Siehe auch keyAtIterator().
bool QMetaAssociation::canGetMappedAtConstIterator() const
Gibt true zurück, wenn ein zugeordneter Wert von einem Konst-Iterator mit mappedAtConstIterator() abgerufen werden kann, andernfalls false.
Siehe auch mappedAtConstIterator().
bool QMetaAssociation::canGetMappedAtIterator() const
Gibt true zurück, wenn ein zugeordneter Wert von einem nicht-konstanten Iterator mit mappedAtIterator() abgerufen werden kann, andernfalls wird false zurückgegeben.
Siehe auch mappedAtIterator().
bool QMetaAssociation::canGetMappedAtKey() const
Gibt true zurück, wenn der Container mit mappedAtKey() nach Werten abgefragt werden kann, andernfalls wird false zurückgegeben.
bool QMetaAssociation::canInsertKey() const
Gibt true zurück, wenn dem Container mit insertKey() Schlüssel hinzugefügt werden können, andernfalls wird false zurückgegeben.
Siehe auch insertKey().
bool QMetaAssociation::canRemoveKey() const
Gibt true zurück, wenn Schlüssel mit removeKey() aus dem Container entfernt werden können, andernfalls wird false zurückgegeben.
Siehe auch removeKey().
bool QMetaAssociation::canSetMappedAtIterator() const
Gibt true zurück, wenn ein gemappter Wert über einen Nicht-Konst-Iterator mit setMappedAtIterator() gesetzt werden kann, andernfalls false.
Siehe auch setMappedAtIterator().
bool QMetaAssociation::canSetMappedAtKey() const
Gibt true zurück, wenn gemappte Werte im Container mit setMappedAtKey() geändert werden können, andernfalls gibt es false zurück.
Siehe auch setMappedAtKey().
bool QMetaAssociation::containsKey(const void *container, const void *key) const
Gibt true zurück, wenn die container nach Schlüsseln abgefragt werden kann und die key enthält, andernfalls false.
Siehe auch canContainsKey().
void *QMetaAssociation::createConstIteratorAtKey(const void *container, const void *key) const
Gibt einen konstanten Iterator zurück, der auf den Eintrag von key in container zeigt, falls möglich. Wenn der Eintrag nicht existiert, wird ein konstanter Iterator erstellt, der auf das Ende von container zeigt. Wenn kein konstanter Iterator erstellt werden kann, wird nullptr zurückgegeben.
Der const-Iterator muss mit destroyConstIterator() zerstört werden.
Siehe auch canCreateConstIteratorAtKey(), constBegin(), constEnd(), und destroyConstIterator().
void *QMetaAssociation::createIteratorAtKey(void *container, const void *key) const
Gibt einen nicht-konstanten Iterator zurück, der auf den Eintrag von key in container zeigt, falls möglich. Existiert der Eintrag nicht, wird ein Non-Const-Iterator erzeugt, der auf das Ende von container zeigt. Kann kein Non-Const-Iterator erzeugt werden, wird nullptr zurückgegeben.
Der nicht-konstante Iterator muss mit destroyIterator() zerstört werden.
Siehe auch canCreateIteratorAtKey(), begin(), end(), und destroyIterator().
[static constexpr, since 6.0] template <typename T> QMetaAssociation QMetaAssociation::fromContainer()
Gibt die QMetaAssociation zurück, die dem als Template-Parameter angegebenen Typ entspricht.
Diese Funktion wurde in Qt 6.0 eingeführt.
void QMetaAssociation::insertKey(void *container, const void *key) const
Fügt den key nach Möglichkeit in den container ein. Wenn der Container über zugeordnete Werte verfügt, wird ein standardmäßig erstellter zugeordneter Wert mit dem key verbunden.
Siehe auch canInsertKey().
void QMetaAssociation::keyAtConstIterator(const void *iterator, void *key) const
Ruft den Schlüssel ab, auf den die Konstante iterator zeigt, und speichert ihn an der Speicherstelle, auf die key zeigt, falls möglich.
Siehe auch canGetKeyAtConstIterator(), constBegin(), constEnd(), und createConstIteratorAtKey().
void QMetaAssociation::keyAtIterator(const void *iterator, void *key) const
Ruft den Schlüssel ab, auf den die Nicht-Konstante iterator zeigt, und speichert ihn an der Speicherstelle, auf die key zeigt, falls möglich.
Siehe auch canGetKeyAtIterator(), begin(), end(), und createIteratorAtKey().
QMetaType QMetaAssociation::keyMetaType() const
Gibt den Metatyp für Schlüssel im Container zurück.
void QMetaAssociation::mappedAtConstIterator(const void *iterator, void *mapped) const
Ruft den gemappten Wert ab, auf den die Konstante iterator zeigt, und speichert ihn an der Speicherstelle, auf die mapped zeigt, falls möglich.
Siehe auch canGetMappedAtConstIterator(), constBegin(), constEnd(), und createConstIteratorAtKey().
void QMetaAssociation::mappedAtIterator(const void *iterator, void *mapped) const
Ruft den gemappten Wert ab, auf den die Nicht-Konstante iterator zeigt, und speichert ihn an der Speicherstelle, auf die mapped zeigt, falls möglich.
Siehe auch setMappedAtIterator(), canGetMappedAtIterator(), begin(), end(), und createIteratorAtKey().
void QMetaAssociation::mappedAtKey(const void *container, const void *key, void *mapped) const
Ruft den gemappten Wert ab, der mit key in container verknüpft ist, und legt ihn an der Speicherstelle ab, auf die mapped verweist, sofern dies möglich ist.
Siehe auch setMappedAtKey() und canGetMappedAtKey().
QMetaType QMetaAssociation::mappedMetaType() const
Gibt den Metatyp für zugeordnete Werte im Container zurück.
void QMetaAssociation::removeKey(void *container, const void *key) const
Entfernt key und den zugehörigen gemappten Wert aus container, wenn möglich.
Siehe auch canRemoveKey().
void QMetaAssociation::setMappedAtIterator(const void *iterator, const void *mapped) const
Schreibt den Wert mapped in den Container, auf den die Nicht-Konstante iterator zeigt, sofern möglich.
Siehe auch mappedAtIterator(), canSetMappedAtIterator(), begin(), end(), und createIteratorAtKey().
void QMetaAssociation::setMappedAtKey(void *container, const void *key, const void *mapped) const
Überschreibt den mit key verbundenen Wert in container mit dem als Argument übergebenen Wert mapped, sofern dies möglich ist.
Siehe auch mappedAtKey() und canSetMappedAtKey().
Verwandte Nicht-Mitglieder
[noexcept] bool operator!=(const QMetaAssociation &lhs, const QMetaAssociation &rhs)
Gibt true zurück, wenn QMetaAssociation lhs einen anderen Containertyp repräsentiert als QMetaAssociation rhs , andernfalls false.
[noexcept] bool operator==(const QMetaAssociation &lhs, const QMetaAssociation &rhs)
Gibt true zurück, wenn QMetaAssociation lhs denselben Containertyp repräsentiert wie QMetaAssociation rhs , andernfalls false.
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.