IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QMetaSequence Class

The QMetaSequence class allows type erased access to sequential containers.

This class was introduced in Qt 6.0.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QMetaSequence Class

  • Header: QMetaSequence

  • Since: Qt 6.0

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS Core)

    target_link_libraries(mytarget PRIVATE Qt6::Core)

  • qmake: QT += core

  • Inherits: QMetaContainer

  • Group: QMetaSequence is part of objectmodel

Detailed Description

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.

Member Function Documentation

 

void QMetaSequence::addValue(void *container, const void *value) const

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

void QMetaSequence::addValueAtBegin(void *container, const void *value) const

Adds value to the beginning of container if possible. If canAddValueAtBegin() returns false, the value is not added.

See Also

void QMetaSequence::addValueAtEnd(void *container, const void *value) const

Adds value to the end of container if possible. If canAddValueAtEnd() returns false, the value is not added.

See Also

bool QMetaSequence::canAddValue() const

Returns true if values can be added to the container, false otherwise.

See Also

See also addValue(), isSortable()

bool QMetaSequence::canAddValueAtBegin() const

Returns true if values added using addValue() can be placed at the beginning of the container, otherwise returns false.

See Also

bool QMetaSequence::canAddValueAtEnd() const

Returns true if values added using addValue() can be placed at the end of the container, otherwise returns false.

See Also

bool QMetaSequence::canEraseRangeAtIterator() const

Returns true if a range between two iterators can be erased from the container, false otherwise.

bool QMetaSequence::canEraseValueAtIterator() const

Returns true if the value pointed to by a non-const iterator can be erased, false otherwise.

See Also

bool QMetaSequence::canGetValueAtConstIterator() const

Returns true if the underlying container can retrieve the value pointed to by a const iterator, false otherwise.

See Also

bool QMetaSequence::canGetValueAtIndex() const

Returns true if values can be retrieved from the container by index, otherwise false.

See Also

See also valueAtIndex()

bool QMetaSequence::canGetValueAtIterator() const

Returns true if the underlying container can retrieve the value pointed to by a non-const iterator, false otherwise.

See Also

bool QMetaSequence::canInsertValueAtIterator() const

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

bool QMetaSequence::canRemoveValue() const

Returns true if values can be removed from the container, false otherwise.

See Also

See also removeValue(), isSortable()

bool QMetaSequence::canRemoveValueAtBegin() const

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

bool QMetaSequence::canRemoveValueAtEnd() const

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

bool QMetaSequence::canSetValueAtIndex() const

Returns true if an value can be written to the container by index, otherwise false.

See Also

See also setValueAtIndex()

bool QMetaSequence::canSetValueAtIterator() const

Returns true if the underlying container can write to the value pointed to by a non-const iterator, false otherwise.

See Also

void QMetaSequence::eraseRangeAtIterator(void *container, const void *iterator1, const void *iterator2) const

Erases the range of values between the iterators iterator1 and iterator2 from the container, if possible.

See Also

See also canEraseValueAtIterator(), begin(), end()

void QMetaSequence::eraseValueAtIterator(void *container, const void *iterator) const

Erases the value pointed to by the non-const iterator from the container, if possible.

See Also

See also canEraseValueAtIterator(), begin(), end()

[static constexpr, since 6.0] QMetaSequence QMetaSequence::fromContainer()

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

This function was introduced in Qt 6.0.

void QMetaSequence::insertValueAtIterator(void *container, const void *iterator, const void *value) const

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

bool QMetaSequence::isSortable() const

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

void QMetaSequence::removeValue(void *container) const

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

void QMetaSequence::removeValueAtBegin(void *container) const

Removes a value from the beginning of container if possible. If canRemoveValueAtBegin() returns false, the value is not removed.

See Also

void QMetaSequence::removeValueAtEnd(void *container) const

Removes a value from the end of container if possible. If canRemoveValueAtEnd() returns false, the value is not removed.

See Also

void QMetaSequence::setValueAtIndex(void *container, qsizetype index, const void *value) const

Overwrites the value at index in the container using the value passed as parameter if that is possible.

See Also

void QMetaSequence::setValueAtIterator(const void *iterator, const void *value) const

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

See Also

void QMetaSequence::valueAtConstIterator(const void *iterator, void *result) const

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

See Also

void QMetaSequence::valueAtIndex(const void *container, qsizetype index, void *result) const

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

void QMetaSequence::valueAtIterator(const void *iterator, void *result) const

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

QMetaType QMetaSequence::valueMetaType() const

Returns the meta type for values stored in the container.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+