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
QCborMap Class Reference

\inmodule QtCore\reentrant More...

#include <qcbormap.h>

Collaboration diagram for QCborMap:

Classes

class  ConstIterator
 \inmodule QtCore More...
class  Iterator
 \inmodule QtCore\reentrant More...

Public Types

typedef std::pair< QCborValue, QCborValuevalue_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.
typedef QKeyValueIterator< QCborValueConstRef, QCborValueConstRef, const_iterator, QtPrivate::QCborMapKeyValues< QCborValueConstRef, ConstIterator > > const_key_value_iterator
 \inmodule QtCore
typedef QKeyValueIterator< QCborValueConstRef, QCborValueRef, iterator, QtPrivate::QCborMapKeyValues< QCborValueRef, Iterator > > key_value_iterator
 \inmodule QtCore

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 (QCborMap &&other) noexcept=default
QCborMapoperator= (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
 \memberswap{map}
QCborValue toCborValue () const
 Explicitly constructs a \l QCborValue object that represents this map.
Q_DECL_PURE_FUNCTION qsizetype size () const noexcept
 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< QCborValuekeys () 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.
Q_DECL_PURE_FUNCTION int compare (const QCborMap &other) const 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).
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().
key_value_iterator keyValueBegin ()
key_value_iterator keyValueEnd ()
const_key_value_iterator keyValueBegin () const
const_key_value_iterator constKeyValueBegin () const
const_key_value_iterator keyValueEnd () const
const_key_value_iterator constKeyValueEnd () const
auto asKeyValueRange () &
auto asKeyValueRange () const &
auto asKeyValueRange () &&
auto asKeyValueRange () const &&
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
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool comparesEqual (const QCborMap &lhs, const QCborMap &rhs)
Qt::strong_ordering compareThreeWay (const QCborMap &lhs, const QCborMap &rhs) noexcept
bool comparesEqual (const QCborMap &lhs, const QCborValue &rhs) noexcept
Qt::strong_ordering compareThreeWay (const QCborMap &lhs, const QCborValue &rhs) noexcept
bool comparesEqual (const QCborMap &lhs, const QCborValueConstRef &rhs) noexcept
Qt::strong_ordering compareThreeWay (const QCborMap &lhs, const QCborValueConstRef &rhs) noexcept

Detailed Description

\inmodule QtCore

\reentrant

Since
5.12

The QCborMap class is used to hold an associative container representable in CBOR.

\compares strong \compareswith strong QCborValue QCborValueConstRef \endcompareswith

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.

See also
QCborArray, QCborValue, QJsonDocument, QVariantMap, {Parsing and displaying CBOR data}, {Serialization Converter}, {Saving and Loading a Game}

Definition at line 34 of file qcbormap.h.

Member Typedef Documentation

◆ const_iterator

A synonym for QCborMap::ConstIterator.

Definition at line 331 of file qcbormap.h.

◆ const_key_value_iterator

\inmodule QtCore

Since
6.10

The QCborMap::const_key_value_iterator typedef provides an STL-style iterator for QCborMap.

QCborMap::const_key_value_iterator is essentially the same as QCborMap::const_iterator but provided for symmetry with other containers like QJsonObject.

See also
QKeyValueIterator

Definition at line 348 of file qcbormap.h.

◆ iterator

A synonym for QCborMap::Iterator.

Definition at line 330 of file qcbormap.h.

◆ key_type

The key type for this map.

Since QCborMap keys can be any CBOR type, this is a QCborValue.

Definition at line 38 of file qcbormap.h.

◆ key_value_iterator

\inmodule QtCore

Since
6.10

The QCborMap::key_value_iterator typedef provides an STL-style iterator for QCborMap.

QCborMap::key_value_iterator is essentially the same as QCborMap::iterator but provided for symmetry with other containers like QJsonObject.

See also
QKeyValueIterator

Definition at line 351 of file qcbormap.h.

◆ mapped_type

The type that is mapped to (the value), that is, a QCborValue.

Definition at line 39 of file qcbormap.h.

◆ size_type

