![]() |
Qt 6.x
The Qt SDK
|
\inmodule QtCore More...
#include <qmetacontainer.h>
Public Member Functions | |
QMetaSequence ()=default | |
QMetaSequence (const QtMetaContainerPrivate::QMetaSequenceInterface *d) | |
QMetaType | valueMetaType () const |
Returns the meta type for values stored in the container. | |
bool | isSortable () const |
Returns true if the underlying container is sortable, otherwise returns false . | |
bool | canAddValueAtBegin () const |
Returns true if values added using \l addValue() can be placed at the beginning of the container, otherwise returns false . | |
void | addValueAtBegin (void *container, const void *value) const |
Adds value to the beginning of container if possible. | |
bool | canAddValueAtEnd () const |
Returns true if values added using \l addValue() can be placed at the end of the container, otherwise returns false . | |
void | addValueAtEnd (void *container, const void *value) const |
Adds value to the end of container if possible. | |
bool | canRemoveValueAtBegin () const |
Returns true if values can be removed from the beginning of the container using \l removeValue() can be placed at the, otherwise returns false . | |
void | removeValueAtBegin (void *container) const |
Removes a value from the beginning of container if possible. | |
bool | canRemoveValueAtEnd () const |
Returns true if values can be removed from the end of the container using \l removeValue() can be placed at the, otherwise returns false . | |
void | removeValueAtEnd (void *container) const |
Removes a value from the end of container if possible. | |
bool | canGetValueAtIndex () const |
Returns true if values can be retrieved from the container by index, otherwise false . | |
void | 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. | |
bool | canSetValueAtIndex () const |
Returns true if an value can be written to the container by index, otherwise false . | |
void | 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. | |
bool | canAddValue () const |
Returns true if values can be added to the container, false otherwise. | |
void | addValue (void *container, const void *value) const |
Adds value to the container if possible. | |
bool | canRemoveValue () const |
Returns true if values can be removed from the container, false otherwise. | |
void | removeValue (void *container) const |
Removes an value from the container if possible. | |
bool | canGetValueAtIterator () const |
Returns true if the underlying container can retrieve the value pointed to by a non-const iterator, false otherwise. | |
void | 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. | |
bool | canSetValueAtIterator () const |
Returns true if the underlying container can write to the value pointed to by a non-const iterator, false otherwise. | |
void | setValueAtIterator (const void *iterator, const void *value) const |
Writes value to the value pointed to by the non-const iterator, if possible. | |
bool | 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. | |
void | insertValueAtIterator (void *container, const void *iterator, const void *value) const |
Inserts value into the container, if possible, taking the non-const iterator into account. | |
bool | canEraseValueAtIterator () const |
Returns true if the value pointed to by a non-const iterator can be erased, false otherwise. | |
void | eraseValueAtIterator (void *container, const void *iterator) const |
Erases the value pointed to by the non-const iterator from the container, if possible. | |
bool | canEraseRangeAtIterator () const |
Returns true if a range between two iterators can be erased from the container, false otherwise. | |
void | 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. | |
bool | canGetValueAtConstIterator () const |
Returns true if the underlying container can retrieve the value pointed to by a const iterator, false otherwise. | |
void | 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. | |
const QtMetaContainerPrivate::QMetaSequenceInterface * | iface () const |
![]() | |
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. | |
void * | begin (void *container) const |
Creates and returns a non-const iterator pointing to the beginning of container. | |
void * | end (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. | |
void * | constBegin (const void *container) const |
Creates and returns a const iterator pointing to the beginning of container. | |
void * | constEnd (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 QMetaSequence | fromContainer () |
Friends | |
bool | operator== (const QMetaSequence &a, const QMetaSequence &b) |
bool | operator!= (const QMetaSequence &a, const QMetaSequence &b) |
Related Symbols | |
(Note that these are not member symbols.) | |
bool | operator== (QMetaSequence a, QMetaSequence b) |
bool | operator!= (QMetaSequence a, QMetaSequence b) |
Additional Inherited Members | |
![]() | |
const QtMetaContainerPrivate::QMetaContainerInterface * | d_ptr = nullptr |
\inmodule QtCore
The QMetaSequence class allows type erased access to sequential containers.
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 \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.
Definition at line 924 of file qmetacontainer.h.
|
default |
|
inlineexplicit |
Definition at line 928 of file qmetacontainer.h.
Adds value to the container if possible.
If \l canAddValue() returns false
, the value is not added. Else, if \l canAddValueAtEnd() returns true
, the value is added to the end of the container. Else, if \l 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 \l QSet.
Definition at line 363 of file qmetacontainer.cpp.
References QtMetaContainerPrivate::QMetaSequenceInterface::addValueFn, canAddValue(), and QtMetaContainerPrivate::QMetaContainerInterface::Unspecified.
Referenced by QSequentialIterable::addValue(), and QQmlPropertyPrivate::write().
Adds value to the beginning of container if possible.
If \l canAddValueAtBegin() returns false
, the value is not added.
Definition at line 157 of file qmetacontainer.cpp.
References QtMetaContainerPrivate::QMetaSequenceInterface::addValueFn, QtMetaContainerPrivate::QMetaContainerInterface::AtBegin, and canAddValueAtBegin().
Referenced by QSequentialIterable::addValue().
Adds value to the end of container if possible.
If \l canAddValueAtEnd() returns false
, the value is not added.
Definition at line 211 of file qmetacontainer.cpp.
References QtMetaContainerPrivate::QMetaSequenceInterface::addValueFn, QtMetaContainerPrivate::QMetaContainerInterface::AtEnd, and canAddValueAtEnd().
Referenced by QSequentialIterable::addValue(), QV4::SequencePrototype::toVariant(), and QQmlPropertyPrivate::write().
bool QMetaSequence::canAddValue | ( | ) | const |
Returns true
if values can be added to the container, false
otherwise.
Definition at line 343 of file qmetacontainer.cpp.
References QtMetaContainerPrivate::QMetaSequenceInterface::addValueFn, and iface().
Referenced by addValue(), and QQmlPropertyPrivate::write().
bool QMetaSequence::canAddValueAtBegin | ( | ) | const |
Returns true
if values added using \l addValue() can be placed at the beginning of the container, otherwise returns false
.
Definition at line 142 of file qmetacontainer.cpp.
References QtMetaContainerPrivate::QMetaSequenceInterface::addRemoveCapabilities, QtMetaContainerPrivate::QMetaSequenceInterface::addValueFn, QtMetaContainerPrivate::CanAddAtBegin, and iface().
Referenced by addValueAtBegin().
bool QMetaSequence::canAddValueAtEnd | ( | ) | const |
Returns true
if values added using \l addValue() can be placed at the end of the container, otherwise returns false
.
Definition at line 196 of file qmetacontainer.cpp.
References QtMetaContainerPrivate::QMetaSequenceInterface::addRemoveCapabilities, QtMetaContainerPrivate::QMetaSequenceInterface::addValueFn, QtMetaContainerPrivate::CanAddAtEnd, and iface().
Referenced by addValueAtEnd(), and QQmlPropertyPrivate::write().
bool QMetaSequence::canEraseRangeAtIterator | ( | ) | const |
Returns true
if a range between two iterators can be erased from the container, false
otherwise.
Definition at line 630 of file qmetacontainer.cpp.
References QtMetaContainerPrivate::QMetaSequenceInterface::eraseRangeAtIteratorFn, and iface().
Referenced by eraseRangeAtIterator().
bool QMetaSequence::canEraseValueAtIterator | ( | ) | const |
Returns true
if the value pointed to by a non-const iterator can be erased, false
otherwise.
Definition at line 607 of file qmetacontainer.cpp.
References QtMetaContainerPrivate::QMetaSequenceInterface::eraseValueAtIteratorFn, and iface().
Referenced by eraseValueAtIterator().
bool QMetaSequence::canGetValueAtConstIterator | ( | ) | const |
Returns true
if the underlying container can retrieve the value pointed to by a const iterator, false
otherwise.
Definition at line 773 of file qmetacontainer.cpp.
References iface(), and QtMetaContainerPrivate::QMetaSequenceInterface::valueAtConstIteratorFn.
Referenced by QSequentialIterable::at(), QV4::ExecutionEngine::fromData(), iterateQObjectContainer(), QQmlListAccessor::setList(), and valueAtConstIterator().
bool QMetaSequence::canGetValueAtIndex | ( | ) | const |
Returns true
if values can be retrieved from the container by index, otherwise false
.
Definition at line 293 of file qmetacontainer.cpp.
References iface(), and QtMetaContainerPrivate::QMetaSequenceInterface::valueAtIndexFn.
Referenced by QSequentialIterable::at(), QV4::ExecutionEngine::fromData(), QQmlListAccessor::setList(), and valueAtIndex().
bool QMetaSequence::canGetValueAtIterator | ( | ) | const |
Returns true
if the underlying container can retrieve the value pointed to by a non-const iterator, false
otherwise.
Definition at line 525 of file qmetacontainer.cpp.
References iface(), and QtMetaContainerPrivate::QMetaSequenceInterface::valueAtIteratorFn.
Referenced by valueAtIterator().
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.
Definition at line 575 of file qmetacontainer.cpp.
References iface(), and QtMetaContainerPrivate::QMetaSequenceInterface::insertValueAtIteratorFn.
Referenced by insertValueAtIterator().
bool QMetaSequence::canRemoveValue | ( | ) | const |
Returns true
if values can be removed from the container, false
otherwise.
Definition at line 377 of file qmetacontainer.cpp.
References iface(), and QtMetaContainerPrivate::QMetaSequenceInterface::removeValueFn.
Referenced by removeValue().
bool QMetaSequence::canRemoveValueAtBegin | ( | ) | const |
Returns true
if values can be removed from the beginning of the container using \l removeValue() can be placed at the, otherwise returns false
.
Definition at line 169 of file qmetacontainer.cpp.
References QtMetaContainerPrivate::QMetaSequenceInterface::addRemoveCapabilities, QtMetaContainerPrivate::CanRemoveAtBegin, iface(), and QtMetaContainerPrivate::QMetaSequenceInterface::removeValueFn.
Referenced by removeValueAtBegin().
bool QMetaSequence::canRemoveValueAtEnd | ( | ) | const |
Returns true
if values can be removed from the end of the container using \l removeValue() can be placed at the, otherwise returns false
.
Definition at line 223 of file qmetacontainer.cpp.
References QtMetaContainerPrivate::QMetaSequenceInterface::addRemoveCapabilities, QtMetaContainerPrivate::CanRemoveAtEnd, iface(), and QtMetaContainerPrivate::QMetaSequenceInterface::removeValueFn.
Referenced by removeValueAtEnd().
bool QMetaSequence::canSetValueAtIndex | ( | ) | const |
Returns true
if an value can be written to the container by index, otherwise false
.
Definition at line 318 of file qmetacontainer.cpp.
References iface(), and QtMetaContainerPrivate::QMetaSequenceInterface::setValueAtIndexFn.
Referenced by QSequentialIterable::set(), and 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.
Definition at line 550 of file qmetacontainer.cpp.
References iface(), and QtMetaContainerPrivate::QMetaSequenceInterface::setValueAtIteratorFn.
Referenced by QSequentialIterable::set(), and setValueAtIterator().
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.
Definition at line 643 of file qmetacontainer.cpp.
References canEraseRangeAtIterator(), and QtMetaContainerPrivate::QMetaSequenceInterface::eraseRangeAtIteratorFn.
Erases the value pointed to by the non-const iterator from the container, if possible.
Definition at line 620 of file qmetacontainer.cpp.
References canEraseValueAtIterator(), and QtMetaContainerPrivate::QMetaSequenceInterface::eraseValueAtIteratorFn.
|
inlinestaticconstexpr |
Returns the QMetaSequence corresponding to the type given as template parameter.
Definition at line 931 of file qmetacontainer.h.
|
inline |
Definition at line 987 of file qmetacontainer.h.
References d.
Referenced by canAddValue(), canAddValueAtBegin(), canAddValueAtEnd(), canEraseRangeAtIterator(), canEraseValueAtIterator(), canGetValueAtConstIterator(), canGetValueAtIndex(), canGetValueAtIterator(), canInsertValueAtIterator(), canRemoveValue(), canRemoveValueAtBegin(), canRemoveValueAtEnd(), canSetValueAtIndex(), canSetValueAtIterator(), isSortable(), QV4::Heap::Sequence::setVariant(), and valueMetaType().
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 \l canInsertValueAtIterator() returns false
, the value is not inserted. Else if \l 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 \l addValue() without iterator.
Definition at line 594 of file qmetacontainer.cpp.
References canInsertValueAtIterator(), and QtMetaContainerPrivate::QMetaSequenceInterface::insertValueAtIteratorFn.
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.
Definition at line 124 of file qmetacontainer.cpp.
References QtMetaContainerPrivate::QMetaSequenceInterface::addRemoveCapabilities, QtMetaContainerPrivate::CanAddAtBegin, QtMetaContainerPrivate::CanAddAtEnd, QtMetaContainerPrivate::CanRemoveAtBegin, QtMetaContainerPrivate::CanRemoveAtEnd, and iface().
Removes an value from the container if possible.
If \l canRemoveValue() returns false
, no value is removed. Else, if \l canRemoveValueAtEnd() returns true
, the last value in the container is removed. Else, if \l canRemoveValueAtBegin() returns true
, the first value in the container is removed. Else, an unspecified value or nothing is removed.
Definition at line 395 of file qmetacontainer.cpp.
References canRemoveValue(), QtMetaContainerPrivate::QMetaSequenceInterface::removeValueFn, and QtMetaContainerPrivate::QMetaContainerInterface::Unspecified.
Referenced by QSequentialIterable::removeValue().
Removes a value from the beginning of container if possible.
If \l canRemoveValueAtBegin() returns false
, the value is not removed.
Definition at line 184 of file qmetacontainer.cpp.
References QtMetaContainerPrivate::QMetaContainerInterface::AtBegin, canRemoveValueAtBegin(), and QtMetaContainerPrivate::QMetaSequenceInterface::removeValueFn.
Referenced by QSequentialIterable::removeValue().
Removes a value from the end of container if possible.
If \l canRemoveValueAtEnd() returns false
, the value is not removed.
Definition at line 238 of file qmetacontainer.cpp.
References QtMetaContainerPrivate::QMetaContainerInterface::AtEnd, canRemoveValueAtEnd(), and QtMetaContainerPrivate::QMetaSequenceInterface::removeValueFn.
Referenced by QSequentialIterable::removeValue().
Overwrites the value at index in the container using the value passed as parameter if that is possible.
Definition at line 331 of file qmetacontainer.cpp.
References canSetValueAtIndex(), and QtMetaContainerPrivate::QMetaSequenceInterface::setValueAtIndexFn.
Referenced by QSequentialIterable::set(), QQmlListAccessor::set(), and QV4::Sequence::virtualMetacall().
Writes value to the value pointed to by the non-const iterator, if possible.
Definition at line 563 of file qmetacontainer.cpp.
References canSetValueAtIterator(), and QtMetaContainerPrivate::QMetaSequenceInterface::setValueAtIteratorFn.
Referenced by QSequentialIterable::set().
Retrieves the value pointed to by the const iterator and stores it in the memory location pointed to by result, if possible.
Definition at line 786 of file qmetacontainer.cpp.
References canGetValueAtConstIterator(), and QtMetaContainerPrivate::QMetaSequenceInterface::valueAtConstIteratorFn.
Referenced by QSequentialIterable::at(), and iterateQObjectContainer().
Retrieves the value at index in the container and places it in the memory location pointed to by result, if that is possible.
Definition at line 306 of file qmetacontainer.cpp.
References canGetValueAtIndex(), and QtMetaContainerPrivate::QMetaSequenceInterface::valueAtIndexFn.
Referenced by QSequentialIterable::at(), QQmlListAccessor::at(), and QV4::Sequence::virtualMetacall().
Retrieves the value pointed to by the non-const iterator and stores it in the memory location pointed to by result, if possible.
Definition at line 538 of file qmetacontainer.cpp.
References canGetValueAtIterator(), and QtMetaContainerPrivate::QMetaSequenceInterface::valueAtIteratorFn.
QMetaType QMetaSequence::valueMetaType | ( | ) | const |
Returns the meta type for values stored in the container.
Definition at line 106 of file qmetacontainer.cpp.
References iface(), and QtMetaContainerPrivate::QMetaSequenceInterface::valueMetaType.
Referenced by QQmlListAccessor::at(), QQmlMetaType::registerSequentialContainer(), QQmlListAccessor::set(), and QV4::Sequence::virtualMetacall().
|
friend |
Definition at line 982 of file qmetacontainer.h.
|
related |
Returns true
if the QMetaSequence a represents a different container type than the QMetaSequence b, otherwise returns false
.
|
friend |
Definition at line 978 of file qmetacontainer.h.
|
related |
Returns true
if the QMetaSequence a represents the same container type as the QMetaSequence b, otherwise returns false
.