QMetaSequence 类

QMetaSequence 类允许类型擦除对顺序容器的访问。 更多...

头: #include <QMetaSequence>
CMake: find_package(Qt6 COMPONENTS Core REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
Since: Qt 6.0
继承: 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 () 或 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.

成员函数文档编制

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

添加 value container if possible. If canAddValue () 返回 false value is not added. Else, if canAddValueAtEnd () 返回 true value is added to the end of the container . Else, if canAddValueAtBegin () 返回 true 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 .

另请参阅 canAddValue (), canAddValueAtBegin (), canAddValueAtEnd (), isSortable (),和 removeValue ().

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

添加 value to the beginning of container if possible. If canAddValueAtBegin () 返回 false value is not added.

另请参阅 canAddValueAtBegin (), isSortable (),和 removeValueAtBegin ().

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

添加 value to the end of container if possible. If canAddValueAtEnd () 返回 false value is not added.

另请参阅 canAddValueAtEnd (), isSortable (),和 removeValueAtEnd ().

bool QMetaSequence:: canAddValue () const

返回 true if values can be added to the container, false 否则。

另请参阅 addValue () 和 isSortable ().

bool QMetaSequence:: canAddValueAtBegin () const

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

另请参阅 addValueAtBegin () 和 canAddValueAtEnd ().

bool QMetaSequence:: canAddValueAtEnd () const

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

另请参阅 addValueAtEnd () 和 canAddValueAtBegin ().

bool QMetaSequence:: canEraseRangeAtIterator () const

返回 true if a range between two iterators can be erased from the container, false 否则。

bool QMetaSequence:: canEraseValueAtIterator () const

返回 true if the value pointed to by a non-const iterator can be erased, false 否则。

另请参阅 hasIterator () 和 eraseValueAtIterator ().

bool QMetaSequence:: canGetValueAtConstIterator () const

返回 true if the underlying container can retrieve the value pointed to by a const iterator, false 否则。

另请参阅 hasConstIterator () 和 valueAtConstIterator ().

bool QMetaSequence:: canGetValueAtIndex () const

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

另请参阅 valueAtIndex ().

bool QMetaSequence:: canGetValueAtIterator () const

返回 true if the underlying container can retrieve the value pointed to by a non-const iterator, false 否则。

另请参阅 hasIterator () 和 valueAtIterator ().

bool QMetaSequence:: canInsertValueAtIterator () const

返回 true if the underlying container can insert a new value, taking the location pointed to by a non-const iterator into account.

另请参阅 hasIterator () 和 insertValueAtIterator ().

bool QMetaSequence:: canRemoveValue () const

返回 true if values can be removed from the container, false 否则。

另请参阅 removeValue () 和 isSortable ().

bool QMetaSequence:: canRemoveValueAtBegin () const

返回 true if values can be removed from the beginning of the container using removeValue () can be placed at the, otherwise returns false .

另请参阅 removeValueAtBegin () 和 canRemoveValueAtEnd ().

bool QMetaSequence:: canRemoveValueAtEnd () const

返回 true if values can be removed from the end of the container using removeValue () can be placed at the, otherwise returns false .

另请参阅 removeValueAtEnd () 和 canRemoveValueAtBegin ().

bool QMetaSequence:: canSetValueAtIndex () const

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

另请参阅 setValueAtIndex ().

bool QMetaSequence:: canSetValueAtIterator () const

返回 true if the underlying container can write to the value pointed to by a non-const iterator, false 否则。

另请参阅 hasIterator () 和 setValueAtIterator ().

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

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

另请参阅 canEraseValueAtIterator (), begin (),和 end ().

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

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

另请参阅 canEraseValueAtIterator (), begin (),和 end ().

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

返回 QMetaSequence corresponding to the type given as template parameter.

该函数在 Qt 6.0 引入。

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

插入 value container , if possible, taking the non-const iterator into account. If canInsertValueAtIterator () 返回 false value is not inserted. Else if isSortable () 返回 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.

另请参阅 canInsertValueAtIterator (), isSortable (), begin (),和 end ().

bool QMetaSequence:: isSortable () const

返回 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.

另请参阅 addValue (), insertValueAtIterator (), canAddValueAtBegin (), canAddValueAtEnd (), canRemoveValueAtBegin (),和 canRemoveValueAtEnd ().

void QMetaSequence:: removeValue ( void * container ) const

Removes an value from the container if possible. If canRemoveValue () 返回 false , no value is removed. Else, if canRemoveValueAtEnd () 返回 true , the last value in the container is removed. Else, if canRemoveValueAtBegin () 返回 true , the first value in the container is removed. Else, an unspecified value or nothing is removed.

另请参阅 canRemoveValue (), canRemoveValueAtBegin (), canRemoveValueAtEnd (), isSortable (),和 addValue ().

void QMetaSequence:: removeValueAtBegin ( void * container ) const

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

另请参阅 canRemoveValueAtBegin (), isSortable (),和 addValueAtBegin ().

void QMetaSequence:: removeValueAtEnd ( void * container ) const

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

另请参阅 canRemoveValueAtEnd (), isSortable (),和 addValueAtEnd ().

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

Overwrites the value at index container 使用 value passed as parameter if that is possible.

另请参阅 valueAtIndex () 和 canSetValueAtIndex ().

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

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

另请参阅 valueAtIterator (), canSetValueAtIterator (), begin (),和 end ().

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.

另请参阅 canGetValueAtConstIterator (), constBegin (),和 constEnd ().

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

Retrieves the value at index container and places it in the memory location pointed to by result , if that is possible.

另请参阅 setValueAtIndex () 和 canGetValueAtIndex ().

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.

另请参阅 setValueAtIterator (), canGetValueAtIterator (), begin (),和 end ().

QMetaType QMetaSequence:: valueMetaType () const

Returns the meta type for values stored in the container.