The type that QCborMap uses for sizes.

Definition at line 40 of file qcbormap.h.

◆ value_type

The value that is stored in this container: a pair of QCborValues.

Definition at line 37 of file qcbormap.h.

Constructor & Destructor Documentation

◆ QCborMap() [1/4]

QCborMap::QCborMap ( )
noexcept

Constructs an empty CBOR Map object.

See also
isEmpty()

Definition at line 265 of file qcbormap.cpp.

◆ QCborMap() [2/4]

QCborMap::QCborMap ( const QCborMap & other)
noexcept

Creates a QCborMap object that is a copy of other.

Definition at line 273 of file qcbormap.cpp.

◆ QCborMap() [3/4]

QCborMap::QCborMap ( QCborMap && other)
defaultnoexcept
Since
6.10

Move-constructor.

The moved-from object other is placed in the default-constructed state.

See also
QCborMap::QCborMap()

◆ QCborMap() [4/4]

QCborMap::QCborMap ( std::initializer_list< value_type > args)
inline

Constructs a QCborMap with items from a brace-initialization list found in args, as in the following example:

QCborMap map = {
{0, "Hello"},
{1, "World"},
{"foo", nullptr},
{"bar", QCborArray{0, 1, 2, 3, 4}}
};
QCborMap() noexcept
Constructs an empty CBOR Map object.
Definition qcbormap.cpp:265

Definition at line 245 of file qcbormap.h.

◆ ~QCborMap()

QCborMap::~QCborMap ( )

Destroys this QCborMap object and frees any associated resources it owns.

Definition at line 308 of file qcbormap.cpp.

Member Function Documentation

◆ asKeyValueRange() [1/4]

auto QCborMap::asKeyValueRange ( ) &
inline

Definition at line 363 of file qcbormap.h.

◆ asKeyValueRange() [2/4]

auto QCborMap::asKeyValueRange ( ) &&
inline

Definition at line 365 of file qcbormap.h.

◆ asKeyValueRange() [3/4]

auto QCborMap::asKeyValueRange ( ) const &
inline

Definition at line 364 of file qcbormap.h.

◆ asKeyValueRange() [4/4]

auto QCborMap::asKeyValueRange ( ) const &&
inline

Definition at line 366 of file qcbormap.h.

◆ begin() [1/2]

iterator QCborMap::begin ( )
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().

See also
constBegin(), end()

Definition at line 332 of file qcbormap.h.

◆ begin() [2/2]

const_iterator QCborMap::begin ( ) const
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().

See also
begin(), constEnd()

Definition at line 334 of file qcbormap.h.

◆ cbegin()

const_iterator QCborMap::cbegin ( ) const
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().

See also
begin(), constEnd()

Definition at line 335 of file qcbormap.h.

◆ cend()

const_iterator QCborMap::cend ( ) const
inline

Returns a map iterator representing an element just past the last element in the map.

See also
begin(), constBegin(), find(), constFind()

Definition at line 339 of file qcbormap.h.

◆ clear()

void QCborMap::clear ( )

Empties this map.

See also
isEmpty()

Definition at line 373 of file qcbormap.cpp.

◆ compare()

int QCborMap::compare ( const QCborMap & other) const
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().

See also
QCborValue::compare(), QCborArray::compare(), operator==()

Definition at line 1529 of file qcborvalue.cpp.

◆ constBegin()

const_iterator QCborMap::constBegin ( ) const
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().

See also
begin(), constEnd()

Definition at line 333 of file qcbormap.h.

◆ constEnd()

const_iterator QCborMap::constEnd ( ) const
inline

Returns a map iterator representing an element just past the last element in the map.

See also
begin(), constBegin(), find(), constFind()

Definition at line 337 of file qcbormap.h.

◆ constFind() [1/4]

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.

See also
value(const QCborValue &), operator[](const QCborValue &), find(const QCborValue &), remove(const QCborValue &), contains(const QCborValue &), value(qint64), value(QLatin1StringView), value(const QString &)

Definition at line 1067 of file qcbormap.cpp.

