![]() |
Qt 6.x
The Qt SDK
|
\inmodule QtCore\reentrant More...
#include <qcbormap.h>
Classes | |
class | ConstIterator |
\inmodule QtCore More... | |
class | Iterator |
\inmodule QtCore\reentrant More... | |
Public Types | |
typedef QPair< QCborValue, QCborValue > | value_type |
The value that is stored in this container: a pair of QCborValues. | |
typedef QCborValue | key_type |
The key type for this map. | |
typedef QCborValue | mapped_type |
The type that is mapped to (the value), that is, a QCborValue. | |
typedef qsizetype | size_type |
The type that QCborMap uses for sizes. | |
typedef Iterator | iterator |
A synonym for QCborMap::Iterator. | |
typedef ConstIterator | const_iterator |
A synonym for QCborMap::ConstIterator. | |
Public Member Functions | |
QCborMap () noexcept | |
Constructs an empty CBOR Map object. | |
QCborMap (const QCborMap &other) noexcept | |
Creates a QCborMap object that is a copy of other. | |
QCborMap & | operator= (const QCborMap &other) noexcept |
Replaces the contents of this object with a copy of other, then returns a reference to this object. | |
QCborMap (std::initializer_list< value_type > args) | |
Constructs a QCborMap with items from a brace-initialization list found in args, as in the following example: | |
~QCborMap () | |
Destroys this QCborMap object and frees any associated resources it owns. | |
void | swap (QCborMap &other) noexcept |
Swaps the contents of this map and other. | |
QCborValue | toCborValue () const |
Explicitly constructs a \l QCborValue object that represents this map. | |
qsizetype | size () const noexcept Q_DECL_PURE_FUNCTION |
Returns the number of elements in this map. | |
bool | isEmpty () const |
Returns true if this map is empty (that is, size() is 0). | |
void | clear () |
Empties this map. | |
QList< QCborValue > | keys () const |
Returns a list of all keys in this map. | |
QCborValue | value (qint64 key) const |
Returns the QCborValue element in this map that corresponds to key key, if there is one. | |
QCborValue | value (QLatin1StringView key) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the QCborValue element in this map that corresponds to key key, if there is one. | |
QCborValue | value (const QString &key) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the QCborValue element in this map that corresponds to key key, if there is one. | |
QCborValue | value (const QCborValue &key) const |
Returns the QCborValue element in this map that corresponds to key key, if there is one. | |
template<size_t N> | |
QT_ASCII_CAST_WARN const QCborValue | value (const char(&key)[N]) const |
const QCborValue | operator[] (qint64 key) const |
Returns the QCborValue element in this map that corresponds to key key, if there is one. | |
const QCborValue | operator[] (QLatin1StringView key) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the QCborValue element in this map that corresponds to key key, if there is one. | |
const QCborValue | operator[] (const QString &key) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the QCborValue element in this map that corresponds to key key, if there is one. | |
const QCborValue | operator[] (const QCborValue &key) const |
Returns the QCborValue element in this map that corresponds to key key, if there is one. | |
template<size_t N> | |
QT_ASCII_CAST_WARN const QCborValue | operator[] (const char(&key)[N]) const |
QCborValueRef | operator[] (qint64 key) |
Returns a QCborValueRef to the value in this map that corresponds to key key. | |
QCborValueRef | operator[] (QLatin1StringView key) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a QCborValueRef to the value in this map that corresponds to key key. | |
QCborValueRef | operator[] (const QString &key) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a QCborValueRef to the value in this map that corresponds to key key. | |
QCborValueRef | operator[] (const QCborValue &key) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a QCborValueRef to the value in this map that corresponds to key key. | |
QCborValue | take (qint64 key) |
Removes the key key and the corresponding value from the map and returns the value, if it is found. | |
QCborValue | take (QLatin1StringView key) |
Removes the key key and the corresponding value from the map and returns the value, if it is found. | |
QCborValue | take (const QString &key) |
Removes the key key and the corresponding value from the map and returns the value, if it is found. | |
QCborValue | take (const QCborValue &key) |
Removes the key key and the corresponding value from the map and returns the value, if it is found. | |
void | remove (qint64 key) |
Removes the key key and the corresponding value from the map, if it is found. | |
void | remove (QLatin1StringView key) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Removes the key key and the corresponding value from the map, if it is found. | |
void | remove (const QString &key) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Removes the key key and the corresponding value from the map, if it is found. | |
void | remove (const QCborValue &key) |
Removes the key key and the corresponding value from the map, if it is found. | |
bool | contains (qint64 key) const |
Returns true if this map contains a key-value pair identified by key key. | |
bool | contains (QLatin1StringView key) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if this map contains a key-value pair identified by key key. | |
bool | contains (const QString &key) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if this map contains a key-value pair identified by key key. | |
bool | contains (const QCborValue &key) const |
Returns true if this map contains a key-value pair identified by key key. | |
int | compare (const QCborMap &other) const noexcept Q_DECL_PURE_FUNCTION |
Compares this map and other, comparing each element in sequence, and returns an integer that indicates whether this map should be sorted prior to (if the result is negative) or after other (if the result is positive). | |
bool | operator== (const QCborMap &other) const noexcept |
Compares this map and other, comparing each element in sequence, and returns true if the two maps contains the same elements in the same order, false otherwise. | |
bool | operator!= (const QCborMap &other) const noexcept |
Compares this map and other, comparing each element in sequence, and returns true if the two maps contains any different elements or elements in different orders, false otherwise. | |
bool | operator< (const QCborMap &other) const |
Compares this map and other, comparing each element in sequence, and returns true if this map should be sorted before other, false otherwise. | |
iterator | begin () |
Returns a map iterator pointing to the first key-value pair of this map. | |
const_iterator | constBegin () const |
Returns a map iterator pointing to the first key-value pair of this map. | |
const_iterator | begin () const |
Returns a map iterator pointing to the first key-value pair of this map. | |
const_iterator | cbegin () const |
Returns a map iterator pointing to the first key-value pair of this map. | |
iterator | end () |
Returns a map iterator representing an element just past the last element in the map. | |
const_iterator | constEnd () const |
Returns a map iterator representing an element just past the last element in the map. | |
const_iterator | end () const |
Returns a map iterator representing an element just past the last element in the map. | |
const_iterator | cend () const |
Returns a map iterator representing an element just past the last element in the map. | |
iterator | erase (iterator it) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Removes the key-value pair pointed to by the map iterator it and returns a pointer to the next element, after removal. | |
iterator | erase (const_iterator it) |
Removes the key-value pair pointed to by the map iterator it and returns a pointer to the next element, after removal. | |
QCborValue | extract (iterator it) |
QCborValue | extract (const_iterator it) |
Extracts a value from the map at the position indicated by iterator it and returns the value so extracted. | |
bool | empty () const |
Synonym for isEmpty(). | |
iterator | find (qint64 key) |
iterator | find (QLatin1StringView key) |
iterator | find (const QString &key) |
iterator | find (const QCborValue &key) |
const_iterator | constFind (qint64 key) const |
Returns a map iterator to the key-value pair whose key is key, if the map contains such a pair. | |
const_iterator | constFind (QLatin1StringView key) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a map iterator to the key-value pair whose key is key, if the map contains such a pair. | |
const_iterator | constFind (const QString &key) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a map iterator to the key-value pair whose key is key, if the map contains such a pair. | |
const_iterator | constFind (const QCborValue &key) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a map iterator to the key-value pair whose key is key, if the map contains such a pair. | |
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. | |
const_iterator | find (QLatin1StringView key) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a map iterator to the key-value pair whose key is key, if the map contains such a pair. | |
const_iterator | find (const QString &key) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a map iterator to the key-value pair whose key is key, if the map contains such a pair. | |
const_iterator | find (const QCborValue &key) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a map iterator to the key-value pair whose key is key, if the map contains such a pair. | |
iterator | insert (qint64 key, const QCborValue &value_) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Inserts the key key and value value into this map and returns a map iterator pointing to the newly inserted pair. | |
iterator | insert (QLatin1StringView key, const QCborValue &value_) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Inserts the key key and value value into this map and returns a map iterator pointing to the newly inserted pair. | |
iterator | insert (const QString &key, const QCborValue &value_) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Inserts the key key and value value into this map and returns a map iterator pointing to the newly inserted pair. | |
iterator | insert (const QCborValue &key, const QCborValue &value_) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Inserts the key key and value value into this map and returns a map iterator pointing to the newly inserted pair. | |
iterator | insert (value_type v) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Inserts the key-value pair in v into this map and returns a map iterator pointing to the newly inserted pair. | |
QVariantMap | toVariantMap () const |
Converts the CBOR values to QVariant using QCborValue::toVariant() and "stringifies" all the CBOR keys in this map, returning the QVariantMap that results from that association list. | |
QVariantHash | toVariantHash () const |
Converts the CBOR values to QVariant using QCborValue::toVariant() and "stringifies" all the CBOR keys in this map, returning the QVariantHash that results from that association list. | |
QJsonObject | toJsonObject () const |
Recursively converts every \l QCborValue value in this map to JSON using QCborValue::toJsonValue() and creates a string key for all keys that aren't strings, then returns the corresponding QJsonObject composed of those associations. | |
Static Public Member Functions | |
static QCborMap | fromVariantMap (const QVariantMap &map) |
Converts all the items in map to CBOR using QCborValue::fromVariant() and returns the map composed of those elements. | |
static QCborMap | fromVariantHash (const QVariantHash &hash) |
Converts all the items in hash to CBOR using QCborValue::fromVariant() and returns the map composed of those elements. | |
static QCborMap | fromJsonObject (const QJsonObject &o) |
Converts all JSON items found in the obj object to CBOR using QCborValue::fromJson(), and returns the map composed of those elements. | |
static QCborMap | fromJsonObject (QJsonObject &&o) noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
Friends | |
class | QCborContainerPrivate |
class | QCborValue |
class | QCborValueRef |
class | QJsonPrivate::Variant |
\inmodule QtCore
\reentrant
The QCborMap class is used to hold an associative container representable in CBOR.
This class can be used to hold an associative container in CBOR, a map between a key and a value type. CBOR is the Concise Binary Object Representation, a very compact form of binary data encoding that is a superset of JSON. It was created by the IETF Constrained RESTful Environments (CoRE) WG, which has used it in many new RFCs. It is meant to be used alongside the \l{RFC 7252}{CoAP protocol}.
Unlike JSON and \l QVariantMap, CBOR map keys can be of any type, not just strings. For that reason, QCborMap is effectively a map between QCborValue keys to QCborValue value elements.
However, for all member functions that take a key parameter, QCborMap provides overloads that will work efficiently with integers and strings. In fact, the use of integer keys is encouraged, since they occupy fewer bytes to transmit and are simpler to encode and decode. Newer protocols designed by the IETF CoRE WG to work specifically with CBOR are known to use them.
QCborMap is not sorted, because of that, searching for keys has linear complexity (O(n)). QCborMap actually keeps the elements in the order that they were inserted, which means that it is possible to make sorted QCborMaps by carefully inserting elements in sorted order. CBOR does not require sorting, but recommends it.
QCborMap can also be converted to and from QVariantMap and QJsonObject. However, when performing the conversion, any non-string keys will be stringified using a one-way method that the conversion back to QCborMap will not undo.
Definition at line 20 of file qcbormap.h.
A synonym for QCborMap::ConstIterator.
Definition at line 242 of file qcbormap.h.
A synonym for QCborMap::Iterator.
Definition at line 241 of file qcbormap.h.
The key type for this map.
Since QCborMap keys can be any CBOR type, this is a QCborValue.
Definition at line 24 of file qcbormap.h.
The type that is mapped to (the value), that is, a QCborValue.
Definition at line 25 of file qcbormap.h.
The type that QCborMap uses for sizes.
Definition at line 26 of file qcbormap.h.
The value that is stored in this container: a pair of QCborValues.
Definition at line 23 of file qcbormap.h.
|
noexcept |
|
noexcept |
Creates a QCborMap object that is a copy of other.
Definition at line 177 of file qcbormap.cpp.
|
inline |
Constructs a QCborMap with items from a brace-initialization list found in args, as in the following example:
Definition at line 148 of file qcbormap.h.
References args, insert(), and QList< T >::size().
QCborMap::~QCborMap | ( | ) |
Destroys this QCborMap object and frees any associated resources it owns.
Definition at line 201 of file qcbormap.cpp.
|
inline |
Returns a map iterator pointing to the first key-value pair of this map.
If this map is empty, the returned iterator will be the same as end().
Definition at line 243 of file qcbormap.h.
References d.
|
inline |
Returns a map iterator pointing to the first key-value pair of this map.
If this map is empty, the returned iterator will be the same as constEnd().
Definition at line 245 of file qcbormap.h.
|
inline |
Returns a map iterator pointing to the first key-value pair of this map.
If this map is empty, the returned iterator will be the same as constEnd().
Definition at line 246 of file qcbormap.h.
|
inline |
Returns a map iterator representing an element just past the last element in the map.
Definition at line 250 of file qcbormap.h.
void QCborMap::clear | ( | ) |
Empties this map.
Definition at line 258 of file qcbormap.cpp.
References QExplicitlySharedDataPointer< T >::reset().
|
noexcept |
Compares this map and other, comparing each element in sequence, and returns an integer that indicates whether this map should be sorted prior to (if the result is negative) or after other (if the result is positive).
If this function returns 0, the two maps are equal and contain the same elements.
Note that CBOR maps are unordered, which means that two maps containing the very same pairs but in different order will still compare differently. To avoid this, it is recommended to insert elements into the map in a predictable order, such as by ascending key value. In fact, maps with keys in sorted order are required for Canonical CBOR representation.
For more information on CBOR sorting order, see QCborValue::compare().
Definition at line 1331 of file qcborvalue.cpp.
References compareContainer(), d, and other().
|
inline |
Returns a map iterator pointing to the first key-value pair of this map.
If this map is empty, the returned iterator will be the same as constEnd().
Definition at line 244 of file qcbormap.h.
References d.
|
inline |
Returns a map iterator representing an element just past the last element in the map.
Definition at line 248 of file qcbormap.h.
References d.
Referenced by constFind(), constFind(), constFind(), and constFind().
QCborMap::const_iterator QCborMap::constFind | ( | const QCborValue & | key | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a map iterator to the key-value pair whose key is key, if the map contains such a pair.
If it doesn't, this function returns constEnd().
If the map contains more than one key equal to key, it is undefined which one this function will find. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 952 of file qcbormap.cpp.
References constEnd(), and QCborContainerPrivate::findCborMapKey().
QCborMap::const_iterator QCborMap::constFind | ( | const QString & | key | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a map iterator to the key-value pair whose key is key, if the map contains such a pair.
If it doesn't, this function returns constEnd().
If the map contains more than one key equal to key, it is undefined which one this function will find. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 931 of file qcbormap.cpp.
References constEnd(), QCborContainerPrivate::findCborMapKey(), and qToStringViewIgnoringNull().
QCborMap::const_iterator QCborMap::constFind | ( | qint64 | key | ) | const |
Returns a map iterator to the key-value pair whose key is key, if the map contains such a pair.
If it doesn't, this function returns constEnd().
CBOR recommends using integer keys, since they occupy less space and are simpler to encode and decode.
If the map contains more than one key equal to key, it is undefined which one this function will find. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 889 of file qcbormap.cpp.
References constEnd(), and QCborContainerPrivate::findCborMapKey().
Referenced by find(), find(), find(), and find().
QCborMap::const_iterator QCborMap::constFind | ( | QLatin1StringView | key | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a map iterator to the key-value pair whose key is key, if the map contains such a pair.
If it doesn't, this function returns constEnd().
If the map contains more than one key equal to key, it is undefined which one this function will find. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 910 of file qcbormap.cpp.
References constEnd(), and QCborContainerPrivate::findCborMapKey().
|
inline |
Returns true if this map contains a key-value pair identified by key key.
Definition at line 220 of file qcbormap.h.
References it.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if this map contains a key-value pair identified by key key.
Definition at line 218 of file qcbormap.h.
References it.
|
inline |
Returns true if this map contains a key-value pair identified by key key.
CBOR recommends using integer keys, since they occupy less space and are simpler to encode and decode.
Definition at line 214 of file qcbormap.h.
References it.
Referenced by QGeoServiceProviderPrivate::features(), QGeoServiceProviderPrivate::loadMeta(), and QQuickSplitView::restoreState().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if this map contains a key-value pair identified by key key.
Definition at line 216 of file qcbormap.h.
References it.
|
inline |
|
inline |
Returns a map iterator representing an element just past the last element in the map.
Definition at line 247 of file qcbormap.h.
References d.
|
inline |
Returns a map iterator representing an element just past the last element in the map.
Definition at line 249 of file qcbormap.h.
|
inline |
Removes the key-value pair pointed to by the map iterator it and returns a pointer to the next element, after removal.
Definition at line 252 of file qcbormap.h.
Referenced by erase().
QCborMap::iterator QCborMap::erase | ( | QCborMap::iterator | it | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Removes the key-value pair pointed to by the map iterator it and returns a pointer to the next element, after removal.
Definition at line 1044 of file qcbormap.cpp.
References it, and QCborContainerPrivate::removeAt().
|
inline |
Extracts a value from the map at the position indicated by iterator it and returns the value so extracted.
Definition at line 254 of file qcbormap.h.
Referenced by extract().
QCborValue QCborMap::extract | ( | iterator | it | ) |
Definition at line 1064 of file qcbormap.cpp.
References QCborContainerPrivate::extractAt(), it, and QCborContainerPrivate::removeAt().
QCborMap::iterator QCborMap::find | ( | const QCborValue & | key | ) |
Definition at line 866 of file qcbormap.cpp.
References constFind(), QExplicitlySharedDataPointer< T >::data(), and it.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a map iterator to the key-value pair whose key is key, if the map contains such a pair.
If it doesn't, this function returns end().
If the map contains more than one key equal to key, it is undefined which one this function will find. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 268 of file qcbormap.h.
QCborMap::iterator QCborMap::find | ( | const QString & | key | ) |
Definition at line 841 of file qcbormap.cpp.
References constFind(), QExplicitlySharedDataPointer< T >::data(), and it.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a map iterator to the key-value pair whose key is key, if the map contains such a pair.
If it doesn't, this function returns end().
If the map contains more than one key equal to key, it is undefined which one this function will find. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 267 of file qcbormap.h.
QCborMap::iterator QCborMap::find | ( | qint64 | key | ) |
Definition at line 791 of file qcbormap.cpp.
References constFind(), QExplicitlySharedDataPointer< T >::data(), and it.
|
inline |
Returns a map iterator to the key-value pair whose key is key, if the map contains such a pair.
If it doesn't, this function returns end().
CBOR recommends using integer keys, since they occupy less space and are simpler to encode and decode.
If the map contains more than one key equal to key, it is undefined which one this function will find. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 265 of file qcbormap.h.
QCborMap::iterator QCborMap::find | ( | QLatin1StringView | key | ) |
Definition at line 816 of file qcbormap.cpp.
References constFind(), QExplicitlySharedDataPointer< T >::data(), and it.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a map iterator to the key-value pair whose key is key, if the map contains such a pair.
If it doesn't, this function returns end().
If the map contains more than one key equal to key, it is undefined which one this function will find. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 266 of file qcbormap.h.
|
static |
Converts all JSON items found in the obj object to CBOR using QCborValue::fromJson(), and returns the map composed of those elements.
This conversion is lossless, as the CBOR type system is a superset of JSON's. Moreover, the map returned by this function can be converted back to the original obj by using toJsonObject().
Definition at line 972 of file qjsoncbor.cpp.
Referenced by QCborValue::fromJsonValue(), QCborValue::fromVariant(), QJsonObject::toVariantHash(), and QJsonObject::toVariantMap().
|
staticnoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 983 of file qjsoncbor.cpp.
|
static |
Converts all the items in hash to CBOR using QCborValue::fromVariant() and returns the map composed of those elements.
Conversion from \l QVariant is not completely lossless. Please see the documentation in QCborValue::fromVariant() for more information.
Definition at line 947 of file qjsoncbor.cpp.
References appendVariant(), d, hash, and it.
Referenced by QCborValue::fromVariant().
|
static |
Converts all the items in map to CBOR using QCborValue::fromVariant() and returns the map composed of those elements.
Conversion from \l QVariant is not completely lossless. Please see the documentation in QCborValue::fromVariant() for more information.
Definition at line 923 of file qjsoncbor.cpp.
References appendVariant(), QMap< Key, T >::begin(), d, QMap< Key, T >::end(), it, map, and QMap< Key, T >::size().
Referenced by QCborValue::fromVariant(), and QJsonPrivate::Variant::toJsonObject().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Inserts the key key and value value into this map and returns a map iterator pointing to the newly inserted pair.
If the map already had a key equal to key, its value will be overwritten by value.
Definition at line 288 of file qcbormap.h.
References d.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Inserts the key key and value value into this map and returns a map iterator pointing to the newly inserted pair.
If the map already had a key equal to key, its value will be overwritten by value.
Definition at line 282 of file qcbormap.h.
References d.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Inserts the key key and value value into this map and returns a map iterator pointing to the newly inserted pair.
If the map already had a key equal to key, its value will be overwritten by value.
Definition at line 270 of file qcbormap.h.
References d.
Referenced by QGeoServiceProviderPrivate::QGeoServiceProviderPrivate(), QGeoServiceProviderPrivate::loadMeta(), and QGeoServiceProviderPrivate::unload().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Inserts the key key and value value into this map and returns a map iterator pointing to the newly inserted pair.
If the map already had a key equal to key, its value will be overwritten by value.
Definition at line 276 of file qcbormap.h.
References d.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Inserts the key-value pair in v into this map and returns a map iterator pointing to the newly inserted pair.
If the map already had a key equal to {v.first}, its value will be overwritten by
{v.second}.
Definition at line 294 of file qcbormap.h.
References insert().
Referenced by insert().
|
inline |
Returns true if this map is empty (that is, size() is 0).
Definition at line 165 of file qcbormap.h.
QList< QCborValue > QCborMap::keys | ( | ) | const |
Returns a list of all keys in this map.
Definition at line 268 of file qcbormap.cpp.
References QCborContainerPrivate::elements, i, QList< T >::size(), and QCborContainerPrivate::valueAt().
|
inlinenoexcept |
Compares this map and other, comparing each element in sequence, and returns true if the two maps contains any different elements or elements in different orders, false otherwise.
Note that CBOR maps are unordered, which means that two maps containing the very same pairs but in different order will still compare differently. To avoid this, it is recommended to insert elements into the map in a predictable order, such as by ascending key value. In fact, maps with keys in sorted order are required for Canonical CBOR representation.
For more information on CBOR equality in Qt, see, QCborValue::compare().
Definition at line 235 of file qcbormap.h.
References other().
|
inline |
Compares this map and other, comparing each element in sequence, and returns true if this map should be sorted before other, false otherwise.
Note that CBOR maps are unordered, which means that two maps containing the very same pairs but in different order will still compare differently. To avoid this, it is recommended to insert elements into the map in a predictable order, such as by ascending key value. In fact, maps with keys in sorted order are required for Canonical CBOR representation.
For more information on CBOR sorting order, see QCborValue::compare().
Definition at line 237 of file qcbormap.h.
References compare(), and other().
Replaces the contents of this object with a copy of other, then returns a reference to this object.
Definition at line 209 of file qcbormap.cpp.
|
inlinenoexcept |
Compares this map and other, comparing each element in sequence, and returns true if the two maps contains the same elements in the same order, false otherwise.
Note that CBOR maps are unordered, which means that two maps containing the very same pairs but in different order will still compare differently. To avoid this, it is recommended to insert elements into the map in a predictable order, such as by ascending key value. In fact, maps with keys in sorted order are required for Canonical CBOR representation.
For more information on CBOR equality in Qt, see, QCborValue::compare().
Definition at line 233 of file qcbormap.h.
References compare(), and other().
|
inline |
Definition at line 190 of file qcbormap.h.
References QString::fromUtf8().
QCborValueRef QCborMap::operator[] | ( | const QCborValue & | key | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a QCborValueRef to the value in this map that corresponds to key key.
QCborValueRef has the exact same API as \l QCborValue, with one important difference: if you assign new values to it, this map will be updated with that new value.
If the map did not have a key equal to key, one is inserted and this function returns a reference to the new value, which will be a QCborValue with an undefined value. For that reason, it is not possible with this function to tell apart the situation where the key was not present from the situation where the key was mapped to an undefined value.
If the map contains more than one key equal to key, it is undefined which one the return will reference. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 759 of file qcbormap.cpp.
|
inline |
Returns the QCborValue element in this map that corresponds to key key, if there is one.
If the map does not contain key key, this function returns a QCborValue containing an undefined value. For that reason, it is not possible with this function to tell apart the situation where the key was not present from the situation where the key was mapped to an undefined value.
If the map contains more than one key equal to key, it is undefined which one this function will return. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 187 of file qcbormap.h.
References it.
QCborValueRef QCborMap::operator[] | ( | const QString & | key | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a QCborValueRef to the value in this map that corresponds to key key.
QCborValueRef has the exact same API as \l QCborValue, with one important difference: if you assign new values to it, this map will be updated with that new value.
If the map did not have a key equal to key, one is inserted and this function returns a reference to the new value, which will be a QCborValue with an undefined value. For that reason, it is not possible with this function to tell apart the situation where the key was not present from the situation where the key was mapped to an undefined value.
If the map contains more than one key equal to key, it is undefined which one the return will reference. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 639 of file qcbormap.cpp.
References QCborContainerPrivate::findOrAddMapKey(), and qToStringViewIgnoringNull().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the QCborValue element in this map that corresponds to key key, if there is one.
If the map does not contain key key, this function returns a QCborValue containing an undefined value. For that reason, it is not possible with this function to tell apart the situation where the key was not present from the situation where the key was mapped to an undefined value.
If the map contains more than one key equal to key, it is undefined which one this function will return. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 185 of file qcbormap.h.
References it.
QCborValueRef QCborMap::operator[] | ( | qint64 | key | ) |
Returns a QCborValueRef to the value in this map that corresponds to key key.
CBOR recommends using integer keys, since they occupy less space and are simpler to encode and decode.
QCborValueRef has the exact same API as \l QCborValue, with one important difference: if you assign new values to it, this map will be updated with that new value.
If the map did not have a key equal to key, one is inserted and this function returns a reference to the new value, which will be a QCborValue with an undefined value. For that reason, it is not possible with this function to tell apart the situation where the key was not present from the situation where the key was mapped to an undefined value.
If the map contains more than one key equal to key, it is undefined which one the return will reference. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 391 of file qcbormap.cpp.
References QCborContainerPrivate::findOrAddMapKey().
|
inline |
Returns the QCborValue element in this map that corresponds to key key, if there is one.
CBOR recommends using integer keys, since they occupy less space and are simpler to encode and decode.
If the map does not contain key key, this function returns a QCborValue containing an undefined value. For that reason, it is not possible with this function to tell apart the situation where the key was not present from the situation where the key was mapped to an undefined value.
If the map contains more than one key equal to key, it is undefined which one this function will return. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 181 of file qcbormap.h.
References it.
QCborValueRef QCborMap::operator[] | ( | QLatin1StringView | key | ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a QCborValueRef to the value in this map that corresponds to key key.
QCborValueRef has the exact same API as \l QCborValue, with one important difference: if you assign new values to it, this map will be updated with that new value.
If the map did not have a key equal to key, one is inserted and this function returns a reference to the new value, which will be a QCborValue with an undefined value. For that reason, it is not possible with this function to tell apart the situation where the key was not present from the situation where the key was mapped to an undefined value.
If the map contains more than one key equal to key, it is undefined which one the return will reference. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 515 of file qcbormap.cpp.
References QCborContainerPrivate::findOrAddMapKey().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the QCborValue element in this map that corresponds to key key, if there is one.
If the map does not contain key key, this function returns a QCborValue containing an undefined value. For that reason, it is not possible with this function to tell apart the situation where the key was not present from the situation where the key was mapped to an undefined value.
If the map contains more than one key equal to key, it is undefined which one this function will return. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 183 of file qcbormap.h.
References it.
|
inline |
Removes the key key and the corresponding value from the map, if it is found.
If the map contains no such key, this function does nothing.
If the map contains more than one key equal to key, it is undefined which one this function will remove. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 212 of file qcbormap.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Removes the key key and the corresponding value from the map, if it is found.
If the map contains no such key, this function does nothing.
If the map contains more than one key equal to key, it is undefined which one this function will remove. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 210 of file qcbormap.h.
Removes the key key and the corresponding value from the map, if it is found.
If the map contains no such key, this function does nothing.
If the map contains more than one key equal to key, it is undefined which one this function will remove. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 206 of file qcbormap.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Removes the key key and the corresponding value from the map, if it is found.
If the map contains no such key, this function does nothing.
If the map contains more than one key equal to key, it is undefined which one this function will remove. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 208 of file qcbormap.h.
|
noexcept |
Returns the number of elements in this map.
Definition at line 248 of file qcbormap.cpp.
References QCborContainerPrivate::elements, and QList< T >::size().
Swaps the contents of this map and other.
Definition at line 157 of file qcbormap.h.
|
inline |
Removes the key key and the corresponding value from the map and returns the value, if it is found.
If the map contains no such key, this function does nothing.
If the map contains more than one key equal to key, it is undefined which one this function will remove. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 204 of file qcbormap.h.
References it.
|
inline |
Removes the key key and the corresponding value from the map and returns the value, if it is found.
If the map contains no such key, this function does nothing.
If the map contains more than one key equal to key, it is undefined which one this function will remove. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 202 of file qcbormap.h.
References it.
|
inline |
Removes the key key and the corresponding value from the map and returns the value, if it is found.
If the map contains no such key, this function does nothing.
If the map contains more than one key equal to key, it is undefined which one this function will remove. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 198 of file qcbormap.h.
References it.
|
inline |
Removes the key key and the corresponding value from the map and returns the value, if it is found.
If the map contains no such key, this function does nothing.
If the map contains more than one key equal to key, it is undefined which one this function will remove. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 200 of file qcbormap.h.
References it.
|
inline |
Explicitly constructs a \l QCborValue object that represents this map.
This function is usually not necessary since QCborValue has a constructor for QCborMap, so the conversion is implicit.
Converting QCborMap to QCborValue allows it to be used in any context where QCborValues can be used, including as keys and mapped types in QCborMap, as well as QCborValue::toCbor().
Definition at line 162 of file qcbormap.h.
QJsonObject QCborMap::toJsonObject | ( | ) | const |
Recursively converts every \l QCborValue value in this map to JSON using QCborValue::toJsonValue() and creates a string key for all keys that aren't strings, then returns the corresponding QJsonObject composed of those associations.
Please note that CBOR contains a richer and wider type set than JSON, so some information may be lost in this conversion. For more details on what conversions are applied, see QCborValue::toJsonValue().
Definition at line 467 of file qjsoncbor.cpp.
References convertToJsonObject(), and d.
QVariantHash QCborMap::toVariantHash | ( | ) | const |
Converts the CBOR values to QVariant using QCborValue::toVariant() and "stringifies" all the CBOR keys in this map, returning the QVariantHash that results from that association list.
QVariantMaps have string keys, unlike CBOR, so the conversion of a QCborMap to QVariantMap will imply a step of "stringification" of the key values. See QCborMap::toJsonObject() for details.
In addition, the conversion to \l QVariant is not completely lossless. Please see the documentation in QCborValue::toVariant() for more information.
Definition at line 905 of file qjsoncbor.cpp.
References d, i, QHash< Key, T >::insert(), makeString(), and QHash< Key, T >::reserve().
Referenced by QJsonObject::toVariantHash().
QVariantMap QCborMap::toVariantMap | ( | ) | const |
Converts the CBOR values to QVariant using QCborValue::toVariant() and "stringifies" all the CBOR keys in this map, returning the QVariantMap that results from that association list.
QVariantMaps have string keys, unlike CBOR, so the conversion of a QCborMap to QVariantMap will imply a step of "stringification" of the key values. See QCborMap::toJsonObject() for details.
In addition, the conversion to \l QVariant is not completely lossless. Please see the documentation in QCborValue::toVariant() for more information.
Definition at line 881 of file qjsoncbor.cpp.
References d, i, QMap< Key, T >::insert(), and makeString().
Referenced by QJsonObject::toVariantMap().
|
inline |
Definition at line 178 of file qcbormap.h.
References QString::fromUtf8().
|
inline |
Returns the QCborValue element in this map that corresponds to key key, if there is one.
If the map does not contain key key, this function returns a QCborValue containing an undefined value. For that reason, it is not possible with this function to tell apart the situation where the key was not present from the situation where the key was mapped to an undefined value.
If the map contains more than one key equal to key, it is undefined which one this function will return. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 175 of file qcbormap.h.
References it.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the QCborValue element in this map that corresponds to key key, if there is one.
If the map does not contain key key, this function returns a QCborValue containing an undefined value. For that reason, it is not possible with this function to tell apart the situation where the key was not present from the situation where the key was mapped to an undefined value.
If the map contains more than one key equal to key, it is undefined which one this function will return. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 173 of file qcbormap.h.
References it.
|
inline |
Returns the QCborValue element in this map that corresponds to key key, if there is one.
CBOR recommends using integer keys, since they occupy less space and are simpler to encode and decode.
If the map does not contain key key, this function returns a QCborValue containing an undefined value. For that reason, it is not possible with this function to tell apart the situation where the key was not present from the situation where the key was mapped to an undefined value.
If the map contains more than one key equal to key, it is undefined which one the return from function will reference. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 169 of file qcbormap.h.
References it.
Referenced by QImageReaderWriterHelpers::appendImagePluginMimeTypes(), QmlTypesClassDescription::collect(), QmlTypesClassDescription::collectLocalAnonymous(), QGeoPositionInfoSourcePrivate::createSourceReal(), QGeoSatelliteInfoSourcePrivate::createSourceReal(), QGeoServiceProviderPrivate::features(), QGeoPositionInfoSourcePrivate::loadFactory(), QGeoServiceProviderPrivate::loadMeta(), QGeoServiceProviderPrivate::loadPlugin(), QGeoServiceProviderPrivate::manager(), members(), and QQuickSplitView::restoreState().
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the QCborValue element in this map that corresponds to key key, if there is one.
If the map does not contain key key, this function returns a QCborValue containing an undefined value. For that reason, it is not possible with this function to tell apart the situation where the key was not present from the situation where the key was mapped to an undefined value.
If the map contains more than one key equal to key, it is undefined which one this function will return. QCborMap does not allow inserting duplicate keys, but it is possible to create such a map by decoding a CBOR stream with them. They are usually not permitted and having duplicate keys is usually an indication of a problem in the sender.
Definition at line 171 of file qcbormap.h.
References it.
|
friend |
Definition at line 305 of file qcbormap.h.
|
friend |
Definition at line 306 of file qcbormap.h.
|
friend |
Definition at line 307 of file qcbormap.h.
|
friend |
Definition at line 308 of file qcbormap.h.