Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QCborArray Class Reference

\inmodule QtCore\reentrant More...

#include <qcborarray.h>

+ Collaboration diagram for QCborArray:

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_typepointer
 A typedef to {QCborValue *}, for compatibility with generic algorithms.
 
typedef const value_typeconst_pointer
 A typedef to {const QCborValue *}, for compatibility with generic algorithms.
 
typedef QCborValuereference
 A typedef to {QCborValue &}, for compatibility with generic algorithms.
 
typedef const QCborValueconst_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.
 
QCborArrayoperator= (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
 Swaps the contents of this object and other.
 
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.
 
QCborArrayoperator+= (const QCborValue &v)
 Appends v to this array and returns a reference to this array.
 
QCborArrayoperator<< (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) noexcept
 
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
 

Detailed Description

\inmodule QtCore

\reentrant

Since
5.12

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.

See also
QCborValue, QCborMap, QJsonArray, QList, {Parsing and displaying CBOR data}, {Serialization Converter}, {Saving and Loading a Game}

Definition at line 19 of file qcborarray.h.

Member Typedef Documentation

◆ const_iterator

A synonym to QCborArray::ConstIterator.

Definition at line 268 of file qcborarray.h.

◆ const_pointer

A typedef to {const QCborValue *}, for compatibility with generic algorithms.

Definition at line 199 of file qcborarray.h.

◆ const_reference

A typedef to {const QCborValue &}, for compatibility with generic algorithms.

Definition at line 201 of file qcborarray.h.

◆ difference_type

A typedef to qsizetype.

Definition at line 202 of file qcborarray.h.

◆ iterator

A synonym to QCborArray::Iterator.

Definition at line 267 of file qcborarray.h.

◆ pointer

A typedef to {QCborValue *}, for compatibility with generic algorithms.

Definition at line 198 of file qcborarray.h.

◆ reference

A typedef to {QCborValue &}, for compatibility with generic algorithms.

Definition at line 200 of file qcborarray.h.

◆ size_type

A typedef to qsizetype.

Definition at line 196 of file qcborarray.h.

◆ value_type

The type of values that can be held in a QCborArray: that is, QCborValue.

Definition at line 197 of file qcborarray.h.

Constructor & Destructor Documentation

◆ QCborArray() [1/3]

QCborArray::QCborArray ( )
noexcept

Constructs an empty QCborArray.

Definition at line 87 of file qcborarray.cpp.

◆ QCborArray() [2/3]

QCborArray::QCborArray ( const QCborArray & other)
noexcept

Copies the contents of other into this object.

Definition at line 95 of file qcborarray.cpp.

◆ QCborArray() [3/3]

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

Initializes this QCborArray from the C++ brace-enclosed list found in args, as in the following example:

QCborArray a = { null, 0, 1, 1.5, 2, "Hello", QByteArray("World") };
\inmodule QtCore\reentrant
Definition qcborarray.h:20
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
GLboolean GLboolean GLboolean GLboolean a
[7]

Definition at line 207 of file qcborarray.h.

References append(), args, and QList< T >::size().

+ Here is the call graph for this function:

◆ ~QCborArray()

QCborArray::~QCborArray ( )

Destroys this QCborArray and frees any associated resources.

Definition at line 114 of file qcborarray.cpp.

Member Function Documentation

◆ append() [1/2]

void QCborArray::append ( const QCborValue & value)
inline

Definition at line 244 of file qcborarray.h.

References insert().

Referenced by QQmlJS::Dom::pluginData(), and QQmlJS::Dom::ErrorGroups::toCbor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ append() [2/2]

void QCborArray::append ( QCborValue && value)
inline

Appends value into the array after all other elements it may already contain.

See also
at(), operator[](), first(), last(), insert(), prepend(), removeAt(), takeAt()

Definition at line 245 of file qcborarray.h.

References insert().

+ Here is the call graph for this function:

◆ at()

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.

See also
operator[](), first(), last(), insert(), prepend(), append(), removeAt(), takeAt()

Definition at line 189 of file qcborarray.cpp.

References i, and QCborContainerPrivate::valueAt().

Referenced by QImageReaderWriterHelpers::appendImagePluginMimeTypes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ begin() [1/2]

QCborArray::iterator QCborArray::begin ( )
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().

See also
constBegin(), end()

Definition at line 269 of file qcborarray.h.

References d.

◆ begin() [2/2]

QCborArray::const_iterator QCborArray::begin ( ) const
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().

See also
constBegin(), constEnd()

Definition at line 271 of file qcborarray.h.

◆ cbegin()

QCborArray::const_iterator QCborArray::cbegin ( ) const
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().

See also
constBegin(), constEnd()

Definition at line 272 of file qcborarray.h.

◆ cend()

QCborArray::const_iterator QCborArray::cend ( ) const
inline

Returns an array iterator pointing to just after the last element in this array.

See also
constBegin(), constEnd()

Definition at line 276 of file qcborarray.h.

◆ clear()

void QCborArray::clear ( )

Empties this array.

See also
isEmpty()

Definition at line 164 of file qcborarray.cpp.

References QExplicitlySharedDataPointer< T >::reset().

+ Here is the call graph for this function:

◆ compare()

int QCborArray::compare ( const QCborArray & other) const
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().

See also
QCborValue::compare(), QCborMap::compare(), operator==()

Definition at line 1504 of file qcborvalue.cpp.

References compareContainer(), d, and other().

+ Here is the call graph for this function:

◆ constBegin()

QCborArray::const_iterator QCborArray::constBegin ( ) const
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().

See also
begin(), constEnd()

Definition at line 270 of file qcborarray.h.

References d.

◆ constEnd()

QCborArray::const_iterator QCborArray::constEnd ( ) const
inline

Returns an array iterator pointing to just after the last element in this array.

See also
constBegin(), end()

Definition at line 274 of file qcborarray.h.

References d.

◆ contains()

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

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

Definition at line 424 of file qcborarray.cpp.

References QCborContainerPrivate::compareElement(), and i.

+ Here is the call graph for this function:

◆ empty()

bool QCborArray::empty ( ) const
inline

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

See also
isEmpty(), size()

Definition at line 288 of file qcborarray.h.

◆ end() [1/2]

QCborArray::iterator QCborArray::end ( )
inline

Returns an array iterator pointing to just after the last element in this array.

See also
begin(), constEnd()

Definition at line 273 of file qcborarray.h.

References d.

◆ end() [2/2]

QCborArray::const_iterator QCborArray::end ( ) const
inline

Returns an array iterator pointing to just after the last element in this array.

See also
constBegin(), constEnd()

Definition at line 275 of file qcborarray.h.

◆ erase() [1/2]

QCborArray::iterator QCborArray::erase ( const_iterator it)
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).