◆ constFind() [2/4]

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.

See also
value(const QString &), operator[](const QString &), find(const QString &), remove(const QString &), contains(const QString &), value(qint64), value(QLatin1StringView), value(const QCborValue &)

Definition at line 1046 of file qcbormap.cpp.

◆ constFind() [3/4]

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.

See also
value(qint64), operator[](qint64), find(qint64), remove(qint64), contains(qint64), value(QLatin1StringView), value(const QString &), value(const QCborValue &)

Definition at line 1004 of file qcbormap.cpp.

◆ constFind() [4/4]

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.

See also
value(QLatin1StringView), operator[](QLatin1StringView), find(QLatin1StringView), remove(QLatin1StringView), contains(QLatin1StringView), value(qint64), value(const QString &), value(const QCborValue &)

Definition at line 1025 of file qcbormap.cpp.

◆ constKeyValueBegin()

const_key_value_iterator QCborMap::constKeyValueBegin ( ) const
inline
Since
6.10

Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first entry in the map.

See also
keyValueBegin()

Definition at line 356 of file qcbormap.h.

◆ constKeyValueEnd()

const_key_value_iterator QCborMap::constKeyValueEnd ( ) const
inline
Since
6.10

Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary entry after the last entry in the map.

See also
constKeyValueBegin()

Definition at line 361 of file qcbormap.h.

◆ contains() [1/4]

bool QCborMap::contains ( const QCborValue & key) const
inline

Returns true if this map contains a key-value pair identified by key key.

See also
value(const QCborValue &), operator[](const QCborValue &), find(const QCborValue &), remove(const QCborValue &), contains(qint64), remove(QLatin1StringView), remove(const QString &)

Definition at line 317 of file qcbormap.h.

◆ contains() [2/4]

bool QCborMap::contains ( const QString & key) const
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.

See also
value(const QString &), operator[](const QString &), find(const QString &), remove(const QString &), contains(qint64), remove(QLatin1StringView), remove(const QCborValue &)

Definition at line 315 of file qcbormap.h.

◆ contains() [3/4]

bool QCborMap::contains ( qint64 key) const
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.

See also
value(qint64), operator[](qint64), find(qint64), remove(qint64), contains(QLatin1StringView), remove(const QString &), remove(const QCborValue &)

Definition at line 311 of file qcbormap.h.

◆ contains() [4/4]

bool QCborMap::contains ( QLatin1StringView key) const
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.

See also
value(QLatin1StringView), operator[](QLatin1StringView), find(QLatin1StringView), remove(QLatin1StringView), contains(qint64), remove(const QString &), remove(const QCborValue &)

Definition at line 313 of file qcbormap.h.

◆ empty()

bool QCborMap::empty ( ) const
inline

Synonym for isEmpty().

This function is provided for compatibility with generic code that uses the Standard Library API.

Returns true if this map is empty (size() == 0).

See also
isEmpty(), size()

Definition at line 344 of file qcbormap.h.

◆ end() [1/2]

iterator QCborMap::end ( )
inline

Returns a map iterator representing an element just past the last element in the map.

See also
begin(), constBegin(), find(), constFind()

Definition at line 336 of file qcbormap.h.

◆ end() [2/2]

const_iterator QCborMap::end ( ) const
inline

Returns a map iterator representing an element just past the last element in the map.

See also
begin(), constBegin(), find(), constFind()

Definition at line 338 of file qcbormap.h.

◆ erase() [1/2]

iterator QCborMap::erase ( const_iterator it)
inline

Removes the key-value pair pointed to by the map iterator it and returns a pointer to the next element, after removal.

See also
remove(), begin(), end(), insert(), extract()

Definition at line 341 of file qcbormap.h.

◆ erase() [2/2]

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.

See also
remove(), begin(), end(), insert()

Definition at line 1159 of file qcbormap.cpp.

◆ extract() [1/2]

QCborValue QCborMap::extract ( const_iterator it)
inline

Extracts a value from the map at the position indicated by iterator it and returns the value so extracted.

See also
insert(), erase(), take(), remove()

