Rename QMetaSequence's "elements" to "values"
This is so that they are in line with the "value_type" usually found in containers. Associative containers have "key_type" and "mapped_type" and we will use those names for access to elements in QMetaAssociation. Using "value" as name for sequential containers improves consistency. Change-Id: I628b7e1446bb2d56843b843bca72d279a6b247e6 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
e460addc42
commit
549b7053a2
@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE
|
||||
\inmodule QtCore
|
||||
\brief The QSequentialIterable class is an iterable interface for a container in a QVariant.
|
||||
|
||||
This class allows several methods of accessing the elements of a container held within
|
||||
This class allows several methods of accessing the values of a container held within
|
||||
a QVariant. An instance of QSequentialIterable can be extracted from a QVariant if it can
|
||||
be converted to a QVariantList.
|
||||
|
||||
@ -89,7 +89,7 @@ QSequentialIterable::const_iterator QSequentialIterable::end() const
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the element at position \a idx in the container.
|
||||
Returns the value at position \a idx in the container.
|
||||
*/
|
||||
QVariant QSequentialIterable::at(qsizetype idx) const
|
||||
{
|
||||
@ -101,12 +101,12 @@ QVariant QSequentialIterable::at(qsizetype idx) const
|
||||
dataPtr = v.data();
|
||||
|
||||
const QMetaSequence metaSequence = m_metaSequence;
|
||||
if (metaSequence.canGetElementAtIndex()) {
|
||||
metaSequence.elementAtIndex(m_iterable.constPointer(), idx, dataPtr);
|
||||
} else if (metaSequence.canGetElementAtConstIterator()) {
|
||||
if (metaSequence.canGetValueAtIndex()) {
|
||||
metaSequence.valueAtIndex(m_iterable.constPointer(), idx, dataPtr);
|
||||
} else if (metaSequence.canGetValueAtConstIterator()) {
|
||||
void *iterator = metaSequence.constBegin(m_iterable.constPointer());
|
||||
metaSequence.advanceConstIterator(iterator, idx);
|
||||
metaSequence.elementAtConstIterator(iterator, dataPtr);
|
||||
metaSequence.valueAtConstIterator(iterator, dataPtr);
|
||||
metaSequence.destroyConstIterator(iterator);
|
||||
}
|
||||
|
||||
@ -114,7 +114,7 @@ QVariant QSequentialIterable::at(qsizetype idx) const
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the number of elements in the container.
|
||||
Returns the number of values in the container.
|
||||
*/
|
||||
qsizetype QSequentialIterable::size() const
|
||||
{
|
||||
@ -207,7 +207,7 @@ const QVariant QSequentialIterable::const_iterator::operator*() const
|
||||
dataPtr = &v;
|
||||
else
|
||||
dataPtr = v.data();
|
||||
m_iterable->m_metaSequence.elementAtConstIterator(m_iterator, dataPtr);
|
||||
m_iterable->m_metaSequence.valueAtConstIterator(m_iterator, dataPtr);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
@ -54,9 +54,9 @@ QT_BEGIN_NAMESPACE
|
||||
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 element type, and calling
|
||||
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 element type.
|
||||
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,
|
||||
@ -128,14 +128,14 @@ QMetaType QMetaSequence::valueMetaType() const
|
||||
|
||||
/*!
|
||||
Returns \c true if the underlying container is ordered, otherwise returns
|
||||
\c false. A container is considered ordered if elements added to it are
|
||||
\c false. A container is considered ordered if values added to it are
|
||||
placed in a defined location. Inserting into or adding to an ordered
|
||||
container will always succeed. Inserting into or adding to an unordered
|
||||
container may not succeed, for example if the container is a QSet that
|
||||
already contains the value being inserted.
|
||||
|
||||
\sa addElement(), insertElementAtIterator(), addsAndRemovesElementsAtBegin(),
|
||||
addsAndRemovesElementsAtEnd()
|
||||
\sa addValue(), insertValueAtIterator(), addsAndRemovesValuesAtBegin(),
|
||||
addsAndRemovesValuesAtEnd()
|
||||
*/
|
||||
bool QMetaSequence::isOrdered() const
|
||||
{
|
||||
@ -145,14 +145,14 @@ bool QMetaSequence::isOrdered() const
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \c true if elements added using \l addElement() are placed at the
|
||||
Returns \c true if values added using \l addValue() are placed at the
|
||||
beginning of the container, otherwise returns \c false. Likewise
|
||||
\l removeElement() removes an element from the beginning of the container
|
||||
\l removeValue() removes an value from the beginning of the container
|
||||
if this method returns \c true.
|
||||
|
||||
\sa addElement(), removeElement(), addsAndRemovesElementsAtEnd()
|
||||
\sa addValue(), removeValue(), addsAndRemovesValuesAtEnd()
|
||||
*/
|
||||
bool QMetaSequence::addsAndRemovesElementsAtBegin() const
|
||||
bool QMetaSequence::addsAndRemovesValuesAtBegin() const
|
||||
{
|
||||
if (!d_ptr)
|
||||
return false;
|
||||
@ -160,14 +160,14 @@ bool QMetaSequence::addsAndRemovesElementsAtBegin() const
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \c true if elements added using \l addElement() are placed at the
|
||||
Returns \c true if values added using \l addValue() are placed at the
|
||||
end of the container, otherwise returns \c false. Likewise
|
||||
\l removeElement() removes an element from the end of the container
|
||||
\l removeValue() removes an value from the end of the container
|
||||
if this method returns \c true.
|
||||
|
||||
\sa addElement(), removeElement(), addsAndRemovesElementsAtBegin()
|
||||
\sa addValue(), removeValue(), addsAndRemovesValuesAtBegin()
|
||||
*/
|
||||
bool QMetaSequence::addsAndRemovesElementsAtEnd() const
|
||||
bool QMetaSequence::addsAndRemovesValuesAtEnd() const
|
||||
{
|
||||
if (!d_ptr)
|
||||
return false;
|
||||
@ -186,7 +186,7 @@ bool QMetaSequence::hasSize() const
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the number of elements in the given \a container if it can be
|
||||
Returns the number of values in the given \a container if it can be
|
||||
queried for its size. Otherwise returns \c -1.
|
||||
|
||||
\sa hasSize()
|
||||
@ -218,107 +218,107 @@ void QMetaSequence::clear(void *container) const
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \c true if elements can be retrieved from the container by index,
|
||||
Returns \c true if values can be retrieved from the container by index,
|
||||
otherwise \c false.
|
||||
|
||||
\sa elementAtIndex()
|
||||
\sa valueAtIndex()
|
||||
*/
|
||||
bool QMetaSequence::canGetElementAtIndex() const
|
||||
bool QMetaSequence::canGetValueAtIndex() const
|
||||
{
|
||||
return d_ptr && d_ptr->elementAtIndexFn;
|
||||
return d_ptr && d_ptr->valueAtIndexFn;
|
||||
}
|
||||
|
||||
/*!
|
||||
Retrieves the element at \a index in the \a container and places it in the
|
||||
Retrieves the value at \a index in the \a container and places it in the
|
||||
memory location pointed to by \a result, if that is possible.
|
||||
|
||||
\sa canGetElementAtIndex()
|
||||
\sa canGetValueAtIndex()
|
||||
*/
|
||||
void QMetaSequence::elementAtIndex(const void *container, qsizetype index, void *result) const
|
||||
void QMetaSequence::valueAtIndex(const void *container, qsizetype index, void *result) const
|
||||
{
|
||||
if (canGetElementAtIndex())
|
||||
d_ptr->elementAtIndexFn(container, index, result);
|
||||
if (canGetValueAtIndex())
|
||||
d_ptr->valueAtIndexFn(container, index, result);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \c true if an element can be written to the container by index,
|
||||
Returns \c true if an value can be written to the container by index,
|
||||
otherwise \c false.
|
||||
|
||||
\sa setElementAtIndex()
|
||||
\sa setValueAtIndex()
|
||||
*/
|
||||
bool QMetaSequence::canSetElementAtIndex() const
|
||||
bool QMetaSequence::canSetValueAtIndex() const
|
||||
{
|
||||
return d_ptr && d_ptr->setElementAtIndexFn;
|
||||
return d_ptr && d_ptr->setValueAtIndexFn;
|
||||
}
|
||||
|
||||
/*!
|
||||
Overwrites the element at \a index in the \a container using the \a element
|
||||
Overwrites the value at \a index in the \a container using the \a value
|
||||
passed as parameter if that is possible.
|
||||
|
||||
\sa canSetElementAtIndex()
|
||||
\sa canSetValueAtIndex()
|
||||
*/
|
||||
void QMetaSequence::setElementAtIndex(void *container, qsizetype index, const void *element) const
|
||||
void QMetaSequence::setValueAtIndex(void *container, qsizetype index, const void *value) const
|
||||
{
|
||||
if (canSetElementAtIndex())
|
||||
d_ptr->setElementAtIndexFn(container, index, element);
|
||||
if (canSetValueAtIndex())
|
||||
d_ptr->setValueAtIndexFn(container, index, value);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \c true if elements can be added to the container, \c false
|
||||
Returns \c true if values can be added to the container, \c false
|
||||
otherwise.
|
||||
|
||||
\sa addElement(), isOrdered()
|
||||
\sa addValue(), isOrdered()
|
||||
*/
|
||||
bool QMetaSequence::canAddElement() const
|
||||
bool QMetaSequence::canAddValue() const
|
||||
{
|
||||
return d_ptr && d_ptr->addElementFn;
|
||||
return d_ptr && d_ptr->addValueFn;
|
||||
}
|
||||
|
||||
/*!
|
||||
Adds \a element to the \a container if possible. If \l canAddElement()
|
||||
returns \c false, the \a element is not added. Else, if
|
||||
\l addsAndRemovesElementsAtBegin() returns \c true, the \a element is added
|
||||
Adds \a value to the \a container if possible. If \l canAddValue()
|
||||
returns \c false, the \a value is not added. Else, if
|
||||
\l addsAndRemovesValuesAtBegin() returns \c true, the \a value is added
|
||||
to the beginning of the \a container. Else, if
|
||||
\l addsAndRemovesElementsAtEnd() returns \c true, the \a element is added to
|
||||
the end of the container. Else, the element is added in an unspecified
|
||||
place or not at all. The latter is the case for adding elements to an
|
||||
\l addsAndRemovesValuesAtEnd() returns \c true, the \a value is added to
|
||||
the end 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.
|
||||
|
||||
\sa canAddElement(), addsAndRemovesElementsAtBegin(),
|
||||
addsAndRemovesElementsAtEnd(), isOrdered(), removeElement()
|
||||
\sa canAddValue(), addsAndRemovesValuesAtBegin(),
|
||||
addsAndRemovesValuesAtEnd(), isOrdered(), removeValue()
|
||||
*/
|
||||
void QMetaSequence::addElement(void *container, const void *element) const
|
||||
void QMetaSequence::addValue(void *container, const void *value) const
|
||||
{
|
||||
if (canAddElement())
|
||||
d_ptr->addElementFn(container, element);
|
||||
if (canAddValue())
|
||||
d_ptr->addValueFn(container, value);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \c true if elements can be removed from the container, \c false
|
||||
Returns \c true if values can be removed from the container, \c false
|
||||
otherwise.
|
||||
|
||||
\sa removeElement(), isOrdered()
|
||||
\sa removeValue(), isOrdered()
|
||||
*/
|
||||
bool QMetaSequence::canRemoveElement() const
|
||||
bool QMetaSequence::canRemoveValue() const
|
||||
{
|
||||
return d_ptr && d_ptr->removeElementFn;
|
||||
return d_ptr && d_ptr->removeValueFn;
|
||||
}
|
||||
|
||||
/*!
|
||||
Removes an element from the \a container if possible. If
|
||||
\l canRemoveElement() returns \c false, no element is removed. Else, if
|
||||
\l addsAndRemovesElementsAtBegin() returns \c true, the first element in
|
||||
the \a container is removed. Else, if \l addsAndRemovesElementsAtEnd()
|
||||
returns \c true, the last element in the \a container is removed. Else,
|
||||
an unspecified element or nothing is removed.
|
||||
Removes an value from the \a container if possible. If
|
||||
\l canRemoveValue() returns \c false, no value is removed. Else, if
|
||||
\l addsAndRemovesValuesAtBegin() returns \c true, the first value in
|
||||
the \a container is removed. Else, if \l addsAndRemovesValuesAtEnd()
|
||||
returns \c true, the last value in the \a container is removed. Else,
|
||||
an unspecified value or nothing is removed.
|
||||
|
||||
\sa canRemoveElement(), addsAndRemovesElementsAtBegin(),
|
||||
addsAndRemovesElementsAtEnd(), isOrdered(), addElement()
|
||||
\sa canRemoveValue(), addsAndRemovesValuesAtBegin(),
|
||||
addsAndRemovesValuesAtEnd(), isOrdered(), addValue()
|
||||
*/
|
||||
void QMetaSequence::removeElement(void *container) const
|
||||
void QMetaSequence::removeValue(void *container) const
|
||||
{
|
||||
if (canRemoveElement())
|
||||
d_ptr->removeElementFn(container);
|
||||
if (canRemoveValue())
|
||||
d_ptr->removeValueFn(container);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -388,7 +388,7 @@ void QMetaSequence::destroyIterator(const void *iterator) const
|
||||
|
||||
/*!
|
||||
Returns \c true if the non-const iterators \a i and \a j point to the same
|
||||
element in the container they are iterating over, otherwise returns \c
|
||||
value in the container they are iterating over, otherwise returns \c
|
||||
false.
|
||||
|
||||
\sa begin(), end()
|
||||
@ -441,99 +441,99 @@ qsizetype QMetaSequence::diffIterator(const void *i, const void *j) const
|
||||
Returns \c true if the underlying container can retrieve the value pointed
|
||||
to by a non-const iterator, \c false otherwise.
|
||||
|
||||
\sa hasIterator(), elementAtIterator()
|
||||
\sa hasIterator(), valueAtIterator()
|
||||
*/
|
||||
bool QMetaSequence::canGetElementAtIterator() const
|
||||
bool QMetaSequence::canGetValueAtIterator() const
|
||||
{
|
||||
return d_ptr && d_ptr->elementAtIteratorFn;
|
||||
return d_ptr && d_ptr->valueAtIteratorFn;
|
||||
}
|
||||
|
||||
/*!
|
||||
Retrieves the element pointed to by the non-const \a iterator and stores it
|
||||
Retrieves the value pointed to by the non-const \a iterator and stores it
|
||||
in the memory location pointed to by \a result, if possible.
|
||||
|
||||
\sa canGetElementAtIterator(), begin(), end()
|
||||
\sa canGetValueAtIterator(), begin(), end()
|
||||
*/
|
||||
void QMetaSequence::elementAtIterator(const void *iterator, void *result) const
|
||||
void QMetaSequence::valueAtIterator(const void *iterator, void *result) const
|
||||
{
|
||||
if (canGetElementAtIterator())
|
||||
d_ptr->elementAtIteratorFn(iterator, result);
|
||||
if (canGetValueAtIterator())
|
||||
d_ptr->valueAtIteratorFn(iterator, result);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \c true if the underlying container can write to the value pointed
|
||||
to by a non-const iterator, \c false otherwise.
|
||||
|
||||
\sa hasIterator(), setElementAtIterator()
|
||||
\sa hasIterator(), setValueAtIterator()
|
||||
*/
|
||||
bool QMetaSequence::canSetElementAtIterator() const
|
||||
bool QMetaSequence::canSetValueAtIterator() const
|
||||
{
|
||||
return d_ptr && d_ptr->setElementAtIteratorFn;
|
||||
return d_ptr && d_ptr->setValueAtIteratorFn;
|
||||
}
|
||||
|
||||
/*!
|
||||
Writes \a element to the value pointed to by the non-const \a iterator, if
|
||||
Writes \a value to the value pointed to by the non-const \a iterator, if
|
||||
possible.
|
||||
|
||||
\sa canSetElementAtIterator(), begin(), end()
|
||||
\sa canSetValueAtIterator(), begin(), end()
|
||||
*/
|
||||
void QMetaSequence::setElementAtIterator(const void *iterator, const void *element) const
|
||||
void QMetaSequence::setValueAtIterator(const void *iterator, const void *value) const
|
||||
{
|
||||
if (canSetElementAtIterator())
|
||||
d_ptr->setElementAtIteratorFn(iterator, element);
|
||||
if (canSetValueAtIterator())
|
||||
d_ptr->setValueAtIteratorFn(iterator, value);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \c true if the underlying container can insert a new element, taking
|
||||
Returns \c true if the underlying container can insert a new value, taking
|
||||
the location pointed to by a non-const iterator into account.
|
||||
|
||||
\sa hasIterator(), insertElementAtIterator()
|
||||
\sa hasIterator(), insertValueAtIterator()
|
||||
*/
|
||||
bool QMetaSequence::canInsertElementAtIterator() const
|
||||
bool QMetaSequence::canInsertValueAtIterator() const
|
||||
{
|
||||
return d_ptr && d_ptr->insertElementAtIteratorFn;
|
||||
return d_ptr && d_ptr->insertValueAtIteratorFn;
|
||||
}
|
||||
|
||||
/*!
|
||||
Inserts \a element into the \a container, if possible, taking the non-const
|
||||
\a iterator into account. If \l canInsertElementAtIterator() returns
|
||||
\c false, the \a element is not inserted. Else if \l isOrdered() returns
|
||||
\c true, the element is inserted before the element pointed to by
|
||||
\a iterator. Else, the \a element is inserted at an unspecified place or not
|
||||
Inserts \a value into the \a container, if possible, taking the non-const
|
||||
\a iterator into account. If \l canInsertValueAtIterator() returns
|
||||
\c false, the \a value is not inserted. Else if \l isOrdered() returns
|
||||
\c true, the value is inserted before the value pointed to by
|
||||
\a iterator. Else, the \a value is inserted at an unspecified place or not
|
||||
at all. In the latter case, the \a iterator is taken as a hint. If it points
|
||||
to the correct place for the \a element, the operation may be faster than a
|
||||
\l addElement() without iterator.
|
||||
to the correct place for the \a value, the operation may be faster than a
|
||||
\l addValue() without iterator.
|
||||
|
||||
\sa canInsertElementAtIterator(), isOrdered(), begin(), end()
|
||||
\sa canInsertValueAtIterator(), isOrdered(), begin(), end()
|
||||
*/
|
||||
void QMetaSequence::insertElementAtIterator(void *container, const void *iterator,
|
||||
const void *element) const
|
||||
void QMetaSequence::insertValueAtIterator(void *container, const void *iterator,
|
||||
const void *value) const
|
||||
{
|
||||
if (canInsertElementAtIterator())
|
||||
d_ptr->insertElementAtIteratorFn(container, iterator, element);
|
||||
if (canInsertValueAtIterator())
|
||||
d_ptr->insertValueAtIteratorFn(container, iterator, value);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns \c true if the element pointed to by a non-const iterator can be
|
||||
Returns \c true if the value pointed to by a non-const iterator can be
|
||||
erased, \c false otherwise.
|
||||
|
||||
\sa hasIterator(), eraseElementAtIterator()
|
||||
\sa hasIterator(), eraseValueAtIterator()
|
||||
*/
|
||||
bool QMetaSequence::canEraseElementAtIterator() const
|
||||
bool QMetaSequence::canEraseValueAtIterator() const
|
||||
{
|
||||
return d_ptr && d_ptr->eraseElementAtIteratorFn;
|
||||
return d_ptr && d_ptr->eraseValueAtIteratorFn;
|
||||
}
|
||||
|
||||
/*!
|
||||
Erases the element pointed to by the non-const \a iterator from the
|
||||
Erases the value pointed to by the non-const \a iterator from the
|
||||
\a container, if possible.
|
||||
|
||||
\sa canEraseElementAtIterator(), begin(), end()
|
||||
\sa canEraseValueAtIterator(), begin(), end()
|
||||
*/
|
||||
void QMetaSequence::eraseElementAtIterator(void *container, const void *iterator) const
|
||||
void QMetaSequence::eraseValueAtIterator(void *container, const void *iterator) const
|
||||
{
|
||||
if (canEraseElementAtIterator())
|
||||
d_ptr->eraseElementAtIteratorFn(container, iterator);
|
||||
if (canEraseValueAtIterator())
|
||||
d_ptr->eraseValueAtIteratorFn(container, iterator);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -604,7 +604,7 @@ void QMetaSequence::destroyConstIterator(const void *iterator) const
|
||||
|
||||
/*!
|
||||
Returns \c true if the const iterators \a i and \a j point to the same
|
||||
element in the container they are iterating over, otherwise returns \c
|
||||
value in the container they are iterating over, otherwise returns \c
|
||||
false.
|
||||
|
||||
\sa constBegin(), constEnd()
|
||||
@ -657,23 +657,23 @@ qsizetype QMetaSequence::diffConstIterator(const void *i, const void *j) const
|
||||
Returns \c true if the underlying container can retrieve the value pointed
|
||||
to by a const iterator, \c false otherwise.
|
||||
|
||||
\sa hasConstIterator(), elementAtConstIterator()
|
||||
\sa hasConstIterator(), valueAtConstIterator()
|
||||
*/
|
||||
bool QMetaSequence::canGetElementAtConstIterator() const
|
||||
bool QMetaSequence::canGetValueAtConstIterator() const
|
||||
{
|
||||
return d_ptr && d_ptr->elementAtConstIteratorFn;
|
||||
return d_ptr && d_ptr->valueAtConstIteratorFn;
|
||||
}
|
||||
|
||||
/*!
|
||||
Retrieves the element pointed to by the const \a iterator and stores it
|
||||
Retrieves the value pointed to by the const \a iterator and stores it
|
||||
in the memory location pointed to by \a result, if possible.
|
||||
|
||||
\sa canGetElementAtConstIterator(), constBegin(), constEnd()
|
||||
\sa canGetValueAtConstIterator(), constBegin(), constEnd()
|
||||
*/
|
||||
void QMetaSequence::elementAtConstIterator(const void *iterator, void *result) const
|
||||
void QMetaSequence::valueAtConstIterator(const void *iterator, void *result) const
|
||||
{
|
||||
if (canGetElementAtConstIterator())
|
||||
d_ptr->elementAtConstIteratorFn(iterator, result);
|
||||
if (canGetValueAtConstIterator())
|
||||
d_ptr->valueAtConstIteratorFn(iterator, result);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -73,15 +73,15 @@ public:
|
||||
using ClearFn = void(*)(void *);
|
||||
ClearFn clearFn;
|
||||
|
||||
using ElementAtIndexFn = void(*)(const void *, qsizetype, void *);
|
||||
ElementAtIndexFn elementAtIndexFn;
|
||||
using SetElementAtIndexFn = void(*)(void *, qsizetype, const void *);
|
||||
SetElementAtIndexFn setElementAtIndexFn;
|
||||
using ValueAtIndexFn = void(*)(const void *, qsizetype, void *);
|
||||
ValueAtIndexFn valueAtIndexFn;
|
||||
using SetValueAtIndexFn = void(*)(void *, qsizetype, const void *);
|
||||
SetValueAtIndexFn setValueAtIndexFn;
|
||||
|
||||
using AddElementFn = void(*)(void *, const void *);
|
||||
AddElementFn addElementFn;
|
||||
using RemoveElementFn = void(*)(void *);
|
||||
RemoveElementFn removeElementFn;
|
||||
using AddValueFn = void(*)(void *, const void *);
|
||||
AddValueFn addValueFn;
|
||||
using RemoveValueFn = void(*)(void *);
|
||||
RemoveValueFn removeValueFn;
|
||||
|
||||
using CreateIteratorFn = void *(*)(void *, Position);
|
||||
CreateIteratorFn createIteratorFn;
|
||||
@ -95,14 +95,14 @@ public:
|
||||
AdvanceIteratorFn advanceIteratorFn;
|
||||
using DiffIteratorFn = qsizetype(*)(const void *, const void *);
|
||||
DiffIteratorFn diffIteratorFn;
|
||||
using ElementAtIteratorFn = void(*)(const void *, void *);
|
||||
ElementAtIteratorFn elementAtIteratorFn;
|
||||
using SetElementAtIteratorFn = void(*)(const void *, const void *);
|
||||
SetElementAtIteratorFn setElementAtIteratorFn;
|
||||
using InsertElementAtIteratorFn = void(*)(void *, const void *, const void *);
|
||||
InsertElementAtIteratorFn insertElementAtIteratorFn;
|
||||
using EraseElementAtIteratorFn = void(*)(void *, const void *);
|
||||
EraseElementAtIteratorFn eraseElementAtIteratorFn;
|
||||
using ValueAtIteratorFn = void(*)(const void *, void *);
|
||||
ValueAtIteratorFn valueAtIteratorFn;
|
||||
using SetValueAtIteratorFn = void(*)(const void *, const void *);
|
||||
SetValueAtIteratorFn setValueAtIteratorFn;
|
||||
using InsertValueAtIteratorFn = void(*)(void *, const void *, const void *);
|
||||
InsertValueAtIteratorFn insertValueAtIteratorFn;
|
||||
using EraseValueAtIteratorFn = void(*)(void *, const void *);
|
||||
EraseValueAtIteratorFn eraseValueAtIteratorFn;
|
||||
|
||||
using CreateConstIteratorFn = void *(*)(const void *, Position);
|
||||
CreateConstIteratorFn createConstIteratorFn;
|
||||
@ -111,7 +111,7 @@ public:
|
||||
CopyIteratorFn copyConstIteratorFn;
|
||||
AdvanceIteratorFn advanceConstIteratorFn;
|
||||
DiffIteratorFn diffConstIteratorFn;
|
||||
ElementAtIteratorFn elementAtConstIteratorFn;
|
||||
ValueAtIteratorFn valueAtConstIteratorFn;
|
||||
};
|
||||
|
||||
template<typename C>
|
||||
@ -173,7 +173,7 @@ class QMetaSequenceForContainer
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr QMetaSequenceInterface::ElementAtIndexFn getElementAtIndexFn()
|
||||
static constexpr QMetaSequenceInterface::ValueAtIndexFn getValueAtIndexFn()
|
||||
{
|
||||
if constexpr (QContainerTraits::has_at_v<C>) {
|
||||
return [](const void *c, qsizetype i, void *r) {
|
||||
@ -190,7 +190,7 @@ class QMetaSequenceForContainer
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr QMetaSequenceInterface::SetElementAtIndexFn getSetElementAtIndexFn()
|
||||
static constexpr QMetaSequenceInterface::SetValueAtIndexFn getSetValueAtIndexFn()
|
||||
{
|
||||
if constexpr (QContainerTraits::can_set_at_index_v<C>) {
|
||||
return [](void *c, qsizetype i, const void *e) {
|
||||
@ -202,7 +202,7 @@ class QMetaSequenceForContainer
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr QMetaSequenceInterface::AddElementFn getAddElementFn()
|
||||
static constexpr QMetaSequenceInterface::AddValueFn getAddValueFn()
|
||||
{
|
||||
if constexpr (QContainerTraits::has_push_back_v<C>) {
|
||||
return [](void *c, const void *v) {
|
||||
@ -224,7 +224,7 @@ class QMetaSequenceForContainer
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr QMetaSequenceInterface::RemoveElementFn getRemoveElementFn()
|
||||
static constexpr QMetaSequenceInterface::RemoveValueFn getRemoveValueFn()
|
||||
{
|
||||
if constexpr (QContainerTraits::has_pop_back_v<C>) {
|
||||
return [](void *c) { static_cast<C *>(c)->pop_back(); };
|
||||
@ -315,7 +315,7 @@ class QMetaSequenceForContainer
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr QMetaSequenceInterface::ElementAtIteratorFn getElementAtIteratorFn()
|
||||
static constexpr QMetaSequenceInterface::ValueAtIteratorFn getValueAtIteratorFn()
|
||||
{
|
||||
if constexpr (QContainerTraits::has_iterator_v<C>
|
||||
&& QContainerTraits::can_get_at_iterator_v<C> && !std::is_const_v<C>) {
|
||||
@ -328,7 +328,7 @@ class QMetaSequenceForContainer
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr QMetaSequenceInterface::SetElementAtIteratorFn getSetElementAtIteratorFn()
|
||||
static constexpr QMetaSequenceInterface::SetValueAtIteratorFn getSetValueAtIteratorFn()
|
||||
{
|
||||
if constexpr (QContainerTraits::has_iterator_v<C>
|
||||
&& QContainerTraits::can_set_at_iterator_v<C> && !std::is_const_v<C>) {
|
||||
@ -341,7 +341,7 @@ class QMetaSequenceForContainer
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr QMetaSequenceInterface::InsertElementAtIteratorFn getInsertElementAtIteratorFn()
|
||||
static constexpr QMetaSequenceInterface::InsertValueAtIteratorFn getInsertValueAtIteratorFn()
|
||||
{
|
||||
if constexpr (QContainerTraits::has_iterator_v<C>
|
||||
&& QContainerTraits::can_insert_at_iterator_v<C> && !std::is_const_v<C>) {
|
||||
@ -355,7 +355,7 @@ class QMetaSequenceForContainer
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr QMetaSequenceInterface::EraseElementAtIteratorFn getEraseElementAtIteratorFn()
|
||||
static constexpr QMetaSequenceInterface::EraseValueAtIteratorFn getEraseValueAtIteratorFn()
|
||||
{
|
||||
if constexpr (QContainerTraits::has_iterator_v<C>
|
||||
&& QContainerTraits::can_erase_at_iterator_v<C> && !std::is_const_v<C>) {
|
||||
@ -447,7 +447,7 @@ class QMetaSequenceForContainer
|
||||
}
|
||||
}
|
||||
|
||||
static constexpr QMetaSequenceInterface::ElementAtIteratorFn getElementAtConstIteratorFn()
|
||||
static constexpr QMetaSequenceInterface::ValueAtIteratorFn getValueAtConstIteratorFn()
|
||||
{
|
||||
if constexpr (QContainerTraits::has_const_iterator_v<C>
|
||||
&& QContainerTraits::can_get_at_iterator_v<C>) {
|
||||
@ -472,27 +472,27 @@ QMetaSequenceInterface QMetaSequenceForContainer<C>::metaSequence = {
|
||||
/*.valueMetaType=*/ getValueMetaType(),
|
||||
/*.sizeFn=*/ getSizeFn(),
|
||||
/*.clearFn=*/ getClearFn(),
|
||||
/*.elementAtIndexFn=*/ getElementAtIndexFn(),
|
||||
/*.setElementAtIndexFn=*/ getSetElementAtIndexFn(),
|
||||
/*.addElementFn=*/ getAddElementFn(),
|
||||
/*.removeLastElementFn=*/ getRemoveElementFn(),
|
||||
/*.valueAtIndexFn=*/ getValueAtIndexFn(),
|
||||
/*.setValueAtIndexFn=*/ getSetValueAtIndexFn(),
|
||||
/*.addValueFn=*/ getAddValueFn(),
|
||||
/*.removeLastValueFn=*/ getRemoveValueFn(),
|
||||
/*.createIteratorFn=*/ getCreateIteratorFn(),
|
||||
/*.destroyIteratorFn=*/ getDestroyIteratorFn(),
|
||||
/*.equalIteratorFn=*/ getCompareIteratorFn(),
|
||||
/*.copyIteratorFn=*/ getCopyIteratorFn(),
|
||||
/*.advanceIteratorFn=*/ getAdvanceIteratorFn(),
|
||||
/*.diffIteratorFn=*/ getDiffIteratorFn(),
|
||||
/*.elementAtIteratorFn=*/ getElementAtIteratorFn(),
|
||||
/*.setElementAtIteratorFn=*/ getSetElementAtIteratorFn(),
|
||||
/*.insertElementAtIteratorFn=*/ getInsertElementAtIteratorFn(),
|
||||
/*.eraseElementAtIteratorFn=*/ getEraseElementAtIteratorFn(),
|
||||
/*.valueAtIteratorFn=*/ getValueAtIteratorFn(),
|
||||
/*.setValueAtIteratorFn=*/ getSetValueAtIteratorFn(),
|
||||
/*.insertValueAtIteratorFn=*/ getInsertValueAtIteratorFn(),
|
||||
/*.eraseValueAtIteratorFn=*/ getEraseValueAtIteratorFn(),
|
||||
/*.createConstIteratorFn=*/ getCreateConstIteratorFn(),
|
||||
/*.destroyConstIteratorFn=*/ getDestroyConstIteratorFn(),
|
||||
/*.equalConstIteratorFn=*/ getCompareConstIteratorFn(),
|
||||
/*.copyConstIteratorFn=*/ getCopyConstIteratorFn(),
|
||||
/*.advanceConstIteratorFn=*/ getAdvanceConstIteratorFn(),
|
||||
/*.diffConstIteratorFn=*/ getDiffConstIteratorFn(),
|
||||
/*.elementAtConstIteratorFn=*/ getElementAtConstIteratorFn(),
|
||||
/*.valueAtConstIteratorFn=*/ getValueAtConstIteratorFn(),
|
||||
};
|
||||
|
||||
template<typename C>
|
||||
@ -522,8 +522,8 @@ public:
|
||||
QMetaType valueMetaType() const;
|
||||
|
||||
bool isOrdered() const;
|
||||
bool addsAndRemovesElementsAtBegin() const;
|
||||
bool addsAndRemovesElementsAtEnd() const;
|
||||
bool addsAndRemovesValuesAtBegin() const;
|
||||
bool addsAndRemovesValuesAtEnd() const;
|
||||
|
||||
bool hasSize() const;
|
||||
qsizetype size(const void *container) const;
|
||||
@ -531,17 +531,17 @@ public:
|
||||
bool canClear() const;
|
||||
void clear(void *container) const;
|
||||
|
||||
bool canGetElementAtIndex() const;
|
||||
void elementAtIndex(const void *container, qsizetype index, void *result) const;
|
||||
bool canGetValueAtIndex() const;
|
||||
void valueAtIndex(const void *container, qsizetype index, void *result) const;
|
||||
|
||||
bool canSetElementAtIndex() const;
|
||||
void setElementAtIndex(void *container, qsizetype index, const void *element) const;
|
||||
bool canSetValueAtIndex() const;
|
||||
void setValueAtIndex(void *container, qsizetype index, const void *value) const;
|
||||
|
||||
bool canAddElement() const;
|
||||
void addElement(void *container, const void *element) const;
|
||||
bool canAddValue() const;
|
||||
void addValue(void *container, const void *value) const;
|
||||
|
||||
bool canRemoveElement() const;
|
||||
void removeElement(void *container) const;
|
||||
bool canRemoveValue() const;
|
||||
void removeValue(void *container) const;
|
||||
|
||||
bool hasIterator() const;
|
||||
void *begin(void *container) const;
|
||||
@ -552,17 +552,17 @@ public:
|
||||
void advanceIterator(void *iterator, qsizetype step) const;
|
||||
qsizetype diffIterator(const void *i, const void *j) const;
|
||||
|
||||
bool canGetElementAtIterator() const;
|
||||
void elementAtIterator(const void *iterator, void *result) const;
|
||||
bool canGetValueAtIterator() const;
|
||||
void valueAtIterator(const void *iterator, void *result) const;
|
||||
|
||||
bool canSetElementAtIterator() const;
|
||||
void setElementAtIterator(const void *iterator, const void *element) const;
|
||||
bool canSetValueAtIterator() const;
|
||||
void setValueAtIterator(const void *iterator, const void *value) const;
|
||||
|
||||
bool canInsertElementAtIterator() const;
|
||||
void insertElementAtIterator(void *container, const void *iterator, const void *element) const;
|
||||
bool canInsertValueAtIterator() const;
|
||||
void insertValueAtIterator(void *container, const void *iterator, const void *value) const;
|
||||
|
||||
bool canEraseElementAtIterator() const;
|
||||
void eraseElementAtIterator(void *container, const void *iterator) const;
|
||||
bool canEraseValueAtIterator() const;
|
||||
void eraseValueAtIterator(void *container, const void *iterator) const;
|
||||
|
||||
bool hasConstIterator() const;
|
||||
void *constBegin(const void *container) const;
|
||||
@ -573,8 +573,8 @@ public:
|
||||
void advanceConstIterator(void *iterator, qsizetype step) const;
|
||||
qsizetype diffConstIterator(const void *i, const void *j) const;
|
||||
|
||||
bool canGetElementAtConstIterator() const;
|
||||
void elementAtConstIterator(const void *iterator, void *result) const;
|
||||
bool canGetValueAtConstIterator() const;
|
||||
void valueAtConstIterator(const void *iterator, void *result) const;
|
||||
|
||||
friend bool operator==(const QMetaSequence &a, const QMetaSequence &b)
|
||||
{
|
||||
|
@ -258,15 +258,15 @@ void tst_QMetaContainer::testSequence()
|
||||
QFETCH(bool, canEraseAtIterator);
|
||||
QFETCH(bool, isOrdered);
|
||||
|
||||
QVERIFY(metaSequence.canAddElement());
|
||||
QVERIFY(metaSequence.canAddValue());
|
||||
QCOMPARE(metaSequence.hasSize(), hasSize);
|
||||
QCOMPARE(metaSequence.canGetElementAtIndex(), isIndexed);
|
||||
QCOMPARE(metaSequence.canSetElementAtIndex(), isIndexed);
|
||||
QCOMPARE(metaSequence.canRemoveElement(), canRemove);
|
||||
QCOMPARE(metaSequence.canGetValueAtIndex(), isIndexed);
|
||||
QCOMPARE(metaSequence.canSetValueAtIndex(), isIndexed);
|
||||
QCOMPARE(metaSequence.canRemoveValue(), canRemove);
|
||||
QCOMPARE(metaSequence.hasBidirectionalIterator(), hasBidirectionalIterator);
|
||||
QCOMPARE(metaSequence.hasRandomAccessIterator(), hasRandomAccessIterator);
|
||||
QCOMPARE(metaSequence.canInsertElementAtIterator(), canInsertAtIterator);
|
||||
QCOMPARE(metaSequence.canEraseElementAtIterator(), canEraseAtIterator);
|
||||
QCOMPARE(metaSequence.canInsertValueAtIterator(), canInsertAtIterator);
|
||||
QCOMPARE(metaSequence.canEraseValueAtIterator(), canEraseAtIterator);
|
||||
QCOMPARE(metaSequence.isOrdered(), isOrdered);
|
||||
|
||||
QVariant var1(metaType);
|
||||
@ -277,40 +277,40 @@ void tst_QMetaContainer::testSequence()
|
||||
const qsizetype size = metaSequence.size(container);
|
||||
|
||||
// var1 is invalid, and our sets do not contain an invalid value so far.
|
||||
metaSequence.addElement(container, var1.constData());
|
||||
metaSequence.addValue(container, var1.constData());
|
||||
QCOMPARE(metaSequence.size(container), size + 1);
|
||||
if (canRemove) {
|
||||
metaSequence.removeElement(container);
|
||||
metaSequence.removeValue(container);
|
||||
QCOMPARE(metaSequence.size(container), size);
|
||||
}
|
||||
} else {
|
||||
metaSequence.addElement(container, var1.constData());
|
||||
metaSequence.addValue(container, var1.constData());
|
||||
if (canRemove)
|
||||
metaSequence.removeElement(container);
|
||||
metaSequence.removeValue(container);
|
||||
}
|
||||
|
||||
if (isIndexed) {
|
||||
QVERIFY(hasSize);
|
||||
const qsizetype size = metaSequence.size(container);
|
||||
for (qsizetype i = 0; i < size; ++i) {
|
||||
metaSequence.elementAtIndex(container, i, var1.data());
|
||||
metaSequence.elementAtIndex(container, size - i - 1, var2.data());
|
||||
metaSequence.valueAtIndex(container, i, var1.data());
|
||||
metaSequence.valueAtIndex(container, size - i - 1, var2.data());
|
||||
|
||||
metaSequence.setElementAtIndex(container, i, var2.constData());
|
||||
metaSequence.setElementAtIndex(container, size - i - 1, var1.constData());
|
||||
metaSequence.setValueAtIndex(container, i, var2.constData());
|
||||
metaSequence.setValueAtIndex(container, size - i - 1, var1.constData());
|
||||
|
||||
metaSequence.elementAtIndex(container, i, var3.data());
|
||||
metaSequence.valueAtIndex(container, i, var3.data());
|
||||
QCOMPARE(var3, var2);
|
||||
|
||||
metaSequence.elementAtIndex(container, size - i - 1, var3.data());
|
||||
metaSequence.valueAtIndex(container, size - i - 1, var3.data());
|
||||
QCOMPARE(var3, var1);
|
||||
}
|
||||
}
|
||||
|
||||
QVERIFY(metaSequence.hasIterator());
|
||||
QVERIFY(metaSequence.hasConstIterator());
|
||||
QVERIFY(metaSequence.canGetElementAtIterator());
|
||||
QVERIFY(metaSequence.canGetElementAtConstIterator());
|
||||
QVERIFY(metaSequence.canGetValueAtIterator());
|
||||
QVERIFY(metaSequence.canGetValueAtConstIterator());
|
||||
|
||||
void *it = metaSequence.begin(container);
|
||||
void *end = metaSequence.end(container);
|
||||
@ -330,12 +330,12 @@ void tst_QMetaContainer::testSequence()
|
||||
qsizetype count = 0;
|
||||
for (; !metaSequence.compareIterator(it, end);
|
||||
metaSequence.advanceIterator(it, 1), metaSequence.advanceConstIterator(constIt, 1)) {
|
||||
metaSequence.elementAtIterator(it, var1.data());
|
||||
metaSequence.valueAtIterator(it, var1.data());
|
||||
if (isIndexed) {
|
||||
metaSequence.elementAtIndex(container, count, var2.data());
|
||||
metaSequence.valueAtIndex(container, count, var2.data());
|
||||
QCOMPARE(var1, var2);
|
||||
}
|
||||
metaSequence.elementAtConstIterator(constIt, var3.data());
|
||||
metaSequence.valueAtConstIterator(constIt, var3.data());
|
||||
QCOMPARE(var3, var1);
|
||||
++count;
|
||||
}
|
||||
@ -348,16 +348,16 @@ void tst_QMetaContainer::testSequence()
|
||||
metaSequence.destroyConstIterator(constIt);
|
||||
metaSequence.destroyConstIterator(constEnd);
|
||||
|
||||
if (metaSequence.canSetElementAtIterator()) {
|
||||
if (metaSequence.canSetValueAtIterator()) {
|
||||
void *it = metaSequence.begin(container);
|
||||
void *end = metaSequence.end(container);
|
||||
QVERIFY(it);
|
||||
QVERIFY(end);
|
||||
|
||||
for (; !metaSequence.compareIterator(it, end); metaSequence.advanceIterator(it, 1)) {
|
||||
metaSequence.elementAtIterator(it, var1.data());
|
||||
metaSequence.setElementAtIterator(it, var2.constData());
|
||||
metaSequence.elementAtIterator(it, var3.data());
|
||||
metaSequence.valueAtIterator(it, var1.data());
|
||||
metaSequence.setValueAtIterator(it, var2.constData());
|
||||
metaSequence.valueAtIterator(it, var3.data());
|
||||
QCOMPARE(var2, var3);
|
||||
var2 = var1;
|
||||
}
|
||||
@ -394,12 +394,12 @@ void tst_QMetaContainer::testSequence()
|
||||
metaSequence.advanceConstIterator(constIt, -1);
|
||||
--count;
|
||||
|
||||
metaSequence.elementAtIterator(it, var1.data());
|
||||
metaSequence.valueAtIterator(it, var1.data());
|
||||
if (isIndexed) {
|
||||
metaSequence.elementAtIndex(container, count - size, var2.data());
|
||||
metaSequence.valueAtIndex(container, count - size, var2.data());
|
||||
QCOMPARE(var1, var2);
|
||||
}
|
||||
metaSequence.elementAtConstIterator(constIt, var3.data());
|
||||
metaSequence.valueAtConstIterator(constIt, var3.data());
|
||||
QCOMPARE(var3, var1);
|
||||
} while (!metaSequence.compareIterator(it, end));
|
||||
|
||||
@ -419,13 +419,13 @@ void tst_QMetaContainer::testSequence()
|
||||
const qsizetype size = metaSequence.diffIterator(end, it);
|
||||
metaSequence.destroyIterator(end);
|
||||
|
||||
metaSequence.insertElementAtIterator(container, it, var1.constData());
|
||||
metaSequence.insertValueAtIterator(container, it, var1.constData());
|
||||
metaSequence.destroyIterator(it);
|
||||
it = metaSequence.begin(container);
|
||||
metaSequence.insertElementAtIterator(container, it, var2.constData());
|
||||
metaSequence.insertValueAtIterator(container, it, var2.constData());
|
||||
metaSequence.destroyIterator(it);
|
||||
it = metaSequence.begin(container);
|
||||
metaSequence.insertElementAtIterator(container, it, var3.constData());
|
||||
metaSequence.insertValueAtIterator(container, it, var3.constData());
|
||||
|
||||
metaSequence.destroyIterator(it);
|
||||
|
||||
@ -437,13 +437,13 @@ void tst_QMetaContainer::testSequence()
|
||||
if (metaSequence.isOrdered()) {
|
||||
QCOMPARE(newSize, size + 3);
|
||||
QVariant var4(metaType);
|
||||
metaSequence.elementAtIterator(it, var4.data());
|
||||
metaSequence.valueAtIterator(it, var4.data());
|
||||
QCOMPARE(var4, var3);
|
||||
metaSequence.advanceIterator(it, 1);
|
||||
metaSequence.elementAtIterator(it, var4.data());
|
||||
metaSequence.valueAtIterator(it, var4.data());
|
||||
QCOMPARE(var4, var2);
|
||||
metaSequence.advanceIterator(it, 1);
|
||||
metaSequence.elementAtIterator(it, var4.data());
|
||||
metaSequence.valueAtIterator(it, var4.data());
|
||||
QCOMPARE(var4, var1);
|
||||
} else {
|
||||
QVERIFY(newSize >= size);
|
||||
@ -453,7 +453,7 @@ void tst_QMetaContainer::testSequence()
|
||||
for (int i = 0; i < newSize; ++i) {
|
||||
metaSequence.destroyIterator(it);
|
||||
it = metaSequence.begin(container);
|
||||
metaSequence.eraseElementAtIterator(container, it);
|
||||
metaSequence.eraseValueAtIterator(container, it);
|
||||
}
|
||||
|
||||
metaSequence.destroyIterator(it);
|
||||
@ -462,9 +462,9 @@ void tst_QMetaContainer::testSequence()
|
||||
end = metaSequence.end(container);
|
||||
QVERIFY(metaSequence.compareIterator(it, end));
|
||||
|
||||
metaSequence.addElement(container, var1.constData());
|
||||
metaSequence.addElement(container, var2.constData());
|
||||
metaSequence.addElement(container, var3.constData());
|
||||
metaSequence.addValue(container, var1.constData());
|
||||
metaSequence.addValue(container, var2.constData());
|
||||
metaSequence.addValue(container, var3.constData());
|
||||
}
|
||||
|
||||
metaSequence.destroyIterator(end);
|
||||
|
@ -4538,7 +4538,7 @@ void tst_QVariant::shouldDeleteVariantDataWorksForSequential()
|
||||
[](const void *, QtMetaContainerPrivate::QMetaSequenceInterface::Position) -> void* {
|
||||
return nullptr;
|
||||
};
|
||||
metaSequence.addElementFn = [](void *, const void *) {};
|
||||
metaSequence.addValueFn = [](void *, const void *) {};
|
||||
metaSequence.advanceConstIteratorFn = [](void *, qsizetype) {};
|
||||
metaSequence.destroyConstIteratorFn = [](const void *){};
|
||||
metaSequence.compareConstIteratorFn = [](const void *, const void *) {
|
||||
@ -4548,11 +4548,11 @@ void tst_QVariant::shouldDeleteVariantDataWorksForSequential()
|
||||
metaSequence.diffConstIteratorFn = [](const void *, const void *) -> qsizetype {
|
||||
return 0;
|
||||
};
|
||||
metaSequence.elementAtIndexFn = [](const void *, qsizetype, void *dataPtr) -> void {
|
||||
metaSequence.valueAtIndexFn = [](const void *, qsizetype, void *dataPtr) -> void {
|
||||
MyType mytype {1, "eins"};
|
||||
*static_cast<MyType *>(dataPtr) = mytype;
|
||||
};
|
||||
metaSequence.elementAtConstIteratorFn = [](const void *, void *dataPtr) -> void {
|
||||
metaSequence.valueAtConstIteratorFn = [](const void *, void *dataPtr) -> void {
|
||||
MyType mytype {2, "zwei"};
|
||||
*static_cast<MyType *>(dataPtr) = mytype;
|
||||
};
|
||||
@ -4696,8 +4696,8 @@ void tst_QVariant::sequentialIterableAppend()
|
||||
auto asIterable = variant.value<QSequentialIterable>();
|
||||
const int i = 3, j = 4;
|
||||
void *mutableIterable = const_cast<void *>(asIterable.constIterable());
|
||||
asIterable.metaSequence().addElement(mutableIterable, &i);
|
||||
asIterable.metaSequence().addElement(mutableIterable, &j);
|
||||
asIterable.metaSequence().addValue(mutableIterable, &i);
|
||||
asIterable.metaSequence().addValue(mutableIterable, &j);
|
||||
QCOMPARE(variant.value<QList<int>>(), QList<int> ({ 1, 2, 3, 4 }));
|
||||
}
|
||||
{
|
||||
@ -4708,8 +4708,8 @@ void tst_QVariant::sequentialIterableAppend()
|
||||
QByteArray qba1 {"goodbye"};
|
||||
QByteArray qba2 { "moon" };
|
||||
void *mutableIterable = const_cast<void *>(asIterable.constIterable());
|
||||
asIterable.metaSequence().addElement(mutableIterable, &qba1);
|
||||
asIterable.metaSequence().addElement(mutableIterable, &qba2);
|
||||
asIterable.metaSequence().addValue(mutableIterable, &qba1);
|
||||
asIterable.metaSequence().addValue(mutableIterable, &qba2);
|
||||
QSet<QByteArray> reference { "hello", "world", "goodbye", "moon" };
|
||||
QCOMPARE(variant.value<QSet<QByteArray>>(), reference);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user