The QMetaSequence class allows type erased access to sequential containers. More...
Header: | #include <QMetaSequence> |
CMake: | find_package(Qt6 COMPONENTS Core REQUIRED) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
Since: | Qt 6.0 |
Inherits: | QMetaContainer |
void | addValue(void *container, const void *value) const |
void | addValueAtBegin(void *container, const void *value) const |
void | addValueAtEnd(void *container, const void *value) const |
bool | canAddValue() const |
bool | canAddValueAtBegin() const |
bool | canAddValueAtEnd() const |
bool | canEraseRangeAtIterator() const |
bool | canEraseValueAtIterator() const |
bool | canGetValueAtConstIterator() const |
bool | canGetValueAtIndex() const |
bool | canGetValueAtIterator() const |
bool | canInsertValueAtIterator() const |
bool | canRemoveValue() const |
bool | canRemoveValueAtBegin() const |
bool | canRemoveValueAtEnd() const |
bool | canSetValueAtIndex() const |
bool | canSetValueAtIterator() const |
void | eraseRangeAtIterator(void *container, const void *iterator1, const void *iterator2) const |
void | eraseValueAtIterator(void *container, const void *iterator) const |
void | insertValueAtIterator(void *container, const void *iterator, const void *value) const |
bool | isSortable() const |
void | removeValue(void *container) const |
void | removeValueAtBegin(void *container) const |
void | removeValueAtEnd(void *container) const |
void | setValueAtIndex(void *container, qsizetype index, const void *value) const |
void | setValueAtIterator(const void *iterator, const void *value) const |
void | valueAtConstIterator(const void *iterator, void *result) const |
void | valueAtIndex(const void *container, qsizetype index, void *result) const |
void | valueAtIterator(const void *iterator, void *result) const |
QMetaType | valueMetaType() const |
QMetaSequence | fromContainer() |
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.
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() or 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.
Adds value to the container if possible. If canAddValue() returns false
, the value is not added. Else, if canAddValueAtEnd() returns true
, the value is added to the end of the container. Else, if canAddValueAtBegin() returns true
, the value is added to the beginning of the container. Else, the value is added in an unspecified place or not at all. The latter is the case for adding values to an unordered container, for example QSet.
See also canAddValue(), canAddValueAtBegin(), canAddValueAtEnd(), isSortable(), and removeValue().
Adds value to the beginning of container if possible. If canAddValueAtBegin() returns false
, the value is not added.
See also canAddValueAtBegin(), isSortable(), and removeValueAtBegin().
Adds value to the end of container if possible. If canAddValueAtEnd() returns false
, the value is not added.
See also canAddValueAtEnd(), isSortable(), and removeValueAtEnd().
Returns true
if values can be added to the container, false
otherwise.
See also addValue() and isSortable().
Returns true
if values added using addValue() can be placed at the beginning of the container, otherwise returns false
.
See also addValueAtBegin() and canAddValueAtEnd().
Returns true
if values added using addValue() can be placed at the end of the container, otherwise returns false
.
See also addValueAtEnd() and canAddValueAtBegin().
Returns true
if a range between two iterators can be erased from the container, false
otherwise.
Returns true
if the value pointed to by a non-const iterator can be erased, false
otherwise.
See also hasIterator() and eraseValueAtIterator().
Returns true
if the underlying container can retrieve the value pointed to by a const iterator, false
otherwise.
See also hasConstIterator() and valueAtConstIterator().
Returns true
if values can be retrieved from the container by index, otherwise false
.
See also valueAtIndex().
Returns true
if the underlying container can retrieve the value pointed to by a non-const iterator, false
otherwise.
See also hasIterator() and valueAtIterator().
Returns true
if the underlying container can insert a new value, taking the location pointed to by a non-const iterator into account.
See also hasIterator() and insertValueAtIterator().
Returns true
if values can be removed from the container, false
otherwise.
See also removeValue() and isSortable().
Returns true
if values can be removed from the beginning of the container using removeValue() can be placed at the, otherwise returns false
.
See also removeValueAtBegin() and canRemoveValueAtEnd().
Returns true
if values can be removed from the end of the container using removeValue() can be placed at the, otherwise returns false
.
See also removeValueAtEnd() and canRemoveValueAtBegin().
Returns true
if an value can be written to the container by index, otherwise false
.
See also setValueAtIndex().
Returns true
if the underlying container can write to the value pointed to by a non-const iterator, false
otherwise.
See also hasIterator() and setValueAtIterator().
Erases the range of values between the iterators iterator1 and iterator2 from the container, if possible.
See also canEraseValueAtIterator(), begin(), and end().
Erases the value pointed to by the non-const iterator from the container, if possible.
See also canEraseValueAtIterator(), begin(), and end().
[static, since 6.0]
template <typename T> QMetaSequence QMetaSequence::fromContainer()
Returns the QMetaSequence corresponding to the type given as template parameter.
This function was introduced in Qt 6.0.
Inserts value into the container, if possible, taking the non-const iterator into account. If canInsertValueAtIterator() returns false
, the value is not inserted. Else if isSortable() returns true
, the value is inserted before the value pointed to by iterator. Else, the value is inserted at an unspecified place or not at all. In the latter case, the iterator is taken as a hint. If it points to the correct place for the value, the operation may be faster than a addValue() without iterator.
See also canInsertValueAtIterator(), isSortable(), begin(), and end().
Returns true
if the underlying container is sortable, otherwise returns false
. A container is considered sortable if values added to it are placed in a defined location. Inserting into or adding to a sortable container will always succeed. Inserting into or adding to an unsortable container may not succeed, for example if the container is a QSet that already contains the value being inserted.
See also addValue(), insertValueAtIterator(), canAddValueAtBegin(), canAddValueAtEnd(), canRemoveValueAtBegin(), and canRemoveValueAtEnd().
Removes an value from the container if possible. If canRemoveValue() returns false
, no value is removed. Else, if canRemoveValueAtEnd() returns true
, the last value in the container is removed. Else, if canRemoveValueAtBegin() returns true
, the first value in the container is removed. Else, an unspecified value or nothing is removed.
See also canRemoveValue(), canRemoveValueAtBegin(), canRemoveValueAtEnd(), isSortable(), and addValue().
Removes a value from the beginning of container if possible. If canRemoveValueAtBegin() returns false
, the value is not removed.
See also canRemoveValueAtBegin(), isSortable(), and addValueAtBegin().
Removes a value from the end of container if possible. If canRemoveValueAtEnd() returns false
, the value is not removed.
See also canRemoveValueAtEnd(), isSortable(), and addValueAtEnd().
Overwrites the value at index in the container using the value passed as parameter if that is possible.
See also valueAtIndex() and canSetValueAtIndex().
Writes value to the value pointed to by the non-const iterator, if possible.
See also valueAtIterator(), canSetValueAtIterator(), begin(), and end().
Retrieves the value pointed to by the const iterator and stores it in the memory location pointed to by result, if possible.
See also canGetValueAtConstIterator(), constBegin(), and constEnd().
Retrieves the value at index in the container and places it in the memory location pointed to by result, if that is possible.
See also setValueAtIndex() and canGetValueAtIndex().
Retrieves the value pointed to by the non-const iterator and stores it in the memory location pointed to by result, if possible.
See also setValueAtIterator(), canGetValueAtIterator(), begin(), and end().
Returns the meta type for values stored in the container.
© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-6.2/qmetasequence.html