Definition at line 343 of file qcbormap.h.

◆ extract() [2/2]

QCborValue QCborMap::extract ( iterator it)

Definition at line 1179 of file qcbormap.cpp.

◆ find() [1/8]

QCborMap::iterator QCborMap::find ( const QCborValue & key)

Definition at line 981 of file qcbormap.cpp.

◆ find() [2/8]

const_iterator QCborMap::find ( const QCborValue & key) const
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.

See also
value(const QCborValue &), operator[](const QCborValue &), constFind(const QCborValue &), remove(const QCborValue &), contains(const QCborValue &), value(qint64), value(QLatin1StringView), value(const QString &)

Definition at line 382 of file qcbormap.h.

◆ find() [3/8]

QCborMap::iterator QCborMap::find ( const QString & key)

Definition at line 956 of file qcbormap.cpp.

◆ find() [4/8]

const_iterator QCborMap::find ( const QString & key) const
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.

See also
value(const QString &), operator[](const QString &), constFind(const QString &), remove(const QString &), contains(const QString &), value(qint64), value(QLatin1StringView), value(const QCborValue &)

Definition at line 381 of file qcbormap.h.

◆ find() [5/8]

QCborMap::iterator QCborMap::find ( qint64 key)

Definition at line 906 of file qcbormap.cpp.

◆ find() [6/8]

const_iterator QCborMap::find ( qint64 key) const
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.

See also
value(qint64), operator[](qint64), constFind(qint64), remove(qint64), contains(qint64), value(QLatin1StringView), value(const QString &), value(const QCborValue &)

Definition at line 379 of file qcbormap.h.

◆ find() [7/8]

QCborMap::iterator QCborMap::find ( QLatin1StringView key)

Definition at line 931 of file qcbormap.cpp.

◆ find() [8/8]

const_iterator QCborMap::find ( QLatin1StringView key) const
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.

See also
value(QLatin1StringView), operator[](QLatin1StringView), constFind(QLatin1StringView), remove(QLatin1StringView), contains(QLatin1StringView), value(qint64), value(const QString &), value(const QCborValue &)

Definition at line 380 of file qcbormap.h.

◆ fromJsonObject() [1/2]

QCborMap QCborMap::fromJsonObject ( const QJsonObject & obj)
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().

See also
toJsonObject(), toVariantMap(), QCborValue::fromJsonValue(), QCborArray::fromJsonArray()

Definition at line 987 of file qjsoncbor.cpp.

◆ fromJsonObject() [2/2]

QCborMap QCborMap::fromJsonObject ( QJsonObject && obj)
staticnoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
6.3

Definition at line 998 of file qjsoncbor.cpp.

◆ fromVariantHash()

QCborMap QCborMap::fromVariantHash ( const QVariantHash & hash)
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.

See also
toVariantHash(), fromVariantMap(), fromJsonObject(), QCborValue::fromVariant()

Definition at line 961 of file qjsoncbor.cpp.

◆ fromVariantMap()

QCborMap QCborMap::fromVariantMap ( const QVariantMap & map)
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.

See also
toVariantMap(), fromVariantHash(), fromJsonObject(), QCborValue::fromVariant()

Definition at line 937 of file qjsoncbor.cpp.

◆ insert() [1/5]

iterator QCborMap::insert ( const QCborValue & key,
const QCborValue & value )
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.

See also
erase(), remove(const QCborValue &), value(const QCborValue &), operator[](const QCborValue &), find(const QCborValue &), contains(const QCborValue &), take(const QCborValue &), extract()

Definition at line 402 of file qcbormap.h.

◆ insert() [2/5]

iterator QCborMap::insert ( const QString & key,
const QCborValue & value )
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.

See also
erase(), remove(const QString &), value(const QString &), operator[](const QString &), find(const QString &), contains(const QString &), take(const QString &), extract()

Definition at line 396 of file qcbormap.h.

◆ insert() [3/5]

iterator QCborMap::insert ( qint64 key,
const QCborValue & value )
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.