See also
insert(), removeAt(), takeAt(), takeFirst(), takeLast()

Definition at line 282 of file qcborarray.h.

References d, and it.

◆ erase() [2/2]

QCborArray::iterator QCborArray::erase ( iterator it)
inline

Definition at line 281 of file qcborarray.h.

References d, and it.

◆ extract() [1/2]

QCborValue QCborArray::extract ( ConstIterator it)
inline

Extracts a value from the array at the position indicated by iterator it and returns the value so extracted.

See also
insert(), erase(), takeAt(), removeAt()

Definition at line 246 of file qcborarray.h.

References extract(), and it.

Referenced by extract().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ extract() [2/2]

QCborValue QCborArray::extract ( Iterator it)

Definition at line 327 of file qcborarray.cpp.

References QCborContainerPrivate::extractAt(), it, and QCborContainerPrivate::removeAt().

+ Here is the call graph for this function:

◆ first() [1/2]

QCborValueRef QCborArray::first ( )
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.

See also
operator[](), at(), last(), insert(), prepend(), append(), removeAt(), takeAt()

Definition at line 231 of file qcborarray.h.

References begin(), and Q_ASSERT.

+ Here is the call graph for this function:

◆ first() [2/2]

QCborValue QCborArray::first ( ) const
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.

See also
operator[](), at(), last(), insert(), prepend(), append(), removeAt(), takeAt()

Definition at line 228 of file qcborarray.h.

References at.

◆ fromJsonArray() [1/2]

QCborArray QCborArray::fromJsonArray ( const QJsonArray & array)
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().

See also
toJsonArray(), toVariantList(), QCborValue::fromJsonValue(), QCborMap::fromJsonObject()

Definition at line 852 of file qjsoncbor.cpp.

Referenced by QCborValue::fromJsonValue(), QCborValue::fromVariant(), and QJsonArray::toVariantList().

+ Here is the caller graph for this function:

◆ fromJsonArray() [2/2]

QCborArray QCborArray::fromJsonArray ( QJsonArray && array)
staticnoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Since
6.3

Definition at line 863 of file qjsoncbor.cpp.

◆ fromStringList()

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

Returns a QCborArray containing all the strings found in the list list.

See also
fromVariantList(), fromJsonArray()

Definition at line 813 of file qjsoncbor.cpp.

References list, and QList< T >::size().

Referenced by QCborValue::fromVariant(), and QJsonDocument::fromVariant().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fromVariantList()

QCborArray QCborArray::fromVariantList ( const QVariantList & list)
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.

