内容表

上一话题

QCalendar

下一话题

QCborError

QCborArray

QCborArray class is used to hold an array of CBOR elements. 更多

Inheritance diagram of PySide2.QtCore.QCborArray

New in version 5.12.

概要

函数

静态函数

详细描述

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 .

QCborArray 非常类似 QVariantList and 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.

另请参阅

QCborValue QCborMap QJsonArray QList QVector

class QCborArray

QCborArray(other)

param other

QCborArray

构造空 QCborArray .

PySide2.QtCore.QCborArray. append ( value )
参数

value QCborValue

PySide2.QtCore.QCborArray. append ( value )
参数

value QCborValue

PySide2.QtCore.QCborArray. at ( i )
参数

i long long

返回类型

QCborValue

返回 QCborValue element at position i in the array.

若数组小于 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.

PySide2.QtCore.QCborArray. clear ( )

清空此数组。

另请参阅

isEmpty()

PySide2.QtCore.QCborArray. compare ( other )
参数

other QCborArray

返回类型

int

比较此数组和 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() .

另请参阅

compare() compare() operator==()

PySide2.QtCore.QCborArray. contains ( value )
参数

value QCborValue

返回类型

bool

Returns true if this array contains an element that is equal to value .

PySide2.QtCore.QCborArray. empty ( )
返回类型

bool

同义词为 isEmpty() . This function is provided for compatibility with generic code that uses the Standard Library API.

返回 true 若此数组为空 ( size() == 0).

PySide2.QtCore.QCborArray. first ( )
返回类型

QCborValue

返回第一 QCborValue of this array.

若数组为空,此函数返回 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.

static PySide2.QtCore.QCborArray. fromJsonArray ( array )
参数

array QJsonArray

返回类型

QCborArray

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

static PySide2.QtCore.QCborArray. fromStringList ( list )
参数

list – 字符串列表

返回类型

QCborArray

返回 QCborArray containing all the strings found in the list 列表。

static PySide2.QtCore.QCborArray. fromVariantList ( list )
参数

list

返回类型

QCborArray

Converts all the items in the list to CBOR using fromVariant() and returns the array composed of those elements.

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

PySide2.QtCore.QCborArray. insert ( i , value )
参数
PySide2.QtCore.QCborArray. insert ( i , value )
参数
PySide2.QtCore.QCborArray. isEmpty ( )
返回类型

bool

返回 true,若此 QCborArray is empty (that is if size() is 0).

另请参阅

size() clear()

PySide2.QtCore.QCborArray. last ( )
返回类型

QCborValue

Returns the last QCborValue of this array.

若数组为空,此函数返回 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.

PySide2.QtCore.QCborArray. __ne__ ( other )
参数

other QCborArray

返回类型

bool

比较此数组和 other , 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() .

另请参阅

compare() operator==() operator==() operator==() operator

PySide2.QtCore.QCborArray. __add__ ( v )
参数

v QCborValue

返回类型

QCborArray

返回新 QCborArray containing the same elements as this array, plus v appended as the last element.

另请参阅

operator+=() operator append()

PySide2.QtCore.QCborArray. __iadd__ ( v )
参数

v QCborValue

返回类型

QCborArray

追加 v to this array and returns a reference to this array.

另请参阅

append() insert() operator+() operator

PySide2.QtCore.QCborArray. __lt__ ( other )
参数

other QCborArray

返回类型

bool

PySide2.QtCore.QCborArray. __lshift__ ( v )
参数

v QCborValue

返回类型

QCborArray

PySide2.QtCore.QCborArray. __eq__ ( other )
参数

other QCborArray

返回类型

bool

比较此数组和 other , 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() .

另请参阅

compare() operator==() operator==() operator!=() operator

PySide2.QtCore.QCborArray.operator[](i)
参数

i long long

返回类型

QCborValue

返回 QCborValue element at position i in the array.

若数组小于 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 .

PySide2.QtCore.QCborArray. pop_back ( )

同义词为 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

PySide2.QtCore.QCborArray. pop_front ( )

同义词为 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

PySide2.QtCore.QCborArray. prepend ( value )
参数

value QCborValue

PySide2.QtCore.QCborArray. prepend ( value )
参数

value QCborValue

PySide2.QtCore.QCborArray. push_back ( t )
参数

t QCborValue

同义词为 append() . This function is provided for compatibility with generic code that uses the Standard Library API.

追加元素 t 到此数组。

PySide2.QtCore.QCborArray. push_front ( t )
参数

t QCborValue

同义词为 prepend() . This function is provided for compatibility with generic code that uses the Standard Library API.

Prepends the element t 到此数组。

PySide2.QtCore.QCborArray. removeAt ( i )
参数

i long long

Removes the item at position i from the array. The array must have more than i elements before the removal.

PySide2.QtCore.QCborArray. removeFirst ( )

Removes the first item in the array, making the second element become the first. The array must not be empty before this call.

PySide2.QtCore.QCborArray. removeLast ( )

Removes the last item in the array. The array must not be empty before this call.

PySide2.QtCore.QCborArray. size ( )
返回类型

long long

返回此数组的大小。

另请参阅

isEmpty()

PySide2.QtCore.QCborArray. swap ( other )
参数

other QCborArray

交换此对象的内容和 other .

PySide2.QtCore.QCborArray. takeAt ( i )
参数

i long long

返回类型

QCborValue

Removes the item at position i from the array and returns it. The array must have more than i elements before the removal.

PySide2.QtCore.QCborArray. takeFirst ( )
返回类型

QCborValue

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.

PySide2.QtCore.QCborArray. takeLast ( )
返回类型

QCborValue

Removes the last item in the array and returns it. The array must not be empty before this call.

PySide2.QtCore.QCborArray. toCborValue ( )
返回类型

QCborValue

Explicitly construcuts a QCborValue object that represents this array. This function is usually not necessary since QCborValue has a constructor for QCborArray , so the conversion is implicit.

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

另请参阅

QCborValue(const QCborArray &)

PySide2.QtCore.QCborArray. toJsonArray ( )
返回类型

QJsonArray

Recursively converts every QCborValue element in this array to JSON using 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 toJsonValue() .

PySide2.QtCore.QCborArray. toVariantList ( )
返回类型

Recursively converts each QCborValue in this array using toVariant() and returns the QVariantList composed of the converted items.

Conversion to QVariant is not completely lossless. Please see the documentation in toVariant() 了解更多信息。