PySide6.QtCore.QCborArray¶
- class QCborArray¶
- The - QCborArrayclass is used to hold an array of CBOR elements. More…- Synopsis¶- Methods¶- def - __init__()
- def - append()
- def - at()
- def - clear()
- def - compare()
- def - contains()
- def - empty()
- def - first()
- def - insert()
- def - isEmpty()
- def - last()
- def - __ne__()
- def - __add__()
- def - __iadd__()
- def - __lt__()
- def - __lshift__()
- def - __le__()
- def - __eq__()
- def - __gt__()
- def - __ge__()
- def - operator[]()
- def - pop_back()
- def - pop_front()
- def - prepend()
- def - push_back()
- def - push_front()
- def - removeAt()
- def - removeFirst()
- def - removeLast()
- def - size()
- def - swap()
- def - takeAt()
- def - takeFirst()
- def - takeLast()
- def - toCborValue()
- def - toJsonArray()
- def - toVariantList()
 - Static functions¶- def - fromJsonArray()
- def - fromStringList()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - Detailed Description¶- 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 CoAP protocol. - QCborArrayis very similar to QVariantList and- QJsonArrayand 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.- See also - QCborValue- QCborMap- QJsonArray- QListParsing and displaying CBOR data Serialization Converter Saving and Loading a Game- __init__()¶
 - Constructs an empty - QCborArray.- __init__(other)
- Parameters:
- other – - QCborArray
 
 - Copies the contents of - otherinto this object.- append(value)¶
- Parameters:
- value – - QCborValue
 
 - at(i)¶
- Parameters:
- i – int 
- Return type:
 
 - Returns the - QCborValueelement at position- iin the array.- If the array is smaller than - ielements, this function returns a- QCborValuecontaining 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.- clear()¶
 - Empties this array. - See also - compare(other)¶
- Parameters:
- other – - QCborArray
- Return type:
- int 
 
 - 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 - compare().- contains(value)¶
- Parameters:
- value – - QCborValue
- Return type:
- bool 
 
 - Returns true if this array contains an element that is equal to - value.- empty()¶
- Return type:
- bool 
 
 - Synonym for - isEmpty(). This function is provided for compatibility with generic code that uses the Standard Library API.- Returns true if this array is empty ( - size()== 0).- first()¶
- Return type:
 
 - Returns the first - QCborValueof this array.- If the array is empty, this function returns a - QCborValuecontaining 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.- static fromJsonArray(array)¶
- Parameters:
- array – - QJsonArray
- Return type:
 
 - Converts all JSON items found in the - arrayarray 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 - arrayby using- toJsonArray().- static fromStringList(list)¶
- Parameters:
- list – list of strings 
- Return type:
 
 - Returns a - QCborArraycontaining all the strings found in the- listlist.- See also - static fromVariantList(list)¶
- Parameters:
- list – .list of QVariant 
- Return type:
 
 - Converts all the items in the - listto CBOR using- fromVariant()and returns the array composed of those elements.- Conversion from - QVariantis not completely lossless. Please see the documentation in- fromVariant()for more information.- insert(i, value)¶
- Parameters:
- i – int 
- value – - QCborValue
 
 
 - isEmpty()¶
- Return type:
- bool 
 
 - Returns true if this - QCborArrayis empty (that is if- size()is 0).- last()¶
- Return type:
 
 - Returns the last - QCborValueof this array.- If the array is empty, this function returns a - QCborValuecontaining 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.- __ne__(rhs)¶
- Parameters:
- rhs – - QCborArray
- Return type:
- bool 
 
 - Compares - lhsand- rhsarrays, comparing each element in sequence, and returns true if the two arrays’ contents are different, false otherwise.- For more information on CBOR equality in Qt, see, - compare().- See also - compare()- operator==()- operator==()- operator==()- operator- __ne__(rhs)
- Parameters:
- rhs – - QCborValue
- Return type:
- bool 
 
 - __add__(v)¶
- Parameters:
- v – - QCborValue
- Return type:
 
 - Returns a new - QCborArraycontaining the same elements as this array, plus- vappended as the last element.- See also - operator+=()- operator- append()- __iadd__(v)¶
- Parameters:
- v – - QCborValue
- Return type:
 
 - Appends - vto this array and returns a reference to this array.- __lt__(rhs)¶
- Parameters:
- rhs – - QCborArray
- Return type:
- bool 
 
 - Compares - lhsand- rhsarrays, comparing each element in sequence, and returns true if- lhsarray should be sorted before- rhs, false otherwise.- For more information on CBOR sorting order, see - compare().- See also - compare()- operator==()- operator==()- operator==()- operator!=()- operator- __lt__(rhs)
- Parameters:
- rhs – - QCborValue
- Return type:
- bool 
 
 - __lshift__(v)¶
- Parameters:
- v – - QCborValue
- Return type:
 
 - Appends - vto this array and returns a reference to this array.- __le__(rhs)¶