See also
toVariantList(), fromStringList(), fromJsonArray(), QCborMap::fromVariantMap()

Definition at line 831 of file qjsoncbor.cpp.

References appendVariant(), list, and QList< T >::size().

Referenced by QCborValue::fromVariant(), and QJsonPrivate::Variant::toJsonArray().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insert() [1/4]

QCborArray::iterator QCborArray::insert ( const_iterator before,
const QCborValue & value )
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.

See also
erase(), removeAt(), prepend(), append()

Definition at line 279 of file qcborarray.h.

References d, QCborValueConstRef::i, and insert().

+ Here is the call graph for this function:

◆ insert() [2/4]

QCborArray::iterator QCborArray::insert ( iterator before,
const QCborValue & value )
inline

Definition at line 277 of file qcborarray.h.

References d, and insert().

+ Here is the call graph for this function:

◆ insert() [3/4]

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

Definition at line 293 of file qcborarray.cpp.

References QExplicitlySharedDataPointer< T >::data(), QCborContainerPrivate::grow(), i, QCborContainerPrivate::insertAt(), and Q_ASSERT.

+ Here is the call graph for this function:

◆ insert() [4/4]

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.

See also
at(), operator[](), first(), last(), prepend(), append(), removeAt(), takeAt(), extract()

Definition at line 305 of file qcborarray.cpp.

References QExplicitlySharedDataPointer< T >::data(), QCborContainerPrivate::grow(), i, QCborContainerPrivate::insertAt(), QCborContainerPrivate::MoveContainer, Q_ASSERT, and QCborContainerPrivate::resetValue().

+ Here is the call graph for this function:

◆ isEmpty()

bool QCborArray::isEmpty ( ) const
inline

Returns true if this QCborArray is empty (that is if size() is 0).

See also
size(), clear()

Definition at line 224 of file qcborarray.h.

◆ last() [1/2]

QCborValueRef QCborArray::last ( )
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.

See also
operator[](), at(), first(), insert(), prepend(), append(), removeAt(), takeAt()

Definition at line 232 of file qcborarray.h.

References begin(), and Q_ASSERT.

+ Here is the call graph for this function:

◆ last() [2/2]

QCborValue QCborArray::last ( ) const
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.

See also
operator[](), at(), first(), insert(), prepend(), append(), removeAt(), takeAt()

Definition at line 229 of file qcborarray.h.

References at.

◆ operator+()

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

Returns a new QCborArray containing the same elements as this array, plus v appended as the last element.

See also
operator+=(), operator<<(), append()

Definition at line 291 of file qcborarray.h.

◆ operator+=()

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

Appends v to this array and returns a reference to this array.

See also
append(), insert(), operator+(), operator<<()

Definition at line 293 of file qcborarray.h.

References append().

+ Here is the call graph for this function:

◆ operator<<()

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

Appends v to this array and returns a reference to this array.

See also
append(), insert(), operator+(), operator+=()

Definition at line 295 of file qcborarray.h.

References append().

+ Here is the call graph for this function:

◆ operator=()

QCborArray & QCborArray::operator= ( const QCborArray & other)
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.

References d, and other().

+ Here is the call graph for this function:

◆ operator[]() [1/2]

QCborValueRef QCborArray::operator[] ( qsizetype i)
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.

See also
at(), first(), last(), insert(), prepend(), append(), removeAt(), takeAt()

Definition at line 233 of file qcborarray.h.

References begin(), i, insert(), and QCborValue().

+ Here is the call graph for this function:

◆ operator[]() [2/2]

QCborValue QCborArray::operator[] ( qsizetype i) const
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.

See also
at(), first(), last(), insert(), prepend(), append(), removeAt(), takeAt()

Definition at line 230 of file qcborarray.h.

References at, and i.

◆ pop_back()

void QCborArray::pop_back ( )
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

See also
removeLast(), takeLast(), pop_front(), push_back(), append(), insert()

Definition at line 287 of file qcborarray.h.

◆ pop_front()

void QCborArray::pop_front ( )
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

See also
removeFirst(), takeFirst(), pop_back(), push_front(), prepend(), insert()

Definition at line 286 of file qcborarray.h.

◆ prepend() [1/2]

void QCborArray::prepend ( const QCborValue & value)
inline

Definition at line 242 of file qcborarray.h.

References insert().

+ Here is the call graph for this function:

◆ prepend() [2/2]

void QCborArray::prepend ( QCborValue && value)
inline

Prepends value into the array before any other elements it may already contain.

See also
at(), operator[](), first(), last(), insert(), append(), removeAt(), takeAt()

Definition at line 243 of file qcborarray.h.