See also
erase(), remove(qint64), value(qint64), operator[](qint64), find(qint64), contains(qint64), take(qint64), extract()

Definition at line 384 of file qcbormap.h.

◆ insert() [4/5]

iterator QCborMap::insert ( QLatin1StringView key,
const QCborValue & value )
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.

See also
erase(), remove(QLatin1StringView), value(QLatin1StringView), operator[](QLatin1StringView), find(QLatin1StringView), contains(QLatin1StringView), take(QLatin1StringView), extract()

Definition at line 390 of file qcbormap.h.

◆ insert() [5/5]

iterator QCborMap::insert ( value_type v)
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}.

See also
operator[], erase(), extract()

Definition at line 408 of file qcbormap.h.

◆ isEmpty()

bool QCborMap::isEmpty ( ) const
inline

Returns true if this map is empty (that is, size() is 0).

See also
size(), clear()

Definition at line 262 of file qcbormap.h.

◆ keys()

QList< QCborValue > QCborMap::keys ( ) const

Returns a list of all keys in this map.

See also
QMap::keys(), QHash::keys()

Definition at line 383 of file qcbormap.cpp.

◆ keyValueBegin() [1/2]

key_value_iterator QCborMap::keyValueBegin ( )
inline
Since
6.10

Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first entry in the map.

See also
keyValueEnd()

Definition at line 353 of file qcbormap.h.

◆ keyValueBegin() [2/2]

const_key_value_iterator QCborMap::keyValueBegin ( ) const
inline
Since
6.10

Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first entry in the map.

See also
keyValueEnd()

Definition at line 355 of file qcbormap.h.

◆ keyValueEnd() [1/2]

key_value_iterator QCborMap::keyValueEnd ( )
inline
Since
6.10

Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary entry after the last entry in the map.

See also
keyValueBegin()

Definition at line 354 of file qcbormap.h.

◆ keyValueEnd() [2/2]

const_key_value_iterator QCborMap::keyValueEnd ( ) const
inline
Since
6.10

Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary entry after the last entry in the map.

See also
keyValueBegin()

Definition at line 360 of file qcbormap.h.

◆ operator=()

QCborMap & QCborMap::operator= ( const QCborMap & other)
noexcept

Replaces the contents of this object with a copy of other, then returns a reference to this object.

Since
6.10

Move-assignment operator.

The moved-from object other is placed in a valid, but unspecified state.

Definition at line 316 of file qcbormap.cpp.

◆ operator[]() [1/9]

template<size_t N>
QT_ASCII_CAST_WARN const QCborValue QCborMap::operator[] ( const char(&) key[N]) const
inline

Definition at line 287 of file qcbormap.h.

◆ operator[]() [2/9]

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.

See also
value(const QCborValue &), find(const QCborValue &), contains(const QCborValue &), remove(const QCborValue &), operator[](qint64), operator[](QLatin1StringView), operator[](const QString &)

Definition at line 874 of file qcbormap.cpp.

◆ operator[]() [3/9]

const QCborValue QCborMap::operator[] ( const QCborValue & key) const
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.

See also
value(const QCborValue &), find(const QCborValue &), constFind(const QCborValue &), remove(const QCborValue &), contains(const QCborValue &) operator[](qint64), operator[](QLatin1StringView), operator[](const QCborOperator[] &)

Definition at line 284 of file qcbormap.h.

◆ operator[]() [4/9]

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.

See also
value(const QString &), find(const QString &), contains(const QString &), remove(const QString &), operator[](qint64), operator[](QLatin1StringView), operator[](const QCborValue &)

Definition at line 754 of file qcbormap.cpp.

◆ operator[]() [5/9]

const QCborValue QCborMap::operator[] ( const QString & key) const
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.

See also
value(const QString &), find(const QString &), constFind(const QString &), remove(const QString &), contains(const QString &) operator[](qint64), operator[](QLatin1StringView), operator[](const QCborOperator[] &)

Definition at line 282 of file qcbormap.h.

◆ operator[]() [6/9]

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.

