Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtCore\reentrant More...
#include <qjsonarray.h>
Classes | |
class | const_iterator |
\inmodule QtCore More... | |
class | iterator |
\inmodule QtCore More... | |
Public Types | |
typedef iterator | Iterator |
Qt-style synonym for QJsonArray::iterator. | |
typedef const_iterator | ConstIterator |
Qt-style synonym for QJsonArray::const_iterator. | |
typedef qsizetype | size_type |
Typedef for qsizetype. | |
typedef QJsonValue | value_type |
Typedef for QJsonValue. | |
typedef value_type * | pointer |
Typedef for QJsonValue *. | |
typedef const value_type * | const_pointer |
Typedef for const QJsonValue *. | |
typedef QJsonValueRef | reference |
Typedef for QJsonValue &. | |
typedef QJsonValue | const_reference |
Typedef for const QJsonValue &. | |
typedef qsizetype | difference_type |
Typedef for qsizetype. | |
Public Member Functions | |
QJsonArray () | |
Creates an empty array. | |
QJsonArray (std::initializer_list< QJsonValue > args) | |
~QJsonArray () | |
Deletes the array. | |
QJsonArray (const QJsonArray &other) noexcept | |
Creates a copy of other. | |
QJsonArray & | operator= (const QJsonArray &other) noexcept |
Assigns other to this array. | |
QJsonArray (QJsonArray &&other) noexcept | |
QJsonArray & | operator= (QJsonArray &&other) noexcept |
QVariantList | toVariantList () const |
Converts this object to a QVariantList. | |
qsizetype | size () const |
Returns the number of values stored in the array. | |
qsizetype | count () const |
Same as size(). | |
bool | isEmpty () const |
Returns true if the object is empty. | |
QJsonValue | at (qsizetype i) const |
Returns a QJsonValue representing the value for index i. | |
QJsonValue | first () const |
Returns the first value stored in the array. | |
QJsonValue | last () const |
Returns the last value stored in the array. | |
void | prepend (const QJsonValue &value) |
Inserts value at the beginning of the array. | |
void | append (const QJsonValue &value) |
Inserts value at the end of the array. | |
void | removeAt (qsizetype i) |
Removes the value at index position i. | |
QJsonValue | takeAt (qsizetype i) |
Removes the item at index position i and returns it. | |
void | removeFirst () |
Removes the first item in the array. | |
void | removeLast () |
Removes the last item in the array. | |
void | insert (qsizetype i, const QJsonValue &value) |
Inserts value at index position i in the array. | |
void | replace (qsizetype i, const QJsonValue &value) |
Replaces the item at index position i with value. | |
bool | contains (const QJsonValue &element) const |
Returns true if the array contains an occurrence of value, otherwise false . | |
QJsonValueRef | operator[] (qsizetype i) |
Returns the value at index position i as a modifiable reference. | |
QJsonValue | operator[] (qsizetype i) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Same as at(). | |
void | swap (QJsonArray &other) noexcept |
iterator | begin () |
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in the array. | |
const_iterator | begin () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
const_iterator | constBegin () const |
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the array. | |
const_iterator | cbegin () const |
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the array. | |
iterator | end () |
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last item in the array. | |
const_iterator | end () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
const_iterator | constEnd () const |
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last item in the array. | |
const_iterator | cend () const |
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last item in the array. | |
iterator | insert (iterator before, const QJsonValue &value) |
Inserts value before the position pointed to by before, and returns an iterator pointing to the newly inserted item. | |
iterator | erase (iterator it) |
Removes the item pointed to by it, and returns an iterator pointing to the next item. | |
QJsonArray | operator+ (const QJsonValue &v) const |
Returns an array that contains all the items in this array followed by the provided value. | |
QJsonArray & | operator+= (const QJsonValue &v) |
Appends value to the array, and returns a reference to the array itself. | |
QJsonArray & | operator<< (const QJsonValue &v) |
Appends value to the array, and returns a reference to the array itself. | |
void | push_back (const QJsonValue &t) |
This function is provided for STL compatibility. | |
void | push_front (const QJsonValue &t) |
This function is provided for STL compatibility. | |
void | pop_front () |
This function is provided for STL compatibility. | |
void | pop_back () |
This function is provided for STL compatibility. | |
bool | empty () const |
This function is provided for STL compatibility. | |
Static Public Member Functions | |
static QJsonArray | fromStringList (const QStringList &list) |
Converts the string list list to a QJsonArray. | |
static QJsonArray | fromVariantList (const QVariantList &list) |
Converts the variant list list to a QJsonArray. | |
Friends | |
class | iterator |
class | const_iterator |
class | QJsonValue |
class | QJsonValueConstRef |
class | QJsonValueRef |
class | QJsonPrivate::Value |
class | QJsonDocument |
class | QCborArray |
Q_CORE_EXPORT QDebug | operator<< (QDebug dbg, const QJsonArray &a) |
Q_CORE_EXPORT bool | comparesEqual (const QJsonArray &lhs, const QJsonArray &rhs) |
Q_CORE_EXPORT bool | comparesEqual (const QJsonArray &lhs, const QJsonValue &rhs) |
\inmodule QtCore
\reentrant
The QJsonArray class encapsulates a JSON array.
\compares equality \compareswith equality QJsonValue \endcompareswith
A JSON array is a list of values. The list can be manipulated by inserting and removing QJsonValue's from the array.
A QJsonArray can be converted to and from a QVariantList. You can query the number of entries with size(), insert(), and removeAt() entries from it and iterate over its content using the standard C++ iterator pattern.
QJsonArray is an implicitly shared class and shares the data with the document it has been created from as long as it is not being modified.
You can convert the array to and from text based JSON through QJsonDocument.
Definition at line 17 of file qjsonarray.h.
Typedef for const QJsonValue *.
Provided for STL compatibility.
Definition at line 290 of file qjsonarray.h.
Typedef for const QJsonValue &.
Provided for STL compatibility.
Definition at line 292 of file qjsonarray.h.
Qt-style synonym for QJsonArray::const_iterator.
Definition at line 271 of file qjsonarray.h.
Qt-style synonym for QJsonArray::iterator.
Definition at line 270 of file qjsonarray.h.
Typedef for QJsonValue *.
Provided for STL compatibility.
Definition at line 289 of file qjsonarray.h.
Typedef for QJsonValue &.
Provided for STL compatibility.
Definition at line 291 of file qjsonarray.h.
Typedef for QJsonValue.
Provided for STL compatibility.
Definition at line 288 of file qjsonarray.h.
|
default |
Creates an empty array.
QJsonArray::QJsonArray | ( | std::initializer_list< QJsonValue > | args | ) |
QJsonArray can be constructed in a way similar to JSON notation, for example:
Definition at line 134 of file qjsonarray.cpp.
|
default |
Deletes the array.
|
defaultnoexcept |
Creates a copy of other.
Since QJsonArray is implicitly shared, the copy is shallow as long as the object doesn't get modified.
|
noexcept |
void QJsonArray::append | ( | const QJsonValue & | value | ) |
Inserts value at the end of the array.
Definition at line 326 of file qjsonarray.cpp.
QJsonValue QJsonArray::at | ( | qsizetype | i | ) | const |
Returns a QJsonValue representing the value for index i.
The returned QJsonValue is Undefined
, if i is out of bounds.
Definition at line 277 of file qjsonarray.cpp.
|
inline |
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the first item in the array.
Definition at line 256 of file qjsonarray.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 257 of file qjsonarray.h.
|
inline |
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the array.
Definition at line 259 of file qjsonarray.h.
|
inline |
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last item in the array.
Definition at line 263 of file qjsonarray.h.
|
inline |
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the array.
Definition at line 258 of file qjsonarray.h.
|
inline |
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last item in the array.
Definition at line 262 of file qjsonarray.h.
bool QJsonArray::contains | ( | const QJsonValue & | value | ) | const |
Returns true
if the array contains an occurrence of value, otherwise false
.
Definition at line 439 of file qjsonarray.cpp.
|
inline |
|
inline |
This function is provided for STL compatibility.
It is equivalent to isEmpty() and returns true
if the array is empty.
Definition at line 286 of file qjsonarray.h.
|
inline |
Returns an \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the last item in the array.
Definition at line 260 of file qjsonarray.h.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 261 of file qjsonarray.h.
Removes the item pointed to by it, and returns an iterator pointing to the next item.
Definition at line 266 of file qjsonarray.h.
QJsonValue QJsonArray::first | ( | ) | const |
Returns the first value stored in the array.
Same as at(0)
.
Definition at line 292 of file qjsonarray.cpp.
|
static |
Converts the string list list to a QJsonArray.
The values in list will be converted to JSON values.
Definition at line 209 of file qjsonarray.cpp.
|
static |
Converts the variant list list to a QJsonArray.
The QVariant values in list will be converted to JSON values.
Definition at line 228 of file qjsonarray.cpp.
|
inline |
Inserts value before the position pointed to by before, and returns an iterator pointing to the newly inserted item.
Definition at line 264 of file qjsonarray.h.
void QJsonArray::insert | ( | qsizetype | i, |
const QJsonValue & | value ) |
Inserts value at index position i in the array.
If i is 0
, the value is prepended to the array. If i is size(), the value is appended to the array.
Definition at line 391 of file qjsonarray.cpp.
bool QJsonArray::isEmpty | ( | ) | const |
Returns true
if the object is empty.
This is the same as size() == 0.
Definition at line 266 of file qjsonarray.cpp.
QJsonValue QJsonArray::last | ( | ) | const |
Returns the last value stored in the array.
Same as {at(size() - 1)}.
Definition at line 304 of file qjsonarray.cpp.
|
inline |
Returns an array that contains all the items in this array followed by the provided value.
Definition at line 274 of file qjsonarray.h.
|
inline |
Appends value to the array, and returns a reference to the array itself.
Definition at line 276 of file qjsonarray.h.
|
inline |
Appends value to the array, and returns a reference to the array itself.
Definition at line 278 of file qjsonarray.h.
|
defaultnoexcept |
Assigns other to this array.
|
inlinenoexcept |
QJsonValueRef QJsonArray::operator[] | ( | qsizetype | i | ) |
Returns the value at index position i as a modifiable reference.
i must be a valid index position in the array (i.e., {0 <= i < size()}).
The return value is of type QJsonValueRef, a helper class for QJsonArray and QJsonObject. When you get an object of type QJsonValueRef, you can use it as if it were a reference to a QJsonValue. If you assign to it, the assignment will apply to the character in the QJsonArray of QJsonObject from which you got the reference.
Definition at line 461 of file qjsonarray.cpp.
QJsonValue QJsonArray::operator[] | ( | qsizetype | i | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Same as at().
Definition at line 472 of file qjsonarray.cpp.
|
inline |
This function is provided for STL compatibility.
It is equivalent to removeLast(). The array must not be empty. If the array can be empty, call isEmpty() before calling this function.
Definition at line 285 of file qjsonarray.h.
|
inline |
This function is provided for STL compatibility.
It is equivalent to removeFirst(). The array must not be empty. If the array can be empty, call isEmpty() before calling this function.
Definition at line 284 of file qjsonarray.h.
void QJsonArray::prepend | ( | const QJsonValue & | value | ) |
Inserts value at the beginning of the array.
This is the same as {insert(0, value)} and will prepend value to the array.
Definition at line 316 of file qjsonarray.cpp.
|
inline |
This function is provided for STL compatibility.
It is equivalent to \l{QJsonArray::append()}{append(value)} and will append value to the array.
Definition at line 282 of file qjsonarray.h.
|
inline |
This function is provided for STL compatibility.
It is equivalent to \l{QJsonArray::prepend()}{prepend(value)} and will prepend value to the array.
Definition at line 283 of file qjsonarray.h.
Removes the value at index position i.
i must be a valid index position in the array (i.e., {0 <= i < size()}).
Definition at line 337 of file qjsonarray.cpp.
|
inline |
Removes the first item in the array.
Calling this function is equivalent to calling {removeAt(0)}. The array must not be empty. If the array can be empty, call isEmpty() before calling this function.
Definition at line 53 of file qjsonarray.h.
|
inline |
Removes the last item in the array.
Calling this function is equivalent to calling {removeAt(size() - 1)}. The array must not be empty. If the array can be empty, call isEmpty() before calling this function.
Definition at line 54 of file qjsonarray.h.
void QJsonArray::replace | ( | qsizetype | i, |
const QJsonValue & | value ) |
Replaces the item at index position i with value.
i must be a valid index position in the array (i.e., {0 <= i < size()}).
Definition at line 427 of file qjsonarray.cpp.
qsizetype QJsonArray::size | ( | ) | const |
Returns the number of values stored in the array.
Definition at line 248 of file qjsonarray.cpp.
|
inlinenoexcept |
Definition at line 67 of file qjsonarray.h.
QJsonValue QJsonArray::takeAt | ( | qsizetype | i | ) |
Removes the item at index position i and returns it.
i must be a valid index position in the array (i.e., {0 <= i < size()}).
If you don't use the return value, removeAt() is more efficient.
Definition at line 373 of file qjsonarray.cpp.
QVariantList QJsonArray::toVariantList | ( | ) | const |
Converts this object to a QVariantList.
Returns the created map.
Definition at line 238 of file qjsonarray.cpp.
|
friend |
Definition at line 477 of file qjsonarray.cpp.
|
friend |
Definition at line 496 of file qjsonarray.cpp.
|
friend |
Definition at line 253 of file qjsonarray.h.
|
friend |
Definition at line 178 of file qjsonarray.h.
|
friend |
Definition at line 1077 of file qjsonarray.cpp.
|
friend |
Definition at line 301 of file qjsonarray.h.
|
friend |
Definition at line 300 of file qjsonarray.h.
|
friend |
Definition at line 299 of file qjsonarray.h.
|
friend |
Definition at line 296 of file qjsonarray.h.
|
friend |
Definition at line 297 of file qjsonarray.h.
|
friend |
Definition at line 298 of file qjsonarray.h.