![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtCore\reentrant More...
#include <qcborarray.h>
Classes | |
class | ConstIterator |
\inmodule QtCore More... | |
class | Iterator |
\inmodule QtCore More... | |
Public Types | |
typedef qsizetype | size_type |
A typedef to qsizetype. | |
typedef QCborValue | value_type |
The type of values that can be held in a QCborArray: that is, QCborValue. | |
typedef value_type * | pointer |
A typedef to {QCborValue *}, for compatibility with generic algorithms. | |
typedef const value_type * | const_pointer |
A typedef to {const QCborValue *}, for compatibility with generic algorithms. | |
typedef QCborValue & | reference |
A typedef to {QCborValue &}, for compatibility with generic algorithms. | |
typedef const QCborValue & | const_reference |
A typedef to {const QCborValue &}, for compatibility with generic algorithms. | |
typedef qsizetype | difference_type |
A typedef to qsizetype. | |
typedef Iterator | iterator |
A synonym to QCborArray::Iterator. | |
typedef ConstIterator | const_iterator |
A synonym to QCborArray::ConstIterator. | |
Public Member Functions | |
QCborArray () noexcept | |
Constructs an empty QCborArray. | |
QCborArray (const QCborArray &other) noexcept | |
Copies the contents of other into this object. | |
QCborArray & | operator= (const QCborArray &other) noexcept |
Replaces the contents of this array with that found in other, then returns a reference to this object. | |
QCborArray (std::initializer_list< QCborValue > args) | |
Initializes this QCborArray from the C++ brace-enclosed list found in args, as in the following example: | |
~QCborArray () | |
Destroys this QCborArray and frees any associated resources. | |
void | swap (QCborArray &other) noexcept |
\memberswap{array} | |
QCborValue | toCborValue () const |
Explicitly construcuts a \l QCborValue object that represents this array. | |
qsizetype | size () const noexcept |
Returns the size of this array. | |
bool | isEmpty () const |
Returns true if this QCborArray is empty (that is if size() is 0). | |
void | clear () |
Empties this array. | |
QCborValue | at (qsizetype i) const |
Returns the QCborValue element at position i in the array. | |
QCborValue | first () const |
Returns the first QCborValue of this array. | |
QCborValue | last () const |
Returns the last QCborValue of this array. | |
const QCborValue | operator[] (qsizetype i) const |
Returns the QCborValue element at position i in the array. | |
QCborValueRef | first () |
Returns a reference to the first QCborValue of this array. | |
QCborValueRef | last () |
Returns a reference to the last QCborValue of this array. | |
QCborValueRef | operator[] (qsizetype i) |
Returns a reference to the QCborValue element at position i in the array. | |
void | insert (qsizetype i, const QCborValue &value) |
void | insert (qsizetype i, QCborValue &&value) |
Inserts value into the array at position i in this array. | |
void | prepend (const QCborValue &value) |
void | prepend (QCborValue &&value) |
Prepends value into the array before any other elements it may already contain. | |
void | append (const QCborValue &value) |
void | append (QCborValue &&value) |
Appends value into the array after all other elements it may already contain. | |
QCborValue | extract (ConstIterator it) |
Extracts a value from the array at the position indicated by iterator it and returns the value so extracted. | |
QCborValue | extract (Iterator it) |
void | removeAt (qsizetype i) |
Removes the item at position i from the array. | |
QCborValue | takeAt (qsizetype i) |
Removes the item at position i from the array and returns it. | |
void | removeFirst () |
Removes the first item in the array, making the second element become the first. | |
void | removeLast () |
Removes the last item in the array. | |
QCborValue | takeFirst () |
Removes the first item in the array and returns it, making the second element become the first. | |
QCborValue | takeLast () |
Removes the last item in the array and returns it. | |
bool | contains (const QCborValue &value) const |
Returns true if this array contains an element that is equal to value. | |
int | compare (const QCborArray &other) const noexcept Q_DECL_PURE_FUNCTION |
Compares this array and other, comparing each element in sequence, and returns an integer that indicates whether this array should be sorted before (if the result is negative) or after other (if the result is positive). | |
iterator | begin () |
Returns an array iterator pointing to the first item in this array. | |
const_iterator | constBegin () const |
Returns an array iterator pointing to the first item in this array. | |
const_iterator | begin () const |
Returns an array iterator pointing to the first item in this array. | |
const_iterator | cbegin () const |
Returns an array iterator pointing to the first item in this array. | |
iterator | end () |
Returns an array iterator pointing to just after the last element in this array. | |
const_iterator | constEnd () const |
Returns an array iterator pointing to just after the last element in this array. | |
const_iterator | end () const |
Returns an array iterator pointing to just after the last element in this array. | |
const_iterator | cend () const |
Returns an array iterator pointing to just after the last element in this array. | |
iterator | insert (iterator before, const QCborValue &value) |
iterator | insert (const_iterator before, 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 value into this array before element before and returns an array iterator pointing to the just-inserted element. | |
iterator | erase (iterator it) |
iterator | erase (const_iterator it) |
Removes the element pointed to by the array iterator it from this array, then returns an iterator to the next element (the one that took the same position in the array that it used to occupy). | |
void | push_back (const QCborValue &t) |
Synonym for append(). | |
void | push_front (const QCborValue &t) |
Synonym for prepend(). | |
void | pop_front () |
Synonym for removeFirst(). | |
void | pop_back () |
Synonym for removeLast(). | |
bool | empty () const |
Synonym for isEmpty(). | |
QCborArray | operator+ (const QCborValue &v) const |
Returns a new QCborArray containing the same elements as this array, plus v appended as the last element. | |
QCborArray & | operator+= (const QCborValue &v) |
Appends v to this array and returns a reference to this array. | |
QCborArray & | operator<< (const QCborValue &v) |
Appends v to this array and returns a reference to this array. | |
QVariantList | toVariantList () const |
Recursively converts each \l QCborValue in this array using QCborValue::toVariant() and returns the QVariantList composed of the converted items. | |
QJsonArray | toJsonArray () const |
Recursively converts every \l QCborValue element in this array to JSON using QCborValue::toJsonValue() and returns the corresponding QJsonArray composed of those elements. | |
Static Public Member Functions | |
static QCborArray | fromStringList (const QStringList &list) |
Returns a QCborArray containing all the strings found in the list list. | |
static QCborArray | fromVariantList (const QVariantList &list) |
Converts all the items in the list to CBOR using QCborValue::fromVariant() and returns the array composed of those elements. | |
static QCborArray | fromJsonArray (const QJsonArray &array) |
Converts all JSON items found in the array array to CBOR using QCborValue::fromJson(), and returns the CBOR array composed of those elements. | |
static QCborArray | fromJsonArray (QJsonArray &&array) 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 | QJsonPrivate::Variant |
Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool | comparesEqual (const QCborArray &lhs, const QCborArray &rhs) |
Qt::strong_ordering | compareThreeWay (const QCborArray &lhs, const QCborArray &rhs) noexcept |
bool | comparesEqual (const QCborArray &lhs, const QCborValue &rhs) noexcept |
Qt::strong_ordering | compareThreeWay (const QCborArray &lhs, const QCborValue &rhs) noexcept |
bool | comparesEqual (const QCborArray &lhs, const QCborValueConstRef &rhs) noexcept |
Qt::strong_ordering | compareThreeWay (const QCborArray &lhs, const QCborValueConstRef &rhs) noexcept |
\inmodule QtCore
\reentrant
The QCborArray class is used to hold an array of CBOR elements.
\compares strong \compareswith strong QCborValueConstRef \endcompareswith
This class can be used to hold one sequential container in CBOR (an array). 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}.
QCborArray is very similar to \l QVariantList and \l QJsonArray and its API is almost identical to those two classes. It can also be converted to and from those two, though there may be loss of information in some conversions.
Definition at line 19 of file qcborarray.h.
A synonym to QCborArray::ConstIterator.
Definition at line 268 of file qcborarray.h.
typedef const value_type* QCborArray::const_pointer |
A typedef to {const QCborValue *}, for compatibility with generic algorithms.
Definition at line 199 of file qcborarray.h.
typedef const QCborValue& QCborArray::const_reference |
A typedef to {const QCborValue &}, for compatibility with generic algorithms.
Definition at line 201 of file qcborarray.h.
typedef qsizetype QCborArray::difference_type |
A typedef to qsizetype.
Definition at line 202 of file qcborarray.h.
typedef Iterator QCborArray::iterator |
A synonym to QCborArray::Iterator.
Definition at line 267 of file qcborarray.h.
typedef value_type* QCborArray::pointer |
A typedef to {QCborValue *}, for compatibility with generic algorithms.
Definition at line 198 of file qcborarray.h.
typedef QCborValue& QCborArray::reference |
A typedef to {QCborValue &}, for compatibility with generic algorithms.
Definition at line 200 of file qcborarray.h.
typedef qsizetype QCborArray::size_type |
A typedef to qsizetype.
Definition at line 196 of file qcborarray.h.
typedef QCborValue QCborArray::value_type |
The type of values that can be held in a QCborArray: that is, QCborValue.
Definition at line 197 of file qcborarray.h.
|
noexcept |
Constructs an empty QCborArray.
Definition at line 87 of file qcborarray.cpp.
|
noexcept |
Copies the contents of other into this object.
Definition at line 95 of file qcborarray.cpp.
|
inline |
Initializes this QCborArray from the C++ brace-enclosed list found in args, as in the following example:
Definition at line 207 of file qcborarray.h.
QCborArray::~QCborArray | ( | ) |
Destroys this QCborArray and frees any associated resources.
Definition at line 114 of file qcborarray.cpp.
|
inline |
Definition at line 244 of file qcborarray.h.
|
inline |
Appends value into the array after all other elements it may already contain.
Definition at line 245 of file qcborarray.h.
QCborValue QCborArray::at | ( | qsizetype | i | ) | const |
Returns the QCborValue element at position i in the array.
If the array is smaller than i elements, 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 array is not large enough from the case where the array starts with an undefined value.
Definition at line 188 of file qcborarray.cpp.
|
inline |
Returns an array iterator pointing to the first item in this array.
If the array is empty, then this function returns the same as end().
Definition at line 269 of file qcborarray.h.
|
inline |
Returns an array iterator pointing to the first item in this array.
If the array is empty, then this function returns the same as end().
Definition at line 271 of file qcborarray.h.
|
inline |
Returns an array iterator pointing to the first item in this array.
If the array is empty, then this function returns the same as end().
Definition at line 272 of file qcborarray.h.
|
inline |
Returns an array iterator pointing to just after the last element in this array.
Definition at line 276 of file qcborarray.h.
void QCborArray::clear | ( | ) |
|
noexcept |
Compares this array and other, comparing each element in sequence, and returns an integer that indicates whether this array should be sorted before (if the result is negative) or after other (if the result is positive).
If this function returns 0, the two arrays are equal and contain the same elements.
For more information on CBOR sorting order, see QCborValue::compare().
Definition at line 1502 of file qcborvalue.cpp.
|
inline |
Returns an array iterator pointing to the first item in this array.
If the array is empty, then this function returns the same as end().
Definition at line 270 of file qcborarray.h.
|
inline |
Returns an array iterator pointing to just after the last element in this array.
Definition at line 274 of file qcborarray.h.
bool QCborArray::contains | ( | const QCborValue & | value | ) | const |
Returns true if this array contains an element that is equal to value.
Definition at line 423 of file qcborarray.cpp.
|
inline |
|
inline |
Returns an array iterator pointing to just after the last element in this array.
Definition at line 273 of file qcborarray.h.
|
inline |
Returns an array iterator pointing to just after the last element in this array.
Definition at line 275 of file qcborarray.h.
|
inline |
Removes the element pointed to by the array iterator it from this array, then returns an iterator to the next element (the one that took the same position in the array that it used to occupy).
Definition at line 282 of file qcborarray.h.
Definition at line 281 of file qcborarray.h.
|
inline |
Extracts a value from the array at the position indicated by iterator it and returns the value so extracted.
Definition at line 246 of file qcborarray.h.
QCborValue QCborArray::extract | ( | Iterator | it | ) |
Definition at line 326 of file qcborarray.cpp.
|
inline |
Returns a reference to the first QCborValue of this array.
The array must not be empty.
QCborValueRef has the exact same API as \l QCborValue, with one important difference: if you assign new values to it, this array will be updated with that new value.
Definition at line 231 of file qcborarray.h.
|
inline |
Returns the first QCborValue of this array.
If the array is empty, 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 array is not large enough from the case where the array ends with an undefined value.
Definition at line 228 of file qcborarray.h.
|
static |
Converts all JSON items found in the array array to CBOR using QCborValue::fromJson(), and returns the CBOR array composed of those elements.
This conversion is lossless, as the CBOR type system is a superset of JSON's. Moreover, the array returned by this function can be converted back to the original array by using toJsonArray().
Definition at line 855 of file qjsoncbor.cpp.
|
staticnoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 866 of file qjsoncbor.cpp.
|
static |
Returns a QCborArray containing all the strings found in the list list.
Definition at line 816 of file qjsoncbor.cpp.
|
static |
Converts all the items in the list to CBOR using QCborValue::fromVariant() and returns the array composed of those elements.
Conversion from \l QVariant is not completely lossless. Please see the documentation in QCborValue::fromVariant() for more information.
Definition at line 834 of file qjsoncbor.cpp.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Inserts value into this array before element before and returns an array iterator pointing to the just-inserted element.
Definition at line 279 of file qcborarray.h.
|
inline |
Definition at line 277 of file qcborarray.h.
void QCborArray::insert | ( | qsizetype | i, |
const QCborValue & | value ) |
Definition at line 292 of file qcborarray.cpp.
void QCborArray::insert | ( | qsizetype | i, |
QCborValue && | value ) |
Inserts value into the array at position i in this array.
If i is -1, the entry is appended to the array. Pads the array with invalid entries if i is greater than the prior size of the array.
Definition at line 304 of file qcborarray.cpp.
|
inline |
Returns true if this QCborArray is empty (that is if size() is 0).
Definition at line 224 of file qcborarray.h.
|
inline |
Returns a reference to the last QCborValue of this array.
The array must not be empty.
QCborValueRef has the exact same API as \l QCborValue, with one important difference: if you assign new values to it, this array will be updated with that new value.
Definition at line 232 of file qcborarray.h.
|
inline |
Returns the last QCborValue of this array.
If the array is empty, 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 array is not large enough from the case where the array ends with an undefined value.
Definition at line 229 of file qcborarray.h.
|
inline |
Returns a new QCborArray containing the same elements as this array, plus v appended as the last element.
Definition at line 291 of file qcborarray.h.
|
inline |
Appends v to this array and returns a reference to this array.
Definition at line 293 of file qcborarray.h.
|
inline |
Appends v to this array and returns a reference to this array.
Definition at line 295 of file qcborarray.h.
|
noexcept |
Replaces the contents of this array with that found in other, then returns a reference to this object.
Definition at line 122 of file qcborarray.cpp.
|
inline |
Returns a reference to the QCborValue element at position i in the array.
Indices beyond the end of the array will grow the array, filling with undefined entries, until it has an entry at the specified index.
QCborValueRef has the exact same API as \l QCborValue, with one important difference: if you assign new values to it, this array will be updated with that new value.
Definition at line 233 of file qcborarray.h.
|
inline |
Returns the QCborValue element at position i in the array.
If the array is smaller than i elements, 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 array is not large enough from the case where the array contains an undefined value at position i.
Definition at line 230 of file qcborarray.h.
|
inline |
Synonym for removeLast().
This function is provided for compatibility with generic code that uses the Standard Library API.
Removes the last element of this array. The array must not be empty before the removal
Definition at line 287 of file qcborarray.h.
|
inline |
Synonym for removeFirst().
This function is provided for compatibility with generic code that uses the Standard Library API.
Removes the first element of this array. The array must not be empty before the removal
Definition at line 286 of file qcborarray.h.
|
inline |
Definition at line 242 of file qcborarray.h.
|
inline |
Prepends value into the array before any other elements it may already contain.
Definition at line 243 of file qcborarray.h.
|
inline |
Synonym for append().
This function is provided for compatibility with generic code that uses the Standard Library API.
Appends the element t to this array.
Definition at line 284 of file qcborarray.h.
|
inline |
Synonym for prepend().
This function is provided for compatibility with generic code that uses the Standard Library API.
Prepends the element t to this array.
Definition at line 285 of file qcborarray.h.
Removes the item at position i from the array.
The array must have more than i elements before the removal.
Definition at line 364 of file qcborarray.cpp.
|
inline |
Removes the first item in the array, making the second element become the first.
The array must not be empty before this call.
Definition at line 250 of file qcborarray.h.
|
inline |
Removes the last item in the array.
The array must not be empty before this call.
Definition at line 251 of file qcborarray.h.
|
noexcept |
|
inlinenoexcept |
\memberswap{array}
Definition at line 216 of file qcborarray.h.
|
inline |
Removes the item at position i from the array and returns it.
The array must have more than i elements before the removal.
Definition at line 249 of file qcborarray.h.
|
inline |
Removes the first item in the array and returns it, making the second element become the first.
The array must not be empty before this call.
Definition at line 252 of file qcborarray.h.
|
inline |
Removes the last item in the array and returns it.
The array must not be empty before this call.
Definition at line 253 of file qcborarray.h.
|
inline |
Explicitly construcuts a \l QCborValue object that represents this array.
This function is usually not necessary since QCborValue has a constructor for QCborArray, so the conversion is implicit.
Converting QCborArray to QCborValue allows it to be used in any context where QCborValues can be used, including as items in QCborArrays and as keys and mapped types in QCborMap. Converting an array to QCborValue allows access to QCborValue::toCbor().
Definition at line 221 of file qcborarray.h.
QJsonArray QCborArray::toJsonArray | ( | ) | const |
Recursively converts every \l QCborValue element in this array to JSON using QCborValue::toJsonValue() and returns the corresponding QJsonArray composed of those elements.
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 418 of file qjsoncbor.cpp.
QVariantList QCborArray::toVariantList | ( | ) | const |
Recursively converts each \l QCborValue in this array using QCborValue::toVariant() and returns the QVariantList composed of the converted items.
Conversion to \l QVariant is not completely lossless. Please see the documentation in QCborValue::toVariant() for more information.
Definition at line 802 of file qjsoncbor.cpp.
|
friend |
Definition at line 1497 of file qcborvalue.cpp.
References QtCbor::ForEquality.
|
friend |
Definition at line 320 of file qcborarray.h.
|
friend |
Definition at line 336 of file qcborarray.h.
|
friend |
Definition at line 308 of file qcborarray.h.
|
friend |
Definition at line 325 of file qcborarray.h.
|
friend |
Definition at line 341 of file qcborarray.h.
|
friend |
Definition at line 352 of file qcborarray.h.