summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qvariant.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-08-25 17:41:42 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-09-03 08:27:44 +0200
commit53fde3c573737592a02c5e15ad4fe253ac3304a4 (patch)
tree9cac35896e789c908c9f4099e5edafc3bcc663ab /src/corelib/kernel/qvariant.cpp
parent0e0149c64dc9b4cf46f4e8f01e5680e7ea5372c4 (diff)
Reimplement QSequentialIterable using QMetaSequence
Change-Id: Ie721a5f0caa697c4bf15a81f3762cf79d3c54f5a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/kernel/qvariant.cpp')
-rw-r--r--src/corelib/kernel/qvariant.cpp306
1 files changed, 0 insertions, 306 deletions
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 0805456e26..e052e3bd34 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -2581,312 +2581,6 @@ QDebug operator<<(QDebug dbg, const QVariant::Type p)
*/
/*!
- \class QSequentialIterable
- \since 5.2
- \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
- a QVariant. An instance of QSequentialIterable can be extracted from a QVariant if it can
- be converted to a QVariantList.
-
- \snippet code/src_corelib_kernel_qvariant.cpp 9
-
- The container itself is not copied before iterating over it.
-
- \sa QVariant
-*/
-
-/*!
- \internal
-*/
-QSequentialIterable::QSequentialIterable(const QtMetaTypePrivate::QSequentialIterableImpl &impl)
- : m_impl(impl)
-{
-}
-
-QSequentialIterable::const_iterator::const_iterator(const QSequentialIterable &iter, QAtomicInt *ref)
- : m_impl(iter.m_impl), m_ref(ref)
-{
- m_ref->ref();
-}
-
-QSequentialIterable::const_iterator::const_iterator(const QtMetaTypePrivate::QSequentialIterableImpl &impl, QAtomicInt *ref)
- : m_impl(impl), m_ref(ref)
-{
- m_ref->ref();
-}
-
-/*! \fn QSequentialIterable::const_iterator QSequentialIterable::begin() const
-
- Returns a QSequentialIterable::const_iterator for the beginning of the container. This
- can be used in stl-style iteration.
-
- \sa end()
-*/
-QSequentialIterable::const_iterator QSequentialIterable::begin() const
-{
- const_iterator it(*this, new QAtomicInt(0));
- it.m_impl.moveToBegin();
- return it;
-}
-
-/*!
- Returns a QSequentialIterable::const_iterator for the end of the container. This
- can be used in stl-style iteration.
-
- \sa begin()
-*/
-QSequentialIterable::const_iterator QSequentialIterable::end() const
-{
- const_iterator it(*this, new QAtomicInt(0));
- it.m_impl.moveToEnd();
- return it;
-}
-
-/*!
- Returns the element at position \a idx in the container.
-*/
-QVariant QSequentialIterable::at(int idx) const
-{
- QVariant v(m_impl._metaType);
- void *dataPtr;
- if (m_impl._metaType == QMetaType::fromType<QVariant>())
- dataPtr = &v;
- else
- dataPtr = v.data();
- m_impl.at(idx, dataPtr);
- return v;
-}
-
-/*!
- Returns the number of elements in the container.
-*/
-int QSequentialIterable::size() const
-{
- return m_impl.size();
-}
-
-/*!
- Returns whether it is possible to iterate over the container in reverse. This
- corresponds to the std::bidirectional_iterator_tag iterator trait of the
- const_iterator of the container.
-*/
-bool QSequentialIterable::canReverseIterate() const
-{
- return m_impl._iteratorCapabilities & QtMetaTypePrivate::BiDirectionalCapability;
-}
-
-/*!
- \class QSequentialIterable::const_iterator
- \since 5.2
- \inmodule QtCore
- \brief The QSequentialIterable::const_iterator allows iteration over a container in a QVariant.
-
- A QSequentialIterable::const_iterator can only be created by a QSequentialIterable instance,
- and can be used in a way similar to other stl-style iterators.
-
- \snippet code/src_corelib_kernel_qvariant.cpp 9
-
- \sa QSequentialIterable
-*/
-
-
-/*!
- Destroys the QSequentialIterable::const_iterator.
-*/
-QSequentialIterable::const_iterator::~const_iterator() {
- if (!m_ref->deref()) {
- m_impl.destroyIter();
- delete m_ref;
- }
-}
-
-/*!
- Creates a copy of \a other.
-*/
-QSequentialIterable::const_iterator::const_iterator(const const_iterator &other)
- : m_impl(other.m_impl), m_ref(other.m_ref)
-{
- m_ref->ref();
-}
-
-/*!
- Assigns \a other to this.
-*/
-QSequentialIterable::const_iterator&
-QSequentialIterable::const_iterator::operator=(const const_iterator &other)
-{
- other.m_ref->ref();
- if (!m_ref->deref()) {
- m_impl.destroyIter();
- delete m_ref;
- }
- m_impl = other.m_impl;
- m_ref = other.m_ref;
- return *this;
-}
-
-/*!
- Returns the current item, converted to a QVariant.
-*/
-const QVariant QSequentialIterable::const_iterator::operator*() const
-{
- QVariant v(m_impl._metaType);
- void *dataPtr;
- if (m_impl._metaType == QMetaType::fromType<QVariant>())
- dataPtr = &v;
- else
- dataPtr = v.data();
- m_impl.getCurrent(dataPtr);
- return v;
-}
-
-/*!
- Returns \c true if \a other points to the same item as this
- iterator; otherwise returns \c false.
-
- \sa operator!=()
-*/
-bool QSequentialIterable::const_iterator::operator==(const const_iterator &other) const
-{
- return m_impl.equal(other.m_impl);
-}
-
-/*!
- Returns \c true if \a other points to a different item than this
- iterator; otherwise returns \c false.
-
- \sa operator==()
-*/
-bool QSequentialIterable::const_iterator::operator!=(const const_iterator &other) const
-{
- return !m_impl.equal(other.m_impl);
-}
-
-/*!
- The prefix ++ operator (\c{++it}) advances the iterator to the
- next item in the container and returns an iterator to the new current
- item.
-
- Calling this function on QSequentialIterable::end() leads to undefined results.
-
- \sa operator--()
-*/
-QSequentialIterable::const_iterator &QSequentialIterable::const_iterator::operator++()
-{
- m_impl.advance(1);
- return *this;
-}
-
-/*!
- \overload
-
- The postfix ++ operator (\c{it++}) advances the iterator to the
- next item in the container and returns an iterator to the previously
- current item.
-*/
-QSequentialIterable::const_iterator QSequentialIterable::const_iterator::operator++(int)
-{
- QtMetaTypePrivate::QSequentialIterableImpl impl;
- impl.copy(m_impl);
- m_impl.advance(1);
- return const_iterator(impl, new QAtomicInt(0));
-}
-
-/*!
- The prefix -- operator (\c{--it}) makes the preceding item
- current and returns an iterator to the new current item.
-
- Calling this function on QSequentialIterable::begin() leads to undefined results.
-
- If the container in the QVariant does not support bi-directional iteration, calling this function
- leads to undefined results.
-
- \sa operator++(), canReverseIterate()
-*/
-QSequentialIterable::const_iterator &QSequentialIterable::const_iterator::operator--()
-{
- m_impl.advance(-1);
- return *this;
-}
-
-/*!
- \overload
-
- The postfix -- operator (\c{it--}) makes the preceding item
- current and returns an iterator to the previously current item.
-
- If the container in the QVariant does not support bi-directional iteration, calling this function
- leads to undefined results.
-
- \sa canReverseIterate()
-*/
-QSequentialIterable::const_iterator QSequentialIterable::const_iterator::operator--(int)
-{
- QtMetaTypePrivate::QSequentialIterableImpl impl;
- impl.copy(m_impl);
- m_impl.advance(-1);
- return const_iterator(impl, new QAtomicInt(0));
-}
-
-/*!
- Advances the iterator by \a j items.
-
- \sa operator-=(), operator+()
-*/
-QSequentialIterable::const_iterator &QSequentialIterable::const_iterator::operator+=(int j)
-{
- m_impl.advance(j);
- return *this;
-}
-
-/*!
- Makes the iterator go back by \a j items.
-
- If the container in the QVariant does not support bi-directional iteration, calling this function
- leads to undefined results.
-
- \sa operator+=(), operator-(), canReverseIterate()
-*/
-QSequentialIterable::const_iterator &QSequentialIterable::const_iterator::operator-=(int j)
-{
- m_impl.advance(-j);
- return *this;
-}
-
-/*!
- Returns an iterator to the item at \a j positions forward from
- this iterator.
-
- \sa operator-(), operator+=()
-*/
-QSequentialIterable::const_iterator QSequentialIterable::const_iterator::operator+(int j) const
-{
- QtMetaTypePrivate::QSequentialIterableImpl impl;
- impl.copy(m_impl);
- impl.advance(j);
- return const_iterator(impl, new QAtomicInt(0));
-}
-
-/*!
- Returns an iterator to the item at \a j positions backward from
- this iterator.
-
- If the container in the QVariant does not support bi-directional iteration, calling this function
- leads to undefined results.
-
- \sa operator+(), operator-=(), canReverseIterate()
-*/
-QSequentialIterable::const_iterator QSequentialIterable::const_iterator::operator-(int j) const
-{
- QtMetaTypePrivate::QSequentialIterableImpl impl;
- impl.copy(m_impl);
- impl.advance(-j);
- return const_iterator(impl, new QAtomicInt(0));
-}
-
-/*!
\class QAssociativeIterable
\since 5.2
\inmodule QtCore