7#include <QtCore/qglobal.h>
8#include <QtCore/qtypeinfo.h>
9#include <QtCore/qmetacontainer.h>
10#include <QtCore/qtaggedpointer.h>
15 template<
typename Type,
typename Storage = Type>
18 enum Tag :
bool { Const, Mutable };
25 : m_pointer(reinterpret_cast<Storage *>(const_cast<
void *>(
pointer)), Const)
32 : m_pointer(reinterpret_cast<Storage *>(
pointer), Mutable)
38 template<
typename InputType>
40 : m_pointer(reinterpret_cast<Storage *>(const_cast<InputType *>(
pointer)), Const)
42 static_assert(
alignof(InputType) >=
alignof(Storage));
45 template<
typename InputType>
47 : m_pointer(reinterpret_cast<Storage *>(
pointer), Mutable)
49 static_assert(
alignof(InputType) >=
alignof(Storage));
56 return reinterpret_cast<const Type *
>(m_pointer.
data());
61 return m_pointer.
tag() == Mutable ?
reinterpret_cast<Type *
>(m_pointer.
data()) :
nullptr;
66template<
class Iterator,
typename IteratorCategory>
74 if (std::is_base_of_v<std::random_access_iterator_tag, IteratorCategory>
76 qFatal(
"You cannot use this iterator as a random access iterator");
77 this->clearIterator();
80 if (std::is_base_of_v<std::bidirectional_iterator_tag, IteratorCategory>
82 qFatal(
"You cannot use this iterator as a bidirectional iterator");
83 this->clearIterator();
86 if (std::is_base_of_v<std::forward_iterator_tag, IteratorCategory>
88 qFatal(
"You cannot use this iterator as a forward iterator");
89 this->clearIterator();
92 if (std::is_base_of_v<std::input_iterator_tag, IteratorCategory>
94 qFatal(
"You cannot use this iterator as an input iterator");
95 this->clearIterator();
119template<
class Container>
122template<
class Container>
127 void *m_iterator =
nullptr;
132 : m_iterable(iterable), m_iterator(iterator)
136 : m_iterable(iterable), m_iterator(iterator)
140 : m_iterable(
std::move(
other.m_iterable)), m_iterator(
std::move(
other.m_iterator))
142 other.m_iterator =
nullptr;
146 : m_iterable(
other.m_iterable)
155 if (
this != &
other) {
157 m_iterable = std::move(
other.m_iterable);
158 m_iterator = std::move(
other.m_iterator);
159 other.m_iterator =
nullptr;
166 if (
this != &
other) {
168 m_iterable =
other.m_iterable;
189 m_iterator =
metaContainer().begin(mutableIt->mutableIterable());
192 m_iterator =
metaContainer().constBegin(constIt->constIterable());
213template<
class Container>
307template<
class Container>
340 this->constIterable()->constIterable()));
356 this->constIterable()->constIterable()));
379 metaContainer.constBegin(
this->constIterable()->constIterable()));
389 this->constIterable()->constIterable()));
406template<
class Container>
429 template<
typename Po
inter>
\inmodule QtCore QBaseIterator forms the common base class for all iterators operating on subclasses ...
void * mutableIterator()
Returns a non-const pointer to the internal native iterator.
const void * constIterator() const
Returns a const pointer to the internal native iterator.
const QIterable< Container > * constIterable() const
QBaseIterator & operator=(QBaseIterator &&other)
QBaseIterator(const QIterable< Container > *iterable, void *iterator)
QBaseIterator(QBaseIterator &&other)
QBaseIterator & operator=(const QBaseIterator &other)
void initIterator(const void *copy)
QBaseIterator(const QBaseIterator &other)
QBaseIterator(QIterable< Container > *iterable, void *iterator)
QIterable< Container > * mutableIterable() const
Container metaContainer() const
qsizetype size() const
Returns the number of values in the container.
bool canRandomAccessIterate() const
Returns whether it is possible to efficiently skip over multiple values using and iterator.
QConstIterator< Container > constBegin() const
Returns a QConstIterator for the beginning of the container.
QIterable(const Container &metaContainer, Pointer iterable)
bool canInputIterate() const
Returns whether the container has an input iterator.
QIterator< Container > mutableEnd()
Returns a QSequentialIterable::iterator for the end of the container.
const void * constIterable() const
QIterable(const Container &metaContainer, qsizetype alignment, const void *p)
Container m_metaContainer
QIterable(const Container &metaContainer, const T *p)
QIterator< Container > mutableBegin()
Returns a QIterator for the beginning of the container.
Container metaContainer() const
QtPrivate::QConstPreservingPointer< void, quint16 > m_iterable
QIterable(const Container &metaContainer, T *p)
bool canForwardIterate() const
Returns whether it is possible to iterate over the container in forward direction.
QIterable(const Container &metaContainer, qsizetype alignment, void *p)
bool canReverseIterate() const
Returns whether it is possible to iterate over the container in reverse.
QConstIterator< Container > constEnd() const
Returns a Qterable::QConstIterator for the end of the container.
QTaggedIterator is a template class that wraps an iterator and exposes standard iterator traits.
bool operator!=(const QTaggedIterator &o) const
Returns true if other points to a different item than this iterator; otherwise returns false.
QTaggedIterator & operator++()
The prefix {++} operator ({++it}) advances the iterator to the next item in the container and returns...
bool operator<(const QTaggedIterator &j)
QTaggedIterator & operator-=(qsizetype j)
Makes the iterator go back by j items.
friend QTaggedIterator operator+(qsizetype j, const QTaggedIterator &k)
Returns an iterator to the item at j positions forward from iterator k.
QTaggedIterator(Iterator &&it)
Constructs a QTaggedIterator from an iterator or QConstIterator it.
bool operator<=(const QTaggedIterator &j)
QTaggedIterator operator+(qsizetype j) const
Returns an iterator to the item at j positions forward from this iterator.
qsizetype operator-(const QTaggedIterator &j) const
Returns the distance between this iterator and j.
QTaggedIterator & operator+=(qsizetype j)
Advances the iterator by j items.
bool operator>(const QTaggedIterator &j)
QTaggedIterator operator--(int x)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QTaggedIterator operator-(qsizetype j) const
Returns an iterator to the item at j positions backward from this iterator.
QTaggedIterator operator++(int x)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QTaggedIterator & operator--()
The prefix {–} operator ({–it}) makes the preceding item current and returns an iterator to the new c...
bool operator==(const QTaggedIterator &o) const
Returns true if other points to the same item as this iterator; otherwise returns false.
IteratorCategory iterator_category
bool operator>=(const QTaggedIterator &j)
T * data() const noexcept
Q_NODISCARD_CTOR QConstPreservingPointer(const InputType *pointer)
Q_NODISCARD_CTOR QConstPreservingPointer(std::nullptr_t)
Q_NODISCARD_CTOR QConstPreservingPointer(InputType *pointer)
const Type * constPointer() const
Q_NODISCARD_CTOR QConstPreservingPointer(void *pointer, qsizetype alignment)
Type * mutablePointer() const
Q_NODISCARD_CTOR QConstPreservingPointer()=default
Q_NODISCARD_CTOR QConstPreservingPointer(const void *pointer, qsizetype alignment)
QSet< QString >::iterator it
Combined button and popup list for selecting options.
static jboolean copy(JNIEnv *, jobject)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
GLint GLint GLint GLint GLint x
[0]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLsizei const void * pointer
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
The QConstIterator allows iteration over a container in a QVariant.
bool operator==(const QConstIterator &o) const
Returns true if other points to the same item as this iterator; otherwise returns false.
QConstIterator operator--(int)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QConstIterator operator-(qsizetype j) const
Returns an iterator to the item at j positions backward from this iterator.
QConstIterator & operator--()
The prefix {–} operator ({–it}) makes the preceding item current and returns an iterator to the new c...
QConstIterator operator+(qsizetype j) const
Returns an iterator to the item at j positions forward from this iterator.
friend QConstIterator operator+(qsizetype j, const QConstIterator &k)
qsizetype difference_type
QConstIterator & operator++()
The prefix {++} operator ({++it}) advances the iterator to the next item in the container and returns...
qsizetype operator-(const QConstIterator &j) const
Returns the distance between the two iterators.
QConstIterator & operator+=(qsizetype j)
Advances the iterator by j items.
QConstIterator(const QIterable< Container > *iterable, void *iterator)
Creates a QConstIterator to wrap iterator, operating on iterable.
QConstIterator operator++(int)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool operator!=(const QConstIterator &o) const
Returns true if other points to a different item than this iterator; otherwise returns false.
QConstIterator & operator-=(qsizetype j)
Makes the iterator go back by j items.
The QIterator is a template class that allows iteration over a container in a QVariant.
bool operator!=(const QIterator &o) const
Returns true if other points to a different item than this iterator; otherwise returns false.
QIterator & operator++()
The prefix {++} operator ({++it}) advances the iterator to the next item in the container and returns...
QIterator & operator-=(qsizetype j)
Makes the iterator go back by j items.
QIterator operator++(int)
This is an overloaded member function, provided for convenience. It differs from the above function o...
qsizetype operator-(const QIterator &j) const
Returns the distance between the two iterators.
QIterator & operator+=(qsizetype j)
Advances the iterator by j items.
QIterator(QIterable< Container > *iterable, void *iterator)
Creates an iterator from an iterable and a pointer to a native iterator.
QIterator operator+(qsizetype j) const
Returns an iterator to the item at j positions forward from this iterator.
QIterator operator--(int)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QIterator & operator--()
The prefix {–} operator ({–it}) makes the preceding item current and returns an iterator to the new c...
qsizetype difference_type
bool operator==(const QIterator &o) const
Returns true if other points to the same item as this iterator; otherwise returns false.
friend QIterator operator+(qsizetype j, const QIterator &k)
Returns an iterator to the item at j positions forward from iterator k.
QIterator operator-(qsizetype j) const
Returns an iterator to the item at j positions backward from this iterator.