QCborArray Class
The QCborArray class is used to hold an array of CBOR elements. More…
| Header | #include <QCborArray> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
| Since | 5.12 |
List of all members, including inherited members
Public Types
| typedef | size_type |
| typedef | value_type |
| typedef | pointer |
| typedef | const_pointer |
| typedef | reference |
| typedef | const_reference |
| typedef | difference_type |
| typedef | iterator |
| typedef | const_iterator |
Public Functions
Static Public Members
| QCborArray | fromStringList(const QStringList &list) |
| QCborArray | fromVariantList(const QVariantList &list) |
| QCborArray | fromJsonArray(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.
QCborArray QCborArray::fromJsonArray(const QJsonArray &array)
Returns an array of the values in array, each converted by QCborValue::fromJsonValue().
QCborArray QCborArray::fromStringList(const QStringList &list)
Returns an array of the strings in list.
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().