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// Qt-Security score:significant reason:default
4
5#include <QtCore/qiterable_impl.h>
6#include <QtCore/qsequentialiterable.h>
7#include <QtCore/qvariant.h>
8
10
11#if QT_DEPRECATED_SINCE(6, 15)
14
15/*!
16 \class QSequentialIterable
17 \deprecated [6.15] Use QMetaSequence::Iterable instead.
18 \since 5.2
19 \inmodule QtCore
20 \brief The QSequentialIterable class is an iterable interface for a container in a QVariant.
21
22 This class allows several methods of accessing the values of a container held within
23 a QVariant. An instance of QSequentialIterable can be extracted from a QVariant if it can
24 be converted to a QVariantList.
25
26 The container itself is not copied before iterating over it.
27
28 \sa QVariant
29*/
30
31/*!
32 \typedef QSequentialIterable::RandomAccessIterator
33 Exposes an iterator using std::random_access_iterator_tag.
34*/
35
36/*!
37 \typedef QSequentialIterable::BidirectionalIterator
38 Exposes an iterator using std::bidirectional_iterator_tag.
39*/
40
41/*!
42 \typedef QSequentialIterable::ForwardIterator
43 Exposes an iterator using std::forward_iterator_tag.
44*/
45
46/*!
47 \typedef QSequentialIterable::InputIterator
48 Exposes an iterator using std::input_iterator_tag.
49*/
50
51/*!
52 \typedef QSequentialIterable::RandomAccessConstIterator
53 Exposes a const_iterator using std::random_access_iterator_tag.
54*/
55
56/*!
57 \typedef QSequentialIterable::BidirectionalConstIterator
58 Exposes a const_iterator using std::bidirectional_iterator_tag.
59*/
60
61/*!
62 \typedef QSequentialIterable::ForwardConstIterator
63 Exposes a const_iterator using std::forward_iterator_tag.
64*/
65
66/*!
67 \typedef QSequentialIterable::InputConstIterator
68 Exposes a const_iterator using std::input_iterator_tag.
69*/
70
71/*!
72 Adds \a value to the container, at \a position, if possible.
73 */
75{
78
79 switch (position) {
80 case AtBegin:
83 break;
84 case AtEnd:
87 break;
88 case Unspecified:
91 break;
92 }
93}
94
95/*!
96 Removes a value from the container, at \a position, if possible.
97 */
99{
100 switch (position) {
101 case AtBegin:
104 break;
105 case AtEnd:
108 break;
109 case Unspecified:
112 break;
113 }
114}
115
117{
119}
120
121/*!
122 Returns the value at position \a idx in the container.
123*/
125{
127 void *dataPtr;
129 dataPtr = &v;
130 else
131 dataPtr = v.data();
132
134 if (meta.canGetValueAtIndex()) {
136 } else if (meta.canGetValueAtConstIterator()) {
141 }
142
143 return v;
144}
145
146/*!
147 Sets the element at position \a idx in the container to \a value.
148*/
150{
153
155 if (meta.canSetValueAtIndex()) {
157 } else if (meta.canSetValueAtIterator()) {
162 }
163}
164
165/*!
166 \typealias QSequentialIterable::const_iterator
167 \deprecated [6.15] Use QMetaSequence::Iterable::ConstIterator instead.
168 \brief The QSequentialIterable::const_iterator allows iteration over a container in a QVariant.
169
170 A QSequentialIterable::const_iterator can only be created by a QSequentialIterable instance,
171 and can be used in a way similar to other stl-style iterators.
172*/
173
174/*!
175 \typealias QSequentialIterable::iterator
176 \since 6.0
177 \deprecated [6.15] Use QMetaSequence::Iterable::Iterator instead.
178 \brief The QSequentialIterable::iterator allows iteration over a container in a QVariant.
179
180 A QSequentialIterable::iterator can only be created by a QSequentialIterable instance,
181 and can be used in a way similar to other stl-style iterators.
182*/
183
184/*!
185 \class QSequentialIterator
186 \internal
187 */
188
189/*!
190 Returns the current item, converted to a QVariantRef.
191*/
193{
194 return QVariantRef<QSequentialIterator>(this);
195}
196
197/*!
198 Returns the current item, converted to a QVariantPointer.
199*/
201{
203}
204
205/*!
206 \class QSequentialConstIterator
207 \internal
208 */
209
210/*!
211 Returns the current item, converted to a QVariant.
212*/
214{
217 });
218}
219
220/*!
221 Returns the current item, converted to a QVariantConstPointer.
222*/
224{
226}
227
229#endif // QT_DEPRECATED_SINCE(6, 15)
230
\inmodule QtSql