Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qcbormap.h
Go to the documentation of this file.
1// Copyright (C) 2022 Intel Corporation.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QCBORMAP_H
5#define QCBORMAP_H
6
7#include <QtCore/qcborvalue.h>
8#include <QtCore/qpair.h>
9
10#include <initializer_list>
11
13
14class QJsonObject;
15class QDataStream;
16
17namespace QJsonPrivate { class Variant; }
18
20class Q_CORE_EXPORT QCborMap
21{
22public:
23 typedef std::pair<QCborValue, QCborValue> value_type;
27
28 class ConstIterator;
29 class Iterator {
30 QCborValueRef item {}; // points to the value
31 friend class ConstIterator;
32 friend class QCborMap;
33 Iterator(QCborContainerPrivate *dd, qsizetype ii) : item(dd, ii) {}
34 public:
35 typedef std::random_access_iterator_tag iterator_category;
37 typedef std::pair<QCborValueConstRef, QCborValueRef> value_type;
38 typedef std::pair<QCborValueConstRef, QCborValueRef> reference;
39 typedef std::pair<QCborValueConstRef, QCborValueRef> pointer;
40
41 constexpr Iterator() = default;
42 constexpr Iterator(const Iterator &) = default;
43 ~Iterator() = default;
45 {
46 // rebind the reference
47 item.d = other.item.d;
48 item.i = other.item.i;
49 return *this;
50 }
51
52 value_type operator*() const { return { QCborValueRef{item.d, item.i - 1}, item }; }
53 value_type operator[](qsizetype j) const { return *(*this + j); }
54 QCborValueRef *operator->() { return &item; }
55 const QCborValueConstRef *operator->() const { return &item; }
56#if QT_VERSION >= QT_VERSION_CHECK(7,0,0)
58#else
60#endif
61 key() const { return QCborValueRef(item.d, item.i - 1); }
62 QCborValueRef value() const { return item; }
63
64#if QT_CORE_REMOVED_SINCE(6, 8)
65 bool operator==(const Iterator &o) const { return item.d == o.item.d && item.i == o.item.i; }
66 bool operator!=(const Iterator &o) const { return !operator==(o); }
67 bool operator<(const Iterator& other) const { Q_ASSERT(item.d == other.item.d); return item.i < other.item.i; }
68 bool operator<=(const Iterator& other) const { Q_ASSERT(item.d == other.item.d); return item.i <= other.item.i; }
69 bool operator>(const Iterator& other) const { Q_ASSERT(item.d == other.item.d); return item.i > other.item.i; }
70 bool operator>=(const Iterator& other) const { Q_ASSERT(item.d == other.item.d); return item.i >= other.item.i; }
71 bool operator==(const ConstIterator &o) const { return item.d == o.item.d && item.i == o.item.i; }
72 bool operator!=(const ConstIterator &o) const { return !operator==(o); }
73 bool operator<(const ConstIterator& other) const { Q_ASSERT(item.d == other.item.d); return item.i < other.item.i; }
74 bool operator<=(const ConstIterator& other) const { Q_ASSERT(item.d == other.item.d); return item.i <= other.item.i; }
75 bool operator>(const ConstIterator& other) const { Q_ASSERT(item.d == other.item.d); return item.i > other.item.i; }
76 bool operator>=(const ConstIterator& other) const { Q_ASSERT(item.d == other.item.d); return item.i >= other.item.i; }
77#endif
78 Iterator &operator++() { item.i += 2; return *this; }
79 Iterator operator++(int) { Iterator n = *this; item.i += 2; return n; }
80 Iterator &operator--() { item.i -= 2; return *this; }
81 Iterator operator--(int) { Iterator n = *this; item.i -= 2; return n; }
82 Iterator &operator+=(qsizetype j) { item.i += 2 * j; return *this; }
83 Iterator &operator-=(qsizetype j) { item.i -= 2 * j; return *this; }
84 Iterator operator+(qsizetype j) const { return Iterator({ item.d, item.i + 2 * j }); }
85 Iterator operator-(qsizetype j) const { return Iterator({ item.d, item.i - 2 * j }); }
86 qsizetype operator-(Iterator j) const { return (item.i - j.item.i) / 2; }
87
88 private:
89 // Helper functions
90 static bool comparesEqual_helper(const Iterator &lhs, const Iterator &rhs) noexcept
91 {
92 return lhs.item.d == rhs.item.d && lhs.item.i == rhs.item.i;
93 }
94
95 static bool comparesEqual_helper(const Iterator &lhs, const ConstIterator &rhs) noexcept
96 {
97 return lhs.item.d == rhs.item.d && lhs.item.i == rhs.item.i;
98 }
99
100 static Qt::strong_ordering compareThreeWay_helper(const Iterator &lhs,
101 const Iterator &rhs) noexcept
102 {
103 Q_ASSERT(lhs.item.d == rhs.item.d);
104 return Qt::compareThreeWay(lhs.item.i, rhs.item.i);
105 }
106
107 static Qt::strong_ordering compareThreeWay_helper(const Iterator &lhs,
108 const ConstIterator &rhs) noexcept
109 {
110 Q_ASSERT(lhs.item.d == rhs.item.d);
111 return Qt::compareThreeWay(lhs.item.i, rhs.item.i);
112 }
113
114 // Compare friends
115 friend bool comparesEqual(const Iterator &lhs, const Iterator &rhs) noexcept
116 {
117 return comparesEqual_helper(lhs, rhs);
118 }
120 const Iterator &rhs) noexcept
121 {
122 return compareThreeWay_helper(lhs, rhs);
123 }
125 friend bool comparesEqual(const Iterator &lhs, const ConstIterator &rhs) noexcept
126 {
127 return comparesEqual_helper(lhs, rhs);
128 }
130 const ConstIterator &rhs) noexcept
131 {
132 return compareThreeWay_helper(lhs, rhs);
133 }
135 };
136
138 QCborValueConstRef item; // points to the value
139 friend class Iterator;
140 friend class QCborMap;
141 friend class QCborValue;
142 friend class QCborValueRef;
143 constexpr ConstIterator(QCborValueConstRef it) : item{it} {}
145 public:
146 typedef std::random_access_iterator_tag iterator_category;
148 typedef std::pair<QCborValueConstRef, QCborValueConstRef> value_type;
149 typedef std::pair<QCborValueConstRef, QCborValueConstRef> reference;
150 typedef std::pair<QCborValueConstRef, QCborValueConstRef> pointer;
151
152 constexpr ConstIterator() = default;
153 constexpr ConstIterator(const ConstIterator &) = default;
154 ~ConstIterator() = default;
156 {
157 // rebind the reference
158 item.d = other.item.d;
159 item.i = other.item.i;
160 return *this;
161 }
162
163 value_type operator*() const { return { QCborValueRef(item.d, item.i - 1), item }; }
164 value_type operator[](qsizetype j) const { return *(*this + j); }
165 const QCborValueConstRef *operator->() const { return &item; }
166#if QT_VERSION >= QT_VERSION_CHECK(7,0,0)
168#else
170#endif
171 key() const { return QCborValueRef(item.d, item.i - 1); }
172 QCborValueConstRef value() const { return item; }
173
174#if QT_CORE_REMOVED_SINCE(6, 8)
175 bool operator==(const Iterator &o) const { return item.d == o.item.d && item.i == o.item.i; }
176 bool operator!=(const Iterator &o) const { return !operator==(o); }
177 bool operator<(const Iterator& other) const { Q_ASSERT(item.d == other.item.d); return item.i < other.item.i; }
178 bool operator<=(const Iterator& other) const { Q_ASSERT(item.d == other.item.d); return item.i <= other.item.i; }
179 bool operator>(const Iterator& other) const { Q_ASSERT(item.d == other.item.d); return item.i > other.item.i; }
180 bool operator>=(const Iterator& other) const { Q_ASSERT(item.d == other.item.d); return item.i >= other.item.i; }
181 bool operator==(const ConstIterator &o) const { return item.d == o.item.d && item.i == o.item.i; }
182 bool operator!=(const ConstIterator &o) const { return !operator==(o); }
183 bool operator<(const ConstIterator& other) const { Q_ASSERT(item.d == other.item.d); return item.i < other.item.i; }
184 bool operator<=(const ConstIterator& other) const { Q_ASSERT(item.d == other.item.d); return item.i <= other.item.i; }
185 bool operator>(const ConstIterator& other) const { Q_ASSERT(item.d == other.item.d); return item.i > other.item.i; }
186 bool operator>=(const ConstIterator& other) const { Q_ASSERT(item.d == other.item.d); return item.i >= other.item.i; }
187#endif
188 ConstIterator &operator++() { item.i += 2; return *this; }
189 ConstIterator operator++(int) { ConstIterator n = *this; item.i += 2; return n; }
190 ConstIterator &operator--() { item.i -= 2; return *this; }
191 ConstIterator operator--(int) { ConstIterator n = *this; item.i -= 2; return n; }
192 ConstIterator &operator+=(qsizetype j) { item.i += 2 * j; return *this; }
193 ConstIterator &operator-=(qsizetype j) { item.i -= 2 * j; return *this; }
194 ConstIterator operator+(qsizetype j) const { return ConstIterator{ item.d, item.i + 2 * j }; }
195 ConstIterator operator-(qsizetype j) const { return ConstIterator{ item.d, item.i - 2 * j }; }
196 qsizetype operator-(ConstIterator j) const { return (item.i - j.item.i) / 2; }
197 private:
198 // Helper functions
199 static bool comparesEqual_helper(const ConstIterator &lhs,
200 const ConstIterator &rhs) noexcept
201 {
202 return lhs.item.d == rhs.item.d && lhs.item.i == rhs.item.i;
203 }
204 static Qt::strong_ordering compareThreeWay_helper(const ConstIterator &lhs,
205 const ConstIterator &rhs) noexcept
206 {
207 Q_ASSERT(lhs.item.d == rhs.item.d);
208 return Qt::compareThreeWay(lhs.item.i, rhs.item.i);
209 }
210
211 // Compare friends
212 friend bool comparesEqual(const ConstIterator &lhs, const ConstIterator &rhs) noexcept
213 {
214 return comparesEqual_helper(lhs, rhs);
215 }
217 const ConstIterator &rhs) noexcept
218 {
219 return compareThreeWay_helper(lhs, rhs);
220 }
222 };
223
224 QCborMap() noexcept;
225 QCborMap(const QCborMap &other) noexcept;
226 QCborMap &operator=(const QCborMap &other) noexcept;
227 QCborMap(std::initializer_list<value_type> args)
228 : QCborMap()
229 {
230 detach(args.size());
231 for (const auto &pair : args)
232 insert(pair.first, pair.second);
233 }
234 ~QCborMap();
235
236 void swap(QCborMap &other) noexcept
237 {
238 d.swap(other.d);
239 }
240
241 QCborValue toCborValue() const { return *this; }
242
243 qsizetype size() const noexcept Q_DECL_PURE_FUNCTION;
244 bool isEmpty() const { return size() == 0; }
245 void clear();
246 QList<QCborValue> keys() const;
247
249 { const_iterator it = find(key); return comparesEqual(it, end()) ? QCborValue() : it.value(); }
251 { const_iterator it = find(key); return comparesEqual(it, end()) ? QCborValue() : it.value(); }
253 { const_iterator it = find(key); return comparesEqual(it, end()) ? QCborValue() : it.value(); }
255 { const_iterator it = find(key); return comparesEqual(it, end()) ? QCborValue() : it.value(); }
256#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
257 template<size_t N> QT_ASCII_CAST_WARN const QCborValue value(const char (&key)[N]) const
258 { return value(QString::fromUtf8(key, N - 1)); }
259#endif
261 { const_iterator it = find(key); return comparesEqual(it, end()) ? QCborValue() : it.value(); }
263 { const_iterator it = find(key); return comparesEqual(it, end()) ? QCborValue() : it.value(); }
264 const QCborValue operator[](const QString & key) const
265 { const_iterator it = find(key); return comparesEqual(it, end()) ? QCborValue() : it.value(); }
267 { const_iterator it = find(key); return comparesEqual(it, end()) ? QCborValue() : it.value(); }
268#if !defined(QT_NO_CAST_FROM_ASCII) && !defined(QT_RESTRICTED_CAST_FROM_ASCII)
269 template<size_t N> QT_ASCII_CAST_WARN const QCborValue operator[](const char (&key)[N]) const
270 { return operator[](QString::fromUtf8(key, N - 1)); }
271#endif
272 QCborValueRef operator[](qint64 key);
273 QCborValueRef operator[](QLatin1StringView key);
274 QCborValueRef operator[](const QString & key);
275 QCborValueRef operator[](const QCborValue &key);
276
278 { const_iterator it = constFind(key); if (!comparesEqual(it, constEnd())) return extract(it); return QCborValue(); }
280 { const_iterator it = constFind(key); if (!comparesEqual(it, constEnd())) return extract(it); return QCborValue(); }
282 { const_iterator it = constFind(key); if (!comparesEqual(it, constEnd())) return extract(it); return QCborValue(); }
284 { const_iterator it = constFind(key); if (!comparesEqual(it, constEnd())) return extract(it); return QCborValue(); }
286 { const_iterator it = constFind(key); if (!comparesEqual(it, constEnd())) erase(it); }
288 { const_iterator it = constFind(key); if (!comparesEqual(it, constEnd())) erase(it); }
289 void remove(const QString & key)
290 { const_iterator it = constFind(key); if (!comparesEqual(it, constEnd())) erase(it); }
291 void remove(const QCborValue &key)
292 { const_iterator it = constFind(key); if (!comparesEqual(it, constEnd())) erase(it); }
293 bool contains(qint64 key) const
294 { const_iterator it = find(key); return !comparesEqual(it, end()); }
296 { const_iterator it = find(key); return !comparesEqual(it, end()); }
297 bool contains(const QString & key) const
298 { const_iterator it = find(key); return !comparesEqual(it, end()); }
299 bool contains(const QCborValue &key) const
300 { const_iterator it = find(key); return !comparesEqual(it, end()); }
301
302 int compare(const QCborMap &other) const noexcept Q_DECL_PURE_FUNCTION;
303#if QT_CORE_REMOVED_SINCE(6, 8)
304 bool operator==(const QCborMap &other) const noexcept
305 { return compare(other) == 0; }
306 bool operator!=(const QCborMap &other) const noexcept
307 { return !operator==(other); }
308 bool operator<(const QCborMap &other) const
309 { return compare(other) < 0; }
310#endif
311
314 iterator begin() { detach(); return iterator{d.data(), 1}; }
315 const_iterator constBegin() const { return const_iterator{d.data(), 1}; }
316 const_iterator begin() const { return constBegin(); }
317 const_iterator cbegin() const { return constBegin(); }
318 iterator end() { detach(); return iterator{d.data(), 2 * size() + 1}; }
319 const_iterator constEnd() const { return const_iterator{d.data(), 2 * size() + 1}; }
320 const_iterator end() const { return constEnd(); }
321 const_iterator cend() const { return constEnd(); }
322 iterator erase(iterator it);
323 iterator erase(const_iterator it) { return erase(iterator{ it.item.d, it.item.i }); }
324 QCborValue extract(iterator it);
325 QCborValue extract(const_iterator it) { return extract(iterator{ it.item.d, it.item.i }); }
326 bool empty() const { return isEmpty(); }
327
328 iterator find(qint64 key);
329 iterator find(QLatin1StringView key);
330 iterator find(const QString & key);
331 iterator find(const QCborValue &key);
332 const_iterator constFind(qint64 key) const;
333 const_iterator constFind(QLatin1StringView key) const;
334 const_iterator constFind(const QString & key) const;
335 const_iterator constFind(const QCborValue &key) const;
336 const_iterator find(qint64 key) const { return constFind(key); }
337 const_iterator find(QLatin1StringView key) const { return constFind(key); }
338 const_iterator find(const QString & key) const { return constFind(key); }
339 const_iterator find(const QCborValue &key) const { return constFind(key); }
340
342 {
343 QCborValueRef v = operator[](key); // detaches
344 v = value_;
345 return { d.data(), v.i };
346 }
348 {
349 QCborValueRef v = operator[](key); // detaches
350 v = value_;
351 return { d.data(), v.i };
352 }
353 iterator insert(const QString &key, const QCborValue &value_)
354 {
355 QCborValueRef v = operator[](key); // detaches
356 v = value_;
357 return { d.data(), v.i };
358 }
359 iterator insert(const QCborValue &key, const QCborValue &value_)
360 {
361 QCborValueRef v = operator[](key); // detaches
362 v = value_;
363 return { d.data(), v.i };
364 }
365 iterator insert(value_type v) { return insert(v.first, v.second); }
366
367 static QCborMap fromVariantMap(const QVariantMap &map);
368 static QCborMap fromVariantHash(const QVariantHash &hash);
369 static QCborMap fromJsonObject(const QJsonObject &o);
370 static QCborMap fromJsonObject(QJsonObject &&o) noexcept;
371 QVariantMap toVariantMap() const;
372 QVariantHash toVariantHash() const;
373 QJsonObject toJsonObject() const;
374
375private:
377 friend class QCborValue;
378 friend class QCborValueRef;
380 void detach(qsizetype reserve = 0);
381
382 friend Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool
383 comparesEqual(const QCborMap &lhs, const QCborMap &rhs) noexcept;
385 const QCborMap &rhs) noexcept
386 {
387 int c = lhs.compare(rhs);
388 return Qt::compareThreeWay(c, 0);
389 }
391
392 static Q_DECL_PURE_FUNCTION bool
393 comparesEqual_helper(const QCborMap &lhs, const QCborValue &rhs) noexcept;
395 compareThreeWay_helper(const QCborMap &lhs, const QCborValue &rhs) noexcept;
396 friend bool comparesEqual(const QCborMap &lhs,
397 const QCborValue &rhs) noexcept
398 {
399 return comparesEqual_helper(lhs, rhs);
400 }
402 const QCborValue &rhs) noexcept
403 {
404 return compareThreeWay_helper(lhs, rhs);
405 }
407
408 static Q_DECL_PURE_FUNCTION bool
409 comparesEqual_helper(const QCborMap &lhs, QCborValueConstRef rhs) noexcept;
411 compareThreeWay_helper(const QCborMap &lhs, QCborValueConstRef rhs) noexcept;
412 friend bool comparesEqual(const QCborMap &lhs,
413 const QCborValueConstRef &rhs) noexcept
414 {
415 return comparesEqual_helper(lhs, rhs);
416 }
418 const QCborValueConstRef &rhs) noexcept
419 {
420 return compareThreeWay_helper(lhs, rhs);
421 }
423
424 explicit QCborMap(QCborContainerPrivate &dd) noexcept;
425 QExplicitlySharedDataPointer<QCborContainerPrivate> d;
426};
427
428Q_DECLARE_SHARED(QCborMap)
429
431 : n(-1), container(m.d.take()), t(Map)
432{
433}
434
435#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0) && !defined(QT_BOOTSTRAPPED)
436inline QCborMap QCborValueRef::toMap() const
437{
438 return concrete().toMap();
439}
440
441inline QCborMap QCborValueRef::toMap(const QCborMap &m) const
442{
443 return concrete().toMap(m);
444}
445#endif
446
448{
449 return concrete().toMap();
450}
451
453{
454 return concrete().toMap(m);
455}
456
457Q_CORE_EXPORT size_t qHash(const QCborMap &map, size_t seed = 0);
458
459#if !defined(QT_NO_DEBUG_STREAM)
460Q_CORE_EXPORT QDebug operator<<(QDebug, const QCborMap &m);
461#endif
462
463#ifndef QT_NO_DATASTREAM
464#if QT_CONFIG(cborstreamwriter)
465Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QCborMap &);
466#endif
467Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QCborMap &);
468#endif
469
470
472
473#endif // QCBORMAP_H
\inmodule QtCore
Definition qcbormap.h:137
QCborValueConstRef key() const
Returns the current item's key.
Definition qcbormap.h:171
ConstIterator & operator++()
The prefix {++} operator, {++i}, advances the iterator to the next item in the map and returns this i...
Definition qcbormap.h:188
value_type operator[](qsizetype j) const
Definition qcbormap.h:164
friend bool comparesEqual(const ConstIterator &lhs, const ConstIterator &rhs) noexcept
Definition qcbormap.h:212
constexpr ConstIterator(const ConstIterator &)=default
Constructs an iterator as a copy of other.
ConstIterator operator-(qsizetype j) const
Returns an iterator to the item at j positions backward from this iterator.
Definition qcbormap.h:195
ConstIterator & operator--()
The prefix {–} operator, {–i}, makes the preceding item current and returns this iterator.
Definition qcbormap.h:190
qsizetype difference_type
Definition qcbormap.h:147
std::pair< QCborValueConstRef, QCborValueConstRef > reference
Definition qcbormap.h:149
qsizetype operator-(ConstIterator j) const
Returns the position of the item at iterator j relative to the item at this iterator.
Definition qcbormap.h:196
ConstIterator & operator-=(qsizetype j)
Makes the iterator go back by j items.
Definition qcbormap.h:193
const QCborValueConstRef * operator->() const
Returns a pointer to the current pair's value.
Definition qcbormap.h:165
QCborValueConstRef value() const
Returns the current item's value.
Definition qcbormap.h:172
constexpr ConstIterator()=default
Constructs an uninitialized iterator.
ConstIterator & operator=(const ConstIterator &other)
Makes this iterator a copy of other and returns a reference to this iterator.
Definition qcbormap.h:155
std::pair< QCborValueConstRef, QCborValueConstRef > pointer
Definition qcbormap.h:150
ConstIterator operator--(int)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:191
std::random_access_iterator_tag iterator_category
A synonym for {std::random_access_iterator_tag} indicating this iterator is a random-access iterator.
Definition qcbormap.h:146
friend Qt::strong_ordering compareThreeWay(const ConstIterator &lhs, const ConstIterator &rhs) noexcept
Definition qcbormap.h:216
ConstIterator operator++(int)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:189
std::pair< QCborValueConstRef, QCborValueConstRef > value_type
Definition qcbormap.h:148
ConstIterator operator+(qsizetype j) const
Returns an iterator to the item at j positions forward from this iterator.
Definition qcbormap.h:194
value_type operator*() const
Returns a pair containing the current item's key and value.
Definition qcbormap.h:163
ConstIterator & operator+=(qsizetype j)
Advances the iterator by j items.
Definition qcbormap.h:192
\inmodule QtCore\reentrant
Definition qcbormap.h:29
Iterator operator++(int)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:79
friend Qt::strong_ordering compareThreeWay(const Iterator &lhs, const Iterator &rhs) noexcept
Definition qcbormap.h:119
std::random_access_iterator_tag iterator_category
A synonym for {std::random_access_iterator_tag} indicating this iterator is a random-access iterator.
Definition qcbormap.h:35
const QCborValueConstRef * operator->() const
Returns a pointer to a modifiable reference to the current pair's value.
Definition qcbormap.h:55
Iterator operator+(qsizetype j) const
Returns an iterator to the item at j positions forward from this iterator.
Definition qcbormap.h:84
value_type operator*() const
Returns a pair containing the current item's key and a modifiable reference to the current item's val...
Definition qcbormap.h:52
QCborValueConstRef key() const
Returns the current item's key.
Definition qcbormap.h:61
friend bool comparesEqual(const Iterator &lhs, const Iterator &rhs) noexcept
Definition qcbormap.h:115
Iterator & operator=(const Iterator &other)
Makes this iterator a copy of other and returns a reference to this iterator.
Definition qcbormap.h:44
constexpr Iterator()=default
Constructs an uninitialized iterator.
Iterator & operator-=(qsizetype j)
Makes the iterator go back by j items.
Definition qcbormap.h:83
Iterator operator--(int)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:81
qsizetype operator-(Iterator j) const
Returns the position of the item at iterator j relative to the item at this iterator.
Definition qcbormap.h:86
Iterator operator-(qsizetype j) const
Returns an iterator to the item at j positions backward from this iterator.
Definition qcbormap.h:85
std::pair< QCborValueConstRef, QCborValueRef > pointer
Definition qcbormap.h:39
value_type operator[](qsizetype j) const
Definition qcbormap.h:53
Iterator & operator++()
The prefix {++} operator, {++i}, advances the iterator to the next item in the map and returns this i...
Definition qcbormap.h:78
qsizetype difference_type
Definition qcbormap.h:36
constexpr Iterator(const Iterator &)=default
Constructs an iterator as a copy of other.
QCborValueRef * operator->()
Definition qcbormap.h:54
Iterator & operator--()
The prefix {–} operator, {–i}, makes the preceding item current and returns this iterator.
Definition qcbormap.h:80
QCborValueRef value() const
Returns a modifiable reference to the current item's value.
Definition qcbormap.h:62
Iterator & operator+=(qsizetype j)
Advances the iterator by j items.
Definition qcbormap.h:82
std::pair< QCborValueConstRef, QCborValueRef > reference
Definition qcbormap.h:38
std::pair< QCborValueConstRef, QCborValueRef > value_type
Definition qcbormap.h:37
friend Qt::strong_ordering compareThreeWay(const Iterator &lhs, const ConstIterator &rhs) noexcept
Definition qcbormap.h:129
\inmodule QtCore\reentrant
Definition qcbormap.h:21
QCborValue extract(const_iterator it)
Extracts a value from the map at the position indicated by iterator it and returns the value so extra...
Definition qcbormap.h:325
QCborValue value(const QString &key) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:252
iterator erase(const_iterator it)
Removes the key-value pair pointed to by the map iterator it and returns a pointer to the next elemen...
Definition qcbormap.h:323
QCborValue toCborValue() const
Explicitly constructs a \l QCborValue object that represents this map.
Definition qcbormap.h:241
const_iterator find(qint64 key) const
Returns a map iterator to the key-value pair whose key is key, if the map contains such a pair.
Definition qcbormap.h:336
friend Qt::strong_ordering compareThreeWay(const QCborMap &lhs, const QCborMap &rhs) noexcept
Definition qcbormap.h:384
bool contains(const QString &key) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:297
const_iterator end() const
Returns a map iterator representing an element just past the last element in the map.
Definition qcbormap.h:320
QCborValue value(qint64 key) const
Returns the QCborValue element in this map that corresponds to key key, if there is one.
Definition qcbormap.h:248
iterator insert(QLatin1StringView key, const QCborValue &value_)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:347
friend Qt::strong_ordering compareThreeWay(const QCborMap &lhs, const QCborValueConstRef &rhs) noexcept
Definition qcbormap.h:417
bool empty() const
Synonym for isEmpty().
Definition qcbormap.h:326
friend bool comparesEqual(const QCborMap &lhs, const QCborValueConstRef &rhs) noexcept
Definition qcbormap.h:412
const_iterator cend() const
Returns a map iterator representing an element just past the last element in the map.
Definition qcbormap.h:321
void swap(QCborMap &other) noexcept
Swaps the contents of this map and other.
Definition qcbormap.h:236
const_iterator find(const QCborValue &key) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:339
QCborValue take(QLatin1StringView key)
Removes the key key and the corresponding value from the map and returns the value,...
Definition qcbormap.h:279
qsizetype size_type
The type that QCborMap uses for sizes.
Definition qcbormap.h:26
QT_ASCII_CAST_WARN const QCborValue value(const char(&key)[N]) const
Definition qcbormap.h:257
iterator end()
Returns a map iterator representing an element just past the last element in the map.
Definition qcbormap.h:318
void remove(const QCborValue &key)
Removes the key key and the corresponding value from the map, if it is found.
Definition qcbormap.h:291
void remove(const QString &key)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:289
QCborValue mapped_type
The type that is mapped to (the value), that is, a QCborValue.
Definition qcbormap.h:25
QCborValue take(qint64 key)
Removes the key key and the corresponding value from the map and returns the value,...
Definition qcbormap.h:277
const_iterator find(const QString &key) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:338
friend bool comparesEqual(const QCborMap &lhs, const QCborValue &rhs) noexcept
Definition qcbormap.h:396
iterator insert(const QCborValue &key, const QCborValue &value_)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:359
const QCborValue operator[](const QCborValue &key) const
Returns the QCborValue element in this map that corresponds to key key, if there is one.
Definition qcbormap.h:266
const QCborValue operator[](QLatin1StringView key) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:262
QCborValue value(const QCborValue &key) const
Returns the QCborValue element in this map that corresponds to key key, if there is one.
Definition qcbormap.h:254
QCborValue take(const QCborValue &key)
Removes the key key and the corresponding value from the map and returns the value,...
Definition qcbormap.h:283
std::pair< QCborValue, QCborValue > value_type
The value that is stored in this container: a pair of QCborValues.
Definition qcbormap.h:23
const_iterator begin() const
Returns a map iterator pointing to the first key-value pair of this map.
Definition qcbormap.h:316
void remove(QLatin1StringView key)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:287
iterator insert(const QString &key, const QCborValue &value_)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:353
ConstIterator const_iterator
A synonym for QCborMap::ConstIterator.
Definition qcbormap.h:313
const_iterator cbegin() const
Returns a map iterator pointing to the first key-value pair of this map.
Definition qcbormap.h:317
const_iterator find(QLatin1StringView key) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:337
QCborValue key_type
The key type for this map.
Definition qcbormap.h:24
bool contains(qint64 key) const
Returns true if this map contains a key-value pair identified by key key.
Definition qcbormap.h:293
iterator insert(qint64 key, const QCborValue &value_)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:341
const_iterator constBegin() const
Returns a map iterator pointing to the first key-value pair of this map.
Definition qcbormap.h:315
QT_ASCII_CAST_WARN const QCborValue operator[](const char(&key)[N]) const
Definition qcbormap.h:269
bool contains(const QCborValue &key) const
Returns true if this map contains a key-value pair identified by key key.
Definition qcbormap.h:299
bool contains(QLatin1StringView key) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:295
QCborValue take(const QString &key)
Removes the key key and the corresponding value from the map and returns the value,...
Definition qcbormap.h:281
friend Qt::strong_ordering compareThreeWay(const QCborMap &lhs, const QCborValue &rhs) noexcept
Definition qcbormap.h:401
const QCborValue operator[](const QString &key) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:264
iterator begin()
Returns a map iterator pointing to the first key-value pair of this map.
Definition qcbormap.h:314
const QCborValue operator[](qint64 key) const
Returns the QCborValue element in this map that corresponds to key key, if there is one.
Definition qcbormap.h:260
QCborValue value(QLatin1StringView key) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:250
const_iterator constEnd() const
Returns a map iterator representing an element just past the last element in the map.
Definition qcbormap.h:319
iterator insert(value_type v)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qcbormap.h:365
Iterator iterator
A synonym for QCborMap::Iterator.
Definition qcbormap.h:312
void remove(qint64 key)
Removes the key key and the corresponding value from the map, if it is found.
Definition qcbormap.h:285
QCborMap toMap() const
Definition qcbormap.h:447
QCborValue concrete() const noexcept
Definition qcborvalue.h:394
\inmodule QtCore\reentrant
Definition qcborvalue.h:47
QCborMap toMap() const
\inmodule QtCore\reentrant
Definition qdatastream.h:46
\inmodule QtCore
\inmodule QtCore\reentrant
Definition qjsonobject.h:20
qsizetype size() const noexcept
Definition qlist.h:397
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:6018
\inmodule QtCore \title Classes and helpers for defining comparison operators \keyword qtcompare
Definition qcompare.h:400
QHash< int, QWidget * > hash
[35multi]
QMap< QString, QString > map
[6]
b clear()
cache insert(employee->id(), employee)
QSet< QString >::iterator it
set reserve(20000)
Combined button and popup list for selecting options.
constexpr Qt::strong_ordering compareThreeWay(LeftInt lhs, RightInt rhs) noexcept
qsizetype erase(QByteArray &ba, const T &t)
Definition qbytearray.h:782
Q_CORE_EXPORT QDataStream & operator>>(QDataStream &, QCborMap &)
Q_CORE_EXPORT size_t qHash(const QCborMap &map, size_t seed=0)
Q_CORE_EXPORT QDebug operator<<(QDebug, const QCborMap &m)
#define Q_DECLARE_STRONGLY_ORDERED(...)
#define Q_DECL_PURE_FUNCTION
constexpr bool operator!=(const timespec &t1, const timespec &t2)
bool comparesEqual(const QDir &lhs, const QDir &rhs)
Definition qdir.cpp:1819
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLsizei const GLfloat * v
[13]
const GLfloat * m
GLuint64 key
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLuint end
GLfloat n
const GLubyte * c
GLdouble GLdouble t
Definition qopenglext.h:243
bool operator>(const QPoint &a, const QPoint &b)
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
Definition qrandom.cpp:1220
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
static bool operator<(const QSettingsIniKey &k1, const QSettingsIniKey &k2)
#define QT_ASCII_CAST_WARN
static int compare(quint64 a, quint64 b)
ptrdiff_t qsizetype
Definition qtypes.h:165
long long qint64
Definition qtypes.h:60
bool operator<=(const QUuid &lhs, const QUuid &rhs) noexcept
Definition quuid.h:294
bool operator>=(const QUuid &lhs, const QUuid &rhs) noexcept
Definition quuid.h:296
QStringList keys
QCborValue(QCborTag(2), QByteArray("\x01\0\0\0\0\0\0\0\0", 9))
[0]
QSharedPointer< T > other(t)
[5]
QGraphicsItem * item
QJSValueList args