- Parameters:
- rhs – - QCborArray
- Return type:
- bool 
 
 - Compares - lhsand- rhsarrays, comparing each element in sequence, and returns true if- lhsarray should be sorted before- rhs, or if both arrays contains the same elements, false otherwise.- For more information on CBOR sorting order, see - compare().- See also - compare()- operator==()- operator==()- operator==()- operator!=()- operator- __le__(rhs)
- Parameters:
- rhs – - QCborValue
- Return type:
- bool 
 
 - __eq__(rhs)¶
- Parameters:
- rhs – - QCborArray
- Return type:
- bool 
 
 - Compares - lhsand- rhsarrays, comparing each element in sequence, and returns true if both arrays contains the same elements, false otherwise.- For more information on CBOR equality in Qt, see, - compare().- See also - compare()- operator==()- operator==()- operator!=()- operator- __eq__(rhs)
- Parameters:
- rhs – - QCborValue
- Return type:
- bool 
 
 - __gt__(rhs)¶
- Parameters:
- rhs – - QCborArray
- Return type:
- bool 
 
 - Compares - lhsand- rhsarrays, comparing each element in sequence, and returns true if- lhsarray should be sorted after- rhs, false otherwise.- For more information on CBOR sorting order, see - compare().- See also - compare()- operator==()- operator==()- operator==()- operator!=()- operator>=()- __gt__(rhs)
- Parameters:
- rhs – - QCborValue
- Return type:
- bool 
 
 - __ge__(rhs)¶
- Parameters:
- rhs – - QCborArray
- Return type:
- bool 
 
 - Compares - lhsand- rhsarrays, comparing each element in sequence, and returns true if- lhsarray should be sorted after- rhs, or if both arrays contains the same elements, false otherwise.- For more information on CBOR sorting order, see - compare().- See also - compare()- operator==()- operator==()- operator==()- operator!=()- operator>()- __ge__(rhs)
- Parameters:
- rhs – - QCborValue
- Return type:
- bool 
 
 - operator(i)¶
- Parameters:
- i – int 
- Return type:
 
 - Returns the - QCborValueelement at position- iin the array.- If the array is smaller than - ielements, this function returns a- QCborValuecontaining 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.- pop_back()¶
 - 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 - pop_front()¶
 - 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 - prepend(value)¶
- Parameters:
- value – - QCborValue
 
 - push_back(t)¶
- Parameters:
- t – - QCborValue
 
 - Synonym for - append(). This function is provided for compatibility with generic code that uses the Standard Library API.- Appends the element - tto this array.- See also - push_front(t)¶
- Parameters:
- t – - QCborValue
 
 - Synonym for - prepend(). This function is provided for compatibility with generic code that uses the Standard Library API.- Prepends the element - tto this array.- See also - removeAt(i)¶
- Parameters:
- i – int 
 
 - Removes the item at position - ifrom the array. The array must have more than- ielements before the removal.- See also - takeAt()- removeFirst()- removeLast()- at()- operator[]()- insert()- prepend()- append()- removeFirst()¶
 - Removes the first item in the array, making the second element become the first. The array must not be empty before this call. - See also - removeAt()- takeFirst()- removeLast()- at()- operator[]()- insert()- prepend()- append()- removeLast()¶
 - Removes the last item in the array. The array must not be empty before this call. - See also - removeAt()- takeLast()- removeFirst()- at()- operator[]()- insert()- prepend()- append()- size()¶
- Return type:
- int 
 
 - Returns the size of this array. - See also - swap(other)¶
- Parameters:
- other – - QCborArray
 
 - Swaps this array with - other. This operation is very fast and never fails.- takeAt(i)¶
- Parameters:
- i – int 
- Return type:
 
 - Removes the item at position - ifrom the array and returns it. The array must have more than- ielements before the removal.- See also - removeAt()- removeFirst()- removeLast()- at()- operator[]()- insert()- prepend()- append()- takeFirst()¶
- Return type:
 
 - 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. - See also - takeAt()- removeFirst()- removeLast()- at()- operator[]()- insert()- prepend()- append()- takeLast()¶
- Return type:
 
 - Removes the last item in the array and returns it. The array must not be empty before this call. - See also - takeAt()- removeLast()- removeFirst()- at()- operator[]()- insert()- prepend()- append()- toCborValue()¶
- Return type:
 
 - Explicitly construcuts a - QCborValueobject that represents this array. This function is usually not necessary since- QCborValuehas a constructor for- QCborArray, so the conversion is implicit.- Converting - QCborArrayto- QCborValueallows 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- QCborValueallows access to- toCbor().- See also - QCborValue(const QCborArray &)- toJsonArray()¶
- Return type:
 
 - Recursively converts every - QCborValueelement in this array to JSON using- toJsonValue()and returns the corresponding- QJsonArraycomposed 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 - toJsonValue().- toVariantList()¶
- Return type:
- .list of QVariant 
 
 - Recursively converts each - QCborValuein this array using- toVariant()and returns the QVariantList composed of the converted items.- Conversion to - QVariantis not completely lossless. Please see the documentation in- toVariant()for more information.