Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qsequentialiterable.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <QtCore/qiterable_impl.h>
5#include <QtCore/qsequentialiterable.h>
6#include <QtCore/qvariant.h>
7
9
10#if QT_DEPRECATED_SINCE(6, 15)
13
14/*!
15 \class QSequentialIterable
16 \deprecated [6.15] Use QMetaSequence::Iterable instead.
17 \since 5.2
18 \inmodule QtCore
19 \brief The QSequentialIterable class is an iterable interface for a container in a QVariant.
20
21 This class allows several methods of accessing the values of a container held within
22 a QVariant. An instance of QSequentialIterable can be extracted from a QVariant if it can
23 be converted to a QVariantList.
24
25 The container itself is not copied before iterating over it.
26
27 \sa QVariant
28*/
29
30/*!
31 \typedef QSequentialIterable::RandomAccessIterator
32 Exposes an iterator using std::random_access_iterator_tag.
33*/
34
35/*!
36 \typedef QSequentialIterable::BidirectionalIterator
37 Exposes an iterator using std::bidirectional_iterator_tag.
38*/
39
40/*!
41 \typedef QSequentialIterable::ForwardIterator
42 Exposes an iterator using std::forward_iterator_tag.
43*/
44
45/*!
46 \typedef QSequentialIterable::InputIterator
47 Exposes an iterator using std::input_iterator_tag.
48*/
49
50/*!
51 \typedef QSequentialIterable::RandomAccessConstIterator
52 Exposes a const_iterator using std::random_access_iterator_tag.
53*/
54
55/*!
56 \typedef QSequentialIterable::BidirectionalConstIterator
57 Exposes a const_iterator using std::bidirectional_iterator_tag.
58*/
59
60/*!
61 \typedef QSequentialIterable::ForwardConstIterator
62 Exposes a const_iterator using std::forward_iterator_tag.
63*/
64
65/*!
66 \typedef QSequentialIterable::InputConstIterator
67 Exposes a const_iterator using std::input_iterator_tag.
68*/
69
70/*!
71 Adds \a value to the container, at \a position, if possible.
72 */
74{
77
78 switch (position) {
79 case AtBegin:
82 break;
83 case AtEnd:
86 break;
87 case Unspecified:
90 break;
91 }
92}
93
94/*!
95 Removes a value from the container, at \a position, if possible.
96 */
98{
99 switch (position) {
100 case AtBegin:
103 break;
104 case AtEnd:
107 break;
108 case Unspecified:
111 break;
112 }
113}
114
116{
118}
119
120/*!
121 Returns the value at position \a idx in the container.
122*/
124{
126 void *dataPtr;
128 dataPtr = &v;
129 else
130 dataPtr = v.data();
131
133 if (meta.canGetValueAtIndex()) {
135 } else if (meta.canGetValueAtConstIterator()) {
140 }
141
142 return v;
143}
144
145/*!
146 Sets the element at position \a idx in the container to \a value.
147*/
149{
152
154 if (meta.canSetValueAtIndex()) {
156 } else if (meta.canSetValueAtIterator()) {
161 }
162}
163
164/*!
165 \typealias QSequentialIterable::const_iterator
166 \deprecated [6.15] Use QMetaSequence::Iterable::ConstIterator instead.
167 \brief The QSequentialIterable::const_iterator allows iteration over a container in a QVariant.
168
169 A QSequentialIterable::const_iterator can only be created by a QSequentialIterable instance,
170 and can be used in a way similar to other stl-style iterators.
171*/
172
173/*!
174 \typealias QSequentialIterable::iterator
175 \since 6.0
176 \deprecated [6.15] Use QMetaSequence::Iterable::Iterator instead.
177 \brief The QSequentialIterable::iterator allows iteration over a container in a QVariant.
178
179 A QSequentialIterable::iterator can only be created by a QSequentialIterable instance,
180 and can be used in a way similar to other stl-style iterators.
181*/
182
183/*!
184 \class QSequentialIterator
185 \internal
186 */
187
188/*!
189 Returns the current item, converted to a QVariantRef.
190*/
192{
193 return QVariantRef<QSequentialIterator>(this);
194}
195
196/*!
197 Returns the current item, converted to a QVariantPointer.
198*/
200{
202}
203
204/*!
205 \class QSequentialConstIterator
206 \internal
207 */
208
209/*!
210 Returns the current item, converted to a QVariant.
211*/
213{
216 });
217}
218
219/*!
220 Returns the current item, converted to a QVariantConstPointer.
221*/
223{
225}
226
228#endif // QT_DEPRECATED_SINCE(6, 15)
229
\inmodule QtSql