See also
value(qint64), find(qint64), contains(qint64), remove(qint64), operator[](QLatin1StringView), operator[](const QString &), operator[](const QCborValue &)

Definition at line 506 of file qcbormap.cpp.

◆ operator[]() [7/9]

const QCborValue QCborMap::operator[] ( qint64 key) const
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.

See also
value(qint64), find(qint64), constFind(qint64), remove(qint64), contains(qint64) operator[](QLatin1StringView), operator[](const QString &), operator[](const QCborOperator[] &)

Definition at line 278 of file qcbormap.h.

◆ operator[]() [8/9]

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.

See also
value(QLatin1StringView), find(QLatin1StringView), contains(QLatin1StringView), remove(QLatin1StringView), operator[](qint64), operator[](const QString &), operator[](const QCborValue &)

Definition at line 630 of file qcbormap.cpp.

◆ operator[]() [9/9]

const QCborValue QCborMap::operator[] ( QLatin1StringView key) const
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.

See also
value(QLatin1StringView), find(QLatin1StringView), constFind(QLatin1StringView), remove(QLatin1StringView), contains(QLatin1StringView) operator[](qint64), operator[](const QString &), operator[](const QCborOperator[] &)

Definition at line 280 of file qcbormap.h.

◆ remove() [1/4]

void QCborMap::remove ( const QCborValue & key)
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.

See also
value(const QCborValue &), operator[](const QCborValue &), find(const QCborValue &), contains(const QCborValue &) remove(qint64), remove(QLatin1StringView), remove(const QString &)

Definition at line 309 of file qcbormap.h.

◆ remove() [2/4]

void QCborMap::remove ( const QString & key)
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.

See also
value(const QString &), operator[](const QString &), find(const QString &), contains(const QString &) remove(qint64), remove(QLatin1StringView), remove(const QCborValue &)

Definition at line 307 of file qcbormap.h.

◆ remove() [3/4]

void QCborMap::remove ( qint64 key)
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.

See also
value(qint64), operator[](qint64), find(qint64), contains(qint64) remove(QLatin1StringView), remove(const QString &), remove(const QCborValue &)

Definition at line 303 of file qcbormap.h.

◆ remove() [4/4]

void QCborMap::remove ( QLatin1StringView key)
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.

See also
value(QLatin1StringView), operator[](QLatin1StringView), find(QLatin1StringView), contains(QLatin1StringView), remove(qint64), remove(const QString &), remove(const QCborValue &)

Definition at line 305 of file qcbormap.h.

◆ size()

qsizetype QCborMap::size ( ) const
noexcept

Returns the number of elements in this map.

See also
isEmpty()

Definition at line 363 of file qcbormap.cpp.

◆ swap()

void QCborMap::swap ( QCborMap & other)
inlinenoexcept

\memberswap{map}

Definition at line 254 of file qcbormap.h.

◆ take() [1/4]

QCborValue QCborMap::take ( const QCborValue & key)
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.

See also
value(const QCborValue &), operator[](const QCborValue &), find(const QCborValue &), contains(const QCborValue &), take(QLatin1StringView), take(const QString &), take(qint64), insert()

Definition at line 301 of file qcbormap.h.

◆ take() [2/4]

QCborValue QCborMap::take ( const QString & key)
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.

See also
value(const QString &), operator[](const QString &), find(const QString &), contains(const QString &), take(QLatin1StringView), take(qint64), take(const QCborValue &), insert()

Definition at line 299 of file qcbormap.h.

◆ take() [3/4]

QCborValue QCborMap::take ( qint64 key)
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.

See also
value(qint64), operator[](qint64), find(qint64), contains(qint64), take(QLatin1StringView), take(const QString &), take(const QCborValue &), insert()

Definition at line 295 of file qcbormap.h.

◆ take() [4/4]

QCborValue QCborMap::take ( QLatin1StringView key)
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.

See also
value(QLatin1StringView), operator[](QLatin1StringView), find(QLatin1StringView), contains(QLatin1StringView), take(qint64), take(const QString &), take(const QCborValue &), insert()

Definition at line 297 of file qcbormap.h.