References insert().

+ Here is the call graph for this function:

◆ push_back()

void QCborArray::push_back ( const QCborValue & t)
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.

See also
append(), push_front(), pop_back(), prepend(), insert()

Definition at line 284 of file qcborarray.h.

References append().

+ Here is the call graph for this function:

◆ push_front()

void QCborArray::push_front ( const QCborValue & t)
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.

See also
prepend(), push_back(), pop_front(), append(), insert()

Definition at line 285 of file qcborarray.h.

References prepend().

+ Here is the call graph for this function:

◆ removeAt()

void QCborArray::removeAt ( qsizetype i)

Removes the item at position i from the array.

The array must have more than i elements before the removal.

See also
takeAt(), removeFirst(), removeLast(), at(), operator[](), insert(), prepend(), append()

Definition at line 365 of file qcborarray.cpp.

References i, and QCborContainerPrivate::removeAt().

+ Here is the call graph for this function:

◆ removeFirst()

void QCborArray::removeFirst ( )
inline

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

Definition at line 250 of file qcborarray.h.

◆ removeLast()

void QCborArray::removeLast ( )
inline

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

Definition at line 251 of file qcborarray.h.

◆ size()

qsizetype QCborArray::size ( ) const
noexcept

Returns the size of this array.

See also
isEmpty()

Definition at line 154 of file qcborarray.cpp.

References QCborContainerPrivate::elements, and QList< T >::size().

+ Here is the call graph for this function:

◆ swap()

void QCborArray::swap ( QCborArray & other)
inlinenoexcept

Swaps the contents of this object and other.

Definition at line 216 of file qcborarray.h.

References d, and other().

+ Here is the call graph for this function:

◆ takeAt()

QCborValue QCborArray::takeAt ( qsizetype i)
inline

Removes the item at position i from the array and returns it.

The array must have more than i elements before the removal.

See also
removeAt(), removeFirst(), removeLast(), at(), operator[](), insert(), prepend(), append()

Definition at line 249 of file qcborarray.h.

References begin(), i, and Q_ASSERT.

+ Here is the call graph for this function:

◆ takeFirst()

void QCborArray::takeFirst ( )
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.

See also
takeAt(), removeFirst(), removeLast(), at(), operator[](), insert(), prepend(), append()

Definition at line 252 of file qcborarray.h.

◆ takeLast()

void QCborArray::takeLast ( )
inline

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

Definition at line 253 of file qcborarray.h.

◆ toCborValue()

QCborValue QCborArray::toCborValue ( ) const
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().

See also
QCborValue::QCborValue(const QCborArray &)

Definition at line 221 of file qcborarray.h.

◆ toJsonArray()

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

See also
fromJsonArray(), QCborValue::toJsonValue(), QCborMap::toJsonObject(), toVariantList()

Definition at line 419 of file qjsoncbor.cpp.

References convertToJsonArray(), and QExplicitlySharedDataPointer< T >::data().

+ Here is the call graph for this function:

◆ toVariantList()

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.

See also
fromVariantList(), fromStringList(), toJsonArray(), QCborValue::toVariant(), QCborMap::toVariantMap()

Definition at line 799 of file qjsoncbor.cpp.

References d, i, and QList< T >::reserve().

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ comparesEqual [1/3]

Q_CORE_EXPORT Q_DECL_PURE_FUNCTION bool comparesEqual ( const QCborArray & lhs,
const QCborArray & rhs )
friend

Definition at line 1499 of file qcborvalue.cpp.

◆ comparesEqual [2/3]

bool comparesEqual ( const QCborArray & lhs,
const QCborValue & rhs )
friend

Definition at line 320 of file qcborarray.h.

◆ comparesEqual [3/3]

bool comparesEqual ( const QCborArray & lhs,
const QCborValueConstRef & rhs )
friend

Definition at line 336 of file qcborarray.h.

◆ compareThreeWay [1/3]

Qt::strong_ordering compareThreeWay ( const QCborArray & lhs,
const QCborArray & rhs )
friend

Definition at line 308 of file qcborarray.h.

◆ compareThreeWay [2/3]

Qt::strong_ordering compareThreeWay ( const QCborArray & lhs,
const QCborValue & rhs )
friend

Definition at line 325 of file qcborarray.h.

◆ compareThreeWay [3/3]

Qt::strong_ordering compareThreeWay ( const QCborArray & lhs,
const QCborValueConstRef & rhs )
friend

Definition at line 341 of file qcborarray.h.

◆ QJsonPrivate::Variant

friend class QJsonPrivate::Variant
friend

Definition at line 352 of file qcborarray.h.


The documentation for this class was generated from the following files: