QCborMap 类

QCborMap 类用于保持以 CBOR 表示的关联容器。 更多...

头: #include <QCborMap>
CMake: find_package(Qt6 COMPONENTS Core REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core
Since: Qt 5.12

注意: 此类的所有函数 可重入 .

公共类型

class ConstIterator
class Iterator
  const_iterator
  iterator
  key_type
  mapped_type
  size_type
  value_type

公共函数

  QCborMap (std::initializer_list<value_type> args )
  QCborMap (const QCborMap & other )
  QCborMap ()
QCborMap & operator= (const QCborMap & other )
  ~QCborMap ()
QCborMap::iterator begin ()
QCborMap::const_iterator begin () const
QCborMap::const_iterator cbegin () const
QCborMap::const_iterator cend () const
void clear ()
int compare (const QCborMap & other ) const
QCborMap::const_iterator constBegin () const
QCborMap::const_iterator constEnd () const
QCborMap::const_iterator constFind (qint64 key ) const
QCborMap::const_iterator constFind (QLatin1String key ) const
QCborMap::const_iterator constFind (const QString & key ) const
QCborMap::const_iterator constFind (const QCborValue & key ) const
bool contains (qint64 key ) const
bool contains (QLatin1String key ) const
bool contains (const QString & key ) const
bool contains (const QCborValue & key ) const
bool empty () const
QCborMap::iterator end ()
QCborMap::const_iterator end () const
QCborMap::iterator erase (QCborMap::const_iterator it )
QCborMap::iterator erase (QCborMap::iterator it )
QCborValue extract (QCborMap::iterator it )
QCborValue extract (QCborMap::const_iterator it )
QCborMap::iterator find (qint64 key )
QCborMap::iterator find (QLatin1String key )
QCborMap::iterator find (const QString & key )
QCborMap::iterator find (const QCborValue & key )
QCborMap::const_iterator find (qint64 key ) const
QCborMap::const_iterator find (QLatin1String key ) const
QCborMap::const_iterator find (const QString & key ) const
QCborMap::const_iterator find (const QCborValue & key ) const
QCborMap::iterator insert (qint64 key , const QCborValue & value )
QCborMap::iterator insert (QLatin1String key , const QCborValue & value )
QCborMap::iterator insert (const QString & key , const QCborValue & value )
QCborMap::iterator insert (const QCborValue & key , const QCborValue & value )
QCborMap::iterator insert (QCborMap::value_type v )
bool isEmpty () const
QList<QCborValue> keys () const
void remove (qint64 key )
void remove (QLatin1String key )
void remove (const QString & key )
void remove (const QCborValue & key )
qsizetype size () const
void swap (QCborMap & other )
QCborValue take (qint64 key )
QCborValue take (QLatin1String key )
QCborValue take (const QString & key )
QCborValue take (const QCborValue & key )
QCborValue toCborValue () const
QJsonObject toJsonObject () const
QVariantHash toVariantHash () const
QVariantMap toVariantMap () const
QCborValue value (qint64 key ) const
QCborValue value (QLatin1String key ) const
QCborValue value (const QString & key ) const
QCborValue value (const QCborValue & key ) const
bool operator!= (const QCborMap & other ) const
bool operator< (const QCborMap & other ) const
bool operator== (const QCborMap & other ) const
const QCborValue operator[] (qint64 key ) const
const QCborValue operator[] (QLatin1String key ) const
const QCborValue operator[] (const QString & key ) const
const QCborValue operator[] (const QCborValue & key ) const
QCborValueRef operator[] (qint64 key )
QCborValueRef operator[] (QLatin1String key )
QCborValueRef operator[] (const QString & key )
QCborValueRef operator[] (const QCborValue & key )

静态公共成员

QCborMap fromJsonObject (const QJsonObject & obj )
QCborMap fromVariantHash (const QVariantHash & hash )
QCborMap fromVariantMap (const QVariantMap & map )

详细描述

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 CoAP protocol .

Unlike JSON and 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.

另请参阅 QCborArray , QCborValue , QJsonDocument ,和 QVariantMap .

成员类型文档编制

QCborMap:: const_iterator

同义词 QCborMap::ConstIterator

QCborMap:: iterator

同义词 QCborMap::Iterator .

QCborMap:: key_type

The key type for this map. Since QCborMap keys can be any CBOR type, this is a QCborValue .

QCborMap:: mapped_type

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

QCborMap:: size_type

The type that QCborMap uses for sizes.

QCborMap:: value_type

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

成员函数文档编制

QCborValue QCborMap:: extract ( QCborMap::const_iterator it )

QCborValue QCborMap:: extract ( QCborMap::iterator it )

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

另请参阅 insert (), erase (), take (),和 remove ().

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

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

value(qint64), value( QLatin1String ), value(const QString &)

另请参阅 value (const QCborValue &), operator[] (const QCborValue &), constFind (const QCborValue &), remove (const QCborValue &), and contains (const QCborValue &).

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

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

value(qint64), value( QLatin1String ), value(const QCborValue &)

另请参阅 value (const QString &), operator[] (const QString &), constFind (const QString &), remove (const QString &), and contains (const QString &).

QCborMap::iterator QCborMap:: find ( QLatin1String key )

QCborMap::const_iterator QCborMap:: find ( QLatin1String 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 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.

value(qint64), value(const QString &), value(const QCborValue &)

另请参阅 value (QLatin1String), operator[] (QLatin1String), constFind (QLatin1String), remove (QLatin1String), and contains (QLatin1String).

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

QCborMap::const_iterator QCborMap:: find ( 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 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.

value( QLatin1String ), value(const QString &), value(const QCborValue &)

另请参阅 value (qint64), operator[] (qint64), constFind (qint64), remove (qint64), and contains (qint64).

QCborMap:: 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 map = {
    {0, "Hello"},
    {1, "World"},
    {"foo", nullptr},
    {"bar", QCborArray{0, 1, 2, 3, 4}}
};
					

QCborMap:: QCborMap (const QCborMap & other )

Creates a QCborMap object that is a copy of other .

QCborMap:: QCborMap ()

Constructs an empty CBOR Map object.

另请参阅 isEmpty ().

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

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

QCborMap:: ~QCborMap ()

销毁此 QCborMap object and frees any associated resources it owns.

QCborMap::iterator QCborMap:: begin ()

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 ().

另请参阅 constBegin () 和 end ().

QCborMap::const_iterator QCborMap:: begin () const

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 ().

另请参阅 begin () 和 constEnd ().

QCborMap::const_iterator QCborMap:: cbegin () const

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 ().

另请参阅 begin () 和 constEnd ().

QCborMap::const_iterator QCborMap:: cend () const

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

另请参阅 begin (), constBegin (), find (),和 constFind ().

void QCborMap:: clear ()

Empties this map.

另请参阅 isEmpty ().

int QCborMap:: compare (const QCborMap & other ) const

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 ().

另请参阅 QCborValue::compare (), QCborArray::compare (),和 operator== ().

QCborMap::const_iterator QCborMap:: constBegin () const

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 ().

另请参阅 begin () 和 constEnd ().

QCborMap::const_iterator QCborMap:: constEnd () const

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

另请参阅 begin (), constBegin (), find (),和 constFind ().

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.

value( QLatin1String ), value(const QString &), value(const QCborValue &)

另请参阅 value (qint64), operator[] (qint64), find (qint64), remove (qint64), and contains (qint64).

QCborMap::const_iterator QCborMap:: constFind ( QLatin1String 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 ().

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.

value(qint64), value(const QString &), value(const QCborValue &)

另请参阅 value (QLatin1String), operator[] (QLatin1String), find (QLatin1String), remove (QLatin1String), and contains (QLatin1String).

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

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.

value(qint64), value( QLatin1String ), value(const QCborValue &)

另请参阅 value (const QString &), operator[] (const QString &), find (const QString &), remove (const QString &), and contains (const QString &).

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

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.

另请参阅 value (const QCborValue &), operator[] (const QCborValue &), find (const QCborValue &), remove (const QCborValue &), contains (const QCborValue &), value (qint64), value (QLatin1String), and value (const QString &).

bool QCborMap:: contains ( qint64 key ) const

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.

另请参阅 value (qint64), operator[] (qint64), find (qint64), remove (qint64), contains (QLatin1String), remove (const QString &), and remove (const QCborValue &).

bool QCborMap:: contains ( QLatin1String key ) const

这是重载函数。

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

另请参阅 value (QLatin1String), operator[] (QLatin1String), find (QLatin1String), remove (QLatin1String), contains (qint64), remove (const QString &), and remove (const QCborValue &).

bool QCborMap:: contains (const QString & key ) const

这是重载函数。

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

另请参阅 value (const QString &), operator[] (const QString &), find (const QString &), remove (const QString &), contains (qint64), remove (QLatin1String), and remove (const QCborValue &).

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

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

另请参阅 value (const QCborValue &), operator[] (const QCborValue &), find (const QCborValue &), remove (const QCborValue &), contains (qint64), remove (QLatin1String), and remove (const QString &).

bool QCborMap:: empty () const

同义词 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).

另请参阅 isEmpty () 和 size ().

QCborMap::iterator QCborMap:: end ()

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

另请参阅 begin (), constBegin (), find (),和 constFind ().

QCborMap::const_iterator QCborMap:: end () const

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

另请参阅 begin (), constBegin (), find (),和 constFind ().

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

另请参阅 remove (), begin (), end (), insert (),和 extract ().

QCborMap::iterator QCborMap:: erase ( QCborMap::iterator it )

这是重载函数。

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

另请参阅 remove (), begin (), end (),和 insert ().

[static] QCborMap QCborMap:: fromJsonObject (const QJsonObject & obj )

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 ().

另请参阅 toJsonObject (), toVariantMap (), QCborValue::fromJsonValue (),和 QCborArray::fromJsonArray ().

[static] QCborMap QCborMap:: fromVariantHash (const QVariantHash & hash )

Converts all the items in hash to CBOR using QCborValue::fromVariant () and returns the map composed of those elements.

Conversion from QVariant is not completely lossless. Please see the documentation in QCborValue::fromVariant () 了解更多信息。

另请参阅 toVariantHash (), fromVariantMap (), fromJsonObject (),和 QCborValue::fromVariant ().

[static] QCborMap QCborMap:: fromVariantMap (const QVariantMap & map )

Converts all the items in map to CBOR using QCborValue::fromVariant () and returns the map composed of those elements.

Conversion from QVariant is not completely lossless. Please see the documentation in QCborValue::fromVariant () 了解更多信息。

另请参阅 toVariantMap (), fromVariantHash (), fromJsonObject (),和 QCborValue::fromVariant ().

QCborMap::iterator QCborMap:: insert ( qint64 key , const QCborValue & value )

这是重载函数。

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 .

另请参阅 erase (), remove (qint64), value (qint64), operator[] (qint64), find (qint64), contains (qint64), take (qint64), and extract ().

QCborMap::iterator QCborMap:: insert ( QLatin1String key , const QCborValue & value )

这是重载函数。

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 .

另请参阅 erase (), remove (QLatin1String), value (QLatin1String), operator[] (QLatin1String), find (QLatin1String), contains (QLatin1String), take (QLatin1String), and extract ().

QCborMap::iterator QCborMap:: insert (const QString & key , const QCborValue & value )

这是重载函数。

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 .

另请参阅 erase (), remove (const QString &), value (const QString &), operator[] (const QString &), find (const QString &), contains (const QString &), take (const QString &), and extract ().

QCborMap::iterator QCborMap:: insert (const QCborValue & key , const QCborValue & value )

这是重载函数。

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 .

另请参阅 erase (), remove (const QCborValue &), value (const QCborValue &), operator[] (const QCborValue &), find (const QCborValue &), contains (const QCborValue &), take (const QCborValue &), and extract ().

QCborMap::iterator QCborMap:: insert ( QCborMap::value_type v )

这是重载函数。

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 .

另请参阅 operator[] , erase (),和 extract ().

bool QCborMap:: isEmpty () const

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

另请参阅 size () 和 clear ().

QList < QCborValue > QCborMap:: keys () const

Returns a list of all keys in this map.

另请参阅 QMap::keys () 和 QHash::keys ().

void QCborMap:: remove ( qint64 key )

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.

remove( QLatin1String ), remove(const QString &), remove(const QCborValue &)

另请参阅 value (qint64), operator[] (qint64), find (qint64), and contains (qint64).

void QCborMap:: remove ( QLatin1String key )

这是重载函数。

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.

remove(qint64), remove(const QString &), remove(const QCborValue &)

另请参阅 value (QLatin1String), operator[] (QLatin1String), find (QLatin1String), and contains (QLatin1String).

void QCborMap:: remove (const QString & key )

这是重载函数。

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.

remove(qint64), remove( QLatin1String ), remove(const QCborValue &)

另请参阅 value (const QString &), operator[] (const QString &), find (const QString &), and contains (const QString &).

void QCborMap:: remove (const QCborValue & key )

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.

remove(qint64), remove( QLatin1String ), remove(const QString &)

另请参阅 value (const QCborValue &), operator[] (const QCborValue &), find (const QCborValue &), and contains (const QCborValue &).

qsizetype QCborMap:: size () const

Returns the number of elements in this map.

另请参阅 isEmpty ().

void QCborMap:: swap ( QCborMap & other )

Swaps the contents of this map and other .

QCborValue QCborMap:: take ( qint64 key )

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.

另请参阅 value (qint64), operator[] (qint64), find (qint64), contains (qint64), take (QLatin1String), take (const QString &), take (const QCborValue &), and insert ().

QCborValue QCborMap:: take ( QLatin1String key )

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.

另请参阅 value (QLatin1String), operator[] (QLatin1String), find (QLatin1String), contains (QLatin1String), take (qint64), take (const QString &), take (const QCborValue &), and insert ().

QCborValue QCborMap:: take (const QString & key )

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.

另请参阅 value (const QString &), operator[] (const QString &), find (const QString &), contains (const QString &), take (QLatin1String), take (qint64), take (const QCborValue &), and insert ().

QCborValue QCborMap:: take (const QCborValue & key )

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.

另请参阅 value (const QCborValue &), operator[] (const QCborValue &), find (const QCborValue &), contains (const QCborValue &), take (QLatin1String), take (const QString &), take (qint64), and insert ().

QCborValue QCborMap:: toCborValue () const

Explicitly constructs a QCborValue object that represents this map. This function is usually not necessary since QCborValue has a constructor for QCborMap , so the conversion is implicit.

转换 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 ().

另请参阅 QCborValue::QCborValue (const QCborMap &).

QJsonObject QCborMap:: toJsonObject () const

Recursively converts every 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 ().

Map key conversion to string

JSON objects are defined as having string keys, unlike CBOR, so the conversion of a QCborMap to QJsonObject will imply a step of "stringification" of the key values. The conversion will use the special handling of tags and extended types from above and will also convert the rest of the types as follows:

类型 Transformation
Bool "true" and "false"
Null "null"
Undefined "undefined"
整数 The decimal string form of the number
Double The decimal string form of the number
Byte array Unless tagged differently (see above), encoded as Base64url
数组 Replaced by the compact form of its Diagnostic notation
Map Replaced by the compact form of its Diagnostic notation
Tags and extended types Tag number is dropped and the tagged value is converted to string

另请参阅 fromJsonObject (), QCborValue::toJsonValue (), QCborArray::toJsonArray (),和 toVariantMap ().

QVariantHash QCborMap:: toVariantHash () const

Converts the CBOR values to QVariant 使用 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 () 了解细节。

In addition, the conversion to QVariant is not completely lossless. Please see the documentation in QCborValue::toVariant () 了解更多信息。

另请参阅 fromVariantHash (), toVariantMap (), toJsonObject (), QCborValue::toVariant (),和 QCborArray::toVariantList ().

QVariantMap QCborMap:: toVariantMap () const

Converts the CBOR values to QVariant 使用 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 () 了解细节。

In addition, the conversion to QVariant is not completely lossless. Please see the documentation in QCborValue::toVariant () 了解更多信息。

另请参阅 fromVariantMap (), toVariantHash (), toJsonObject (), QCborValue::toVariant (),和 QCborArray::toVariantList ().

QCborValue QCborMap:: value ( qint64 key ) const

返回 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 ,此函数返回 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.

value( QLatin1String ), value(const QString &), value(const QCborValue &)

另请参阅 operator[] (qint64), find (qint64), constFind (qint64), remove (qint64), and contains (qint64).

QCborValue QCborMap:: value ( QLatin1String key ) const

这是重载函数。

返回 QCborValue element in this map that corresponds to key key , if there is one.

If the map does not contain key key ,此函数返回 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.

value(qint64), value(const QString &), value(const QCborValue &)

另请参阅 operator[] (QLatin1String), find (QLatin1String), constFind (QLatin1String), remove (QLatin1String), and contains (QLatin1String).

QCborValue QCborMap:: value (const QString & key ) const

这是重载函数。

返回 QCborValue element in this map that corresponds to key key , if there is one.

If the map does not contain key key ,此函数返回 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.

value(qint64), value( QLatin1String ), value(const QCborValue &)

另请参阅 operator[] (const QString &), find (const QString &), constFind (const QString &), remove (const QString &), and contains (const QString &).

QCborValue QCborMap:: value (const QCborValue & key ) const

返回 QCborValue element in this map that corresponds to key key , if there is one.

If the map does not contain key key ,此函数返回 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.

value(qint64), value( QLatin1String ), value(const QString &)

另请参阅 operator[] (const QCborValue &), find (const QCborValue &), constFind (const QCborValue &), remove (const QCborValue &), and contains (const QCborValue &).

bool QCborMap:: operator!= (const QCborMap & other ) const

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 ().

另请参阅 compare (), QCborValue::operator== (), QCborMap::operator== (), operator== (),和 operator< ().

bool QCborMap:: 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.

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 ().

另请参阅 compare (), QCborValue::operator== (), QCborMap::operator== (), operator== (),和 operator!= ().

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

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 ().

另请参阅 compare (), QCborValue::operator== (), QCborMap::operator==(), operator!= (),和 operator< ().

const QCborValue QCborMap:: operator[] ( qint64 key ) const

返回 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 ,此函数返回 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.

operator[]( QLatin1String ), operator[](const QString &), operator[](const QCborOperator[] &)

另请参阅 value (qint64), find (qint64), constFind (qint64), remove (qint64), and contains (qint64).

const QCborValue QCborMap:: operator[] ( QLatin1String key ) const

这是重载函数。

返回 QCborValue element in this map that corresponds to key key , if there is one.

If the map does not contain key key ,此函数返回 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.

operator[](qint64), operator[](const QString &), operator[](const QCborOperator[] &)

另请参阅 value (QLatin1String), find (QLatin1String), constFind (QLatin1String), remove (QLatin1String), and contains (QLatin1String).

const QCborValue QCborMap:: operator[] (const QString & key ) const

这是重载函数。

返回 QCborValue element in this map that corresponds to key key , if there is one.

If the map does not contain key key ,此函数返回 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.

operator[](qint64), operator[]( QLatin1String ), operator[](const QCborOperator[] &)

另请参阅 value (const QString &), find (const QString &), constFind (const QString &), remove (const QString &), and contains (const QString &).

const QCborValue QCborMap:: operator[] (const QCborValue & key ) const

返回 QCborValue element in this map that corresponds to key key , if there is one.

If the map does not contain key key ,此函数返回 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.

operator[](qint64), operator[]( QLatin1String ), operator[](const QCborOperator[] &)

另请参阅 value (const QCborValue &), find (const QCborValue &), constFind (const QCborValue &), remove (const QCborValue &), and contains (const QCborValue &).

QCborValueRef QCborMap:: operator[] ( qint64 key )

返回 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 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.

另请参阅 value (qint64), find (qint64), contains (qint64), remove (qint64), operator[] (QLatin1String), operator[] (const QString &), and operator[] (const QCborValue &).

QCborValueRef QCborMap:: operator[] ( QLatin1String key )

这是重载函数。

返回 QCborValueRef to the value in this map that corresponds to key key .

QCborValueRef has the exact same API as 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.

另请参阅 value (QLatin1String), find (QLatin1String), contains (QLatin1String), remove (QLatin1String), operator[] (qint64), operator[] (const QString &), and operator[] (const QCborValue &).

QCborValueRef QCborMap:: operator[] (const QString & key )

这是重载函数。

返回 QCborValueRef to the value in this map that corresponds to key key .

QCborValueRef has the exact same API as 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.

另请参阅 value (const QString &), find (const QString &), contains (const QString &), remove (const QString &), operator[] (qint64), operator[] (QLatin1String), and operator[] (const QCborValue &).

QCborValueRef QCborMap:: operator[] (const QCborValue & key )

这是重载函数。

返回 QCborValueRef to the value in this map that corresponds to key key .

QCborValueRef has the exact same API as 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.

另请参阅 value (const QCborValue &), find (const QCborValue &), contains (const QCborValue &), remove (const QCborValue &), operator[] (qint64), operator[] (QLatin1String), and operator[] (const QString &).