◆ toCborValue()

QCborValue QCborMap::toCborValue ( ) const
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().

See also
QCborValue::QCborValue(const QCborMap &)

Definition at line 259 of file qcbormap.h.

◆ toJsonObject()

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 469 of file qjsoncbor.cpp.

◆ toVariantHash()

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.

See also
fromVariantHash(), toVariantMap(), toJsonObject(), QCborValue::toVariant(), QCborArray::toVariantList()

Definition at line 919 of file qjsoncbor.cpp.

◆ toVariantMap()

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.

See also
fromVariantMap(), toVariantHash(), toJsonObject(), QCborValue::toVariant(), QCborArray::toVariantList()

Definition at line 895 of file qjsoncbor.cpp.

◆ value() [1/5]

template<size_t N>
QT_ASCII_CAST_WARN const QCborValue QCborMap::value ( const char(&) key[N]) const
inline

Definition at line 275 of file qcbormap.h.

◆ value() [2/5]

QCborValue QCborMap::value ( const QCborValue & key) const
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.

See also
operator[](const QCborValue &), find(const QCborValue &), constFind(const QCborValue &), remove(const QCborValue &), contains(const QCborValue &) value(qint64), value(QLatin1StringView), value(const QString &)

Definition at line 272 of file qcbormap.h.

◆ value() [3/5]

QCborValue QCborMap::value ( const QString & key) const
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.

See also
operator[](const QString &), find(const QString &), constFind(const QString &), remove(const QString &), contains(const QString &) value(qint64), value(QLatin1StringView), value(const QCborValue &)

Definition at line 270 of file qcbormap.h.

◆ value() [4/5]

QCborValue QCborMap::value ( qint64 key) const
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.

See also
operator[](qint64), find(qint64), constFind(qint64), remove(qint64), contains(qint64) value(QLatin1StringView), value(const QString &), value(const QCborValue &)

Definition at line 266 of file qcbormap.h.

◆ value() [5/5]

QCborValue QCborMap::value ( QLatin1StringView key) const
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.

See also
operator[](QLatin1StringView), find(QLatin1StringView), constFind(QLatin1StringView), remove(QLatin1StringView), contains(QLatin1StringView) value(qint64), value(const QString &), value(const QCborValue &)

Definition at line 268 of file qcbormap.h.

◆ comparesEqual [1/3]

Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool comparesEqual ( const QCborMap & lhs,
const QCborMap & rhs )
friend

Definition at line 1524 of file qcborvalue.cpp.

References QtCbor::ForEquality.

◆ comparesEqual [2/3]

bool comparesEqual ( const QCborMap & lhs,
const QCborValue & rhs )
friend

Definition at line 439 of file qcbormap.h.

◆ comparesEqual [3/3]

bool comparesEqual ( const QCborMap & lhs,
const QCborValueConstRef & rhs )
friend

Definition at line 455 of file qcbormap.h.

◆ compareThreeWay [1/3]

Qt::strong_ordering compareThreeWay ( const QCborMap & lhs,
const QCborMap & rhs )
friend

Definition at line 427 of file qcbormap.h.

◆ compareThreeWay [2/3]

Qt::strong_ordering compareThreeWay ( const QCborMap & lhs,
const QCborValue & rhs )
friend

Definition at line 444 of file qcbormap.h.

◆ compareThreeWay [3/3]

Qt::strong_ordering compareThreeWay ( const QCborMap & lhs,
const QCborValueConstRef & rhs )
friend

Definition at line 460 of file qcbormap.h.

◆ QCborContainerPrivate

friend class QCborContainerPrivate
friend

Definition at line 419 of file qcbormap.h.

◆ QCborValue

friend class QCborValue
friend

Definition at line 420 of file qcbormap.h.

◆ QCborValueRef

friend class QCborValueRef
friend

Definition at line 421 of file qcbormap.h.

◆ QJsonPrivate::Variant

friend class QJsonPrivate::Variant
friend

Definition at line 422 of file qcbormap.h.


The documentation for this class was generated from the following files: