6.0.0-rc4Source

QCborArray Class

The QCborArray class is used to hold an array of CBOR elements. More…

Header#include <QCborArray>
CMaketarget_link_libraries(app PRIVATE Nt::Core)
ModuleNt Core C++ Classes
Since5.12

List of all members, including inherited members

Public Types

typedefsize_type
typedefvalue_type
typedefpointer
typedefconst_pointer
typedefreference
typedefconst_reference
typedefdifference_type
typedefiterator
typedefconst_iterator

Public Functions

QCborArray()
QCborArray(std::initializer_list<QCborValue> args)
QCborArray(const QCborArray &other)
QCborArray(QCborArray &&other)
QCborArray &operator=(const QCborArray &other)
QCborArray &operator=(QCborArray &&other)
~QCborArray()
voidswap(QCborArray &other)
QCborValuetoCborValue() const
qsizetypesize() const
boolisEmpty() const
voidclear()
QCborValueat(qsizetype i) const
QCborValuefirst() const
QCborValuelast() const
const QCborValueoperator[](qsizetype i) const
QCborValueReffirst()
QCborValueReflast()
QCborValueRefoperator[](qsizetype i)
voidinsert(qsizetype i, const QCborValue &value)
QCborValueextract(ConstIterator it)
QCborValueextract(Iterator it)
voidremoveAt(qsizetype i)
QCborValuetakeAt(qsizetype i)
voidremoveFirst()
voidremoveLast()
QCborValuetakeFirst()
QCborValuetakeLast()
boolcontains(const QCborValue &value) const
intcompare(const QCborArray &other) const
Iteratorbegin()
ConstIteratorbegin() const
ConstIteratorconstBegin() const
ConstIteratorcbegin() const
Iteratorend()
ConstIteratorend() const
ConstIteratorconstEnd() const
ConstIteratorcend() const
Iteratorinsert(Iterator before, const QCborValue &value)
Iteratorinsert(ConstIterator before, const QCborValue &value)
Iteratorerase(Iterator it)
Iteratorerase(ConstIterator it)
voidpush_back(const QCborValue &t)
voidpush_front(const QCborValue &t)
voidpop_front()
voidpop_back()
boolempty() const
voidprepend(const QCborValue &value)
voidappend(const QCborValue &value)
QCborArrayoperator+(const QCborValue &v) const
QCborArray &operator+=(const QCborValue &v)
QCborArray &operator<<(const QCborValue &v)
QVariantListtoVariantList() const
QJsonArraytoJsonArray() const

Static Public Members

QCborArrayfromStringList(const QStringList &list)
QCborArrayfromVariantList(const QVariantList &list)
QCborArrayfromJsonArray(const QJsonArray &array)

Detailed Description

A QCborArray is a list of QCborValue, which may be of any type, nested arrays and maps among them. It is what QCborValue::toArray() returns, and becomes a QCborValue again with toCborValue() or the QCborValue constructor.

QCborArray array{1, u"two"_s, 3.5};
array.append(QCborMap{{u"key"_s, true}});
array[0] = 10;

The operator[] that is not const and the iterators give a QCborValueRef, through which an element is changed in place. An element that is read past the end is undefined.

See also QCborMap and QCborValue.

Differences from Qt

Copies are deep: a copy of an array copies its elements, which share their own strings and containers. There is no QDebug operator, and no QDataStream operators.

Member Type Documentation

typedef QCborArray::const_iterator

The same as ConstIterator.

typedef QCborArray::const_pointer

A pointer to an element that cannot be changed.

typedef QCborArray::const_reference

A copy of an element.

typedef QCborArray::difference_type

The type of a distance between iterators.

typedef QCborArray::iterator

The same as Iterator.

typedef QCborArray::pointer

A pointer to an element.

typedef QCborArray::reference

A reference to an element that can be assigned to.

typedef QCborArray::size_type

The type of a size.

typedef QCborArray::value_type

The type of the elements.

Member Function Documentation

QCborArray::QCborArray()

Constructs an empty array.

QCborArray::QCborArray(std::initializer_list<QCborValue> args)

Constructs an array of the values in args.

QCborArray::QCborArray(const QCborArray &other)

Constructs a copy of other.

QCborArray::QCborArray(QCborArray &&other)

Move-constructs an array from other, which becomes empty.

QCborArray::~QCborArray()

Destroys the array.

void QCborArray::append(const QCborValue &value)

Appends value to the array.

QCborValue QCborArray::at(qsizetype i) const

Returns the element at i, or undefined if there is none.

Iterator QCborArray::begin()

Returns an iterator to the first element.

ConstIterator QCborArray::begin() const

This is an overloaded function.

ConstIterator QCborArray::cbegin() const

Same as constBegin().

ConstIterator QCborArray::cend() const

Same as constEnd().

void QCborArray::clear()

Removes all elements.

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

Compares this array with other: a shorter array comes first, and arrays of the same length are compared element by element. Returns a negative number, 0 or a positive number.

See also QCborValue::compare().

ConstIterator QCborArray::constBegin() const

Returns a const iterator to the first element.

ConstIterator QCborArray::constEnd() const

Returns a const iterator past the last element.

bool QCborArray::contains(const QCborValue &value) const

Returns true if an element is equal to value.

bool QCborArray::empty() const

Returns true if the array has no elements.

Iterator QCborArray::end()

Returns an iterator past the last element.

ConstIterator QCborArray::end() const

This is an overloaded function.

Iterator QCborArray::erase(Iterator it)

Removes the element at it and returns an iterator to the element after it.

Iterator QCborArray::erase(ConstIterator it)

This is an overloaded function.

Removes the element at it and returns an iterator to the element after it.

QCborValue QCborArray::extract(ConstIterator it)

Removes the element at it and returns it.

QCborValue QCborArray::extract(Iterator it)

This is an overloaded function.

Removes the element at it and returns it.

QCborValue QCborArray::first() const

Returns the first element, or undefined if the array is empty.

QCborValueRef QCborArray::first()

This is an overloaded function.

Returns a reference to the first element. The array must not be empty.

[static] QCborArray QCborArray::fromJsonArray(const QJsonArray &array)

Returns an array of the values in array, each converted by QCborValue::fromJsonValue().

[static] QCborArray QCborArray::fromStringList(const QStringList &list)

Returns an array of the strings in list.

[static] QCborArray QCborArray::fromVariantList(const QVariantList &list)

Returns an array of the values in list, each converted by QCborValue::fromVariant().

void QCborArray::insert(qsizetype i, const QCborValue &value)

Inserts value at i. With a negative i, or one at the end, value is appended; an i beyond the end makes the array grow with undefined elements up to it.

See also append() and prepend().

Iterator QCborArray::insert(Iterator before, const QCborValue &value)

Inserts value before before and returns an iterator to it.

Iterator QCborArray::insert(ConstIterator before, const QCborValue &value)

This is an overloaded function.

Inserts value before before and returns an iterator to it.

bool QCborArray::isEmpty() const

Returns true if the array has no elements.

QCborValue QCborArray::last() const

Returns the last element, or undefined if the array is empty.

QCborValueRef QCborArray::last()

This is an overloaded function.

Returns a reference to the last element. The array must not be empty.

QCborArray QCborArray::operator+(const QCborValue &v) const

Returns a copy of the array with v appended.

QCborArray & QCborArray::operator+=(const QCborValue &v)

Appends v and returns a reference to this array.

QCborArray & QCborArray::operator<<(const QCborValue &v)

Appends v and returns a reference to this array.

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

Assigns other to this array and returns a reference to it.

QCborArray & QCborArray::operator=(QCborArray &&other)

Move-assigns other to this array and returns a reference to it.

const QCborValue QCborArray::operator[](qsizetype i) const

Returns the element at i, or undefined if there is none.

QCborValueRef QCborArray::operator[](qsizetype i)

This is an overloaded function.

Returns a reference to the element at i. An array that is shorter grows to i + 1 elements, with undefined in between.

void QCborArray::pop_back()

Removes the last element.

void QCborArray::pop_front()

Removes the first element.

void QCborArray::prepend(const QCborValue &value)

Puts value in front of the array.

void QCborArray::push_back(const QCborValue &t)

Appends t to the array.

void QCborArray::push_front(const QCborValue &t)

Puts t in front of the array.

void QCborArray::removeAt(qsizetype i)

Removes the element at i, if there is one.

void QCborArray::removeFirst()

Removes the first element. The array must not be empty.

void QCborArray::removeLast()

Removes the last element. The array must not be empty.

qsizetype QCborArray::size() const

Returns the number of elements.

void QCborArray::swap(QCborArray &other)

Exchanges this array with other.

QCborValue QCborArray::takeAt(qsizetype i)

Removes the element at i and returns it, or returns undefined if there is none.

QCborValue QCborArray::takeFirst()

Removes the first element and returns it. The array must not be empty.

QCborValue QCborArray::takeLast()

Removes the last element and returns it. The array must not be empty.

QCborValue QCborArray::toCborValue() const

Returns the array as a QCborValue.

QJsonArray QCborArray::toJsonArray() const

Returns the elements converted by QCborValue::toJsonValue().

QVariantList QCborArray::toVariantList() const

Returns the elements converted by QCborValue::toVariant().