#[repr(C)]pub struct QJsonArray { /* private fields */ }
Expand description
The QJsonArray class encapsulates a JSON array.
C++ class: QJsonArray
.
The QJsonArray class encapsulates a JSON array.
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.
Implementations§
Source§impl QJsonArray
impl QJsonArray
Sourcepub unsafe fn add_assign(
&self,
v: impl CastInto<Ref<QJsonValue>>,
) -> Ref<QJsonArray>
pub unsafe fn add_assign( &self, v: impl CastInto<Ref<QJsonValue>>, ) -> Ref<QJsonArray>
Appends value to the array, and returns a reference to the array itself.
Calls C++ function: QJsonArray& QJsonArray::operator+=(const QJsonValue& v)
.
Appends value to the array, and returns a reference to the array itself.
This function was introduced in Qt 5.3.
See also append() and operator<<().
Sourcepub unsafe fn append(&self, value: impl CastInto<Ref<QJsonValue>>)
pub unsafe fn append(&self, value: impl CastInto<Ref<QJsonValue>>)
Inserts value at the end of the array.
Calls C++ function: void QJsonArray::append(const QJsonValue& value)
.
Sourcepub unsafe fn at(&self, i: c_int) -> CppBox<QJsonValue>
pub unsafe fn at(&self, i: c_int) -> CppBox<QJsonValue>
Returns a QJsonValue representing the value for index i.
Calls C++ function: QJsonValue QJsonArray::at(int i) const
.
Returns a QJsonValue representing the value for index i.
The returned QJsonValue is Undefined
, if i is out of bounds.
Sourcepub unsafe fn begin_mut(&self) -> CppBox<Iterator>
pub unsafe fn begin_mut(&self) -> CppBox<Iterator>
Returns an STL-style iterator pointing to the first item in the array.
Calls C++ function: QJsonArray::iterator QJsonArray::begin()
.
Returns an STL-style iterator pointing to the first item in the array.
See also constBegin() and end().
Sourcepub unsafe fn begin(&self) -> CppBox<ConstIterator>
pub unsafe fn begin(&self) -> CppBox<ConstIterator>
This is an overloaded function.
Calls C++ function: QJsonArray::const_iterator QJsonArray::begin() const
.
This is an overloaded function.
Sourcepub unsafe fn cbegin(&self) -> CppBox<ConstIterator>
Available on cpp_lib_version="5.13.0"
or cpp_lib_version="5.14.0"
only.
pub unsafe fn cbegin(&self) -> CppBox<ConstIterator>
cpp_lib_version="5.13.0"
or cpp_lib_version="5.14.0"
only.Returns a const STL-style iterator pointing to the first item in the array.
Calls C++ function: QJsonArray::const_iterator QJsonArray::cbegin() const
.
Returns a const STL-style iterator pointing to the first item in the array.
Sourcepub unsafe fn cend(&self) -> CppBox<ConstIterator>
Available on cpp_lib_version="5.13.0"
or cpp_lib_version="5.14.0"
only.
pub unsafe fn cend(&self) -> CppBox<ConstIterator>
cpp_lib_version="5.13.0"
or cpp_lib_version="5.14.0"
only.Returns a const STL-style iterator pointing to the imaginary item after the last item in the array.
Calls C++ function: QJsonArray::const_iterator QJsonArray::cend() const
.
Returns a const STL-style iterator pointing to the imaginary item after the last item in the array.
Sourcepub unsafe fn const_begin(&self) -> CppBox<ConstIterator>
pub unsafe fn const_begin(&self) -> CppBox<ConstIterator>
Returns a const STL-style iterator pointing to the first item in the array.
Calls C++ function: QJsonArray::const_iterator QJsonArray::constBegin() const
.
Returns a const STL-style iterator pointing to the first item in the array.
Sourcepub unsafe fn const_end(&self) -> CppBox<ConstIterator>
pub unsafe fn const_end(&self) -> CppBox<ConstIterator>
Returns a const STL-style iterator pointing to the imaginary item after the last item in the array.
Calls C++ function: QJsonArray::const_iterator QJsonArray::constEnd() const
.
Returns a const STL-style iterator pointing to the imaginary item after the last item in the array.
See also constBegin() and end().
Sourcepub unsafe fn contains(&self, element: impl CastInto<Ref<QJsonValue>>) -> bool
pub unsafe fn contains(&self, element: impl CastInto<Ref<QJsonValue>>) -> bool
Returns true
if the array contains an occurrence of value, otherwise false
.
Calls C++ function: bool QJsonArray::contains(const QJsonValue& element) const
.
Returns true
if the array contains an occurrence of value, otherwise false
.
See also count().
Sourcepub unsafe fn copy_from(
&self,
other: impl CastInto<Ref<QJsonArray>>,
) -> Ref<QJsonArray>
pub unsafe fn copy_from( &self, other: impl CastInto<Ref<QJsonArray>>, ) -> Ref<QJsonArray>
Assigns other to this array.
Calls C++ function: QJsonArray& QJsonArray::operator=(const QJsonArray& other)
.
Assigns other to this array.
Sourcepub unsafe fn count(&self) -> c_int
pub unsafe fn count(&self) -> c_int
Same as size().
Calls C++ function: int QJsonArray::count() const
.
Sourcepub unsafe fn empty(&self) -> bool
pub unsafe fn empty(&self) -> bool
Sourcepub unsafe fn end_mut(&self) -> CppBox<Iterator>
pub unsafe fn end_mut(&self) -> CppBox<Iterator>
Returns an STL-style iterator pointing to the imaginary item after the last item in the array.
Calls C++ function: QJsonArray::iterator QJsonArray::end()
.
Returns an STL-style iterator pointing to the imaginary item after the last item in the array.
Sourcepub unsafe fn end(&self) -> CppBox<ConstIterator>
pub unsafe fn end(&self) -> CppBox<ConstIterator>
This is an overloaded function.
Calls C++ function: QJsonArray::const_iterator QJsonArray::end() const
.
This is an overloaded function.
Sourcepub unsafe fn erase(&self, it: impl CastInto<Ref<Iterator>>) -> CppBox<Iterator>
pub unsafe fn erase(&self, it: impl CastInto<Ref<Iterator>>) -> CppBox<Iterator>
Removes the item pointed to by it, and returns an iterator pointing to the next item.
Calls C++ function: QJsonArray::iterator QJsonArray::erase(QJsonArray::iterator it)
.
Removes the item pointed to by it, and returns an iterator pointing to the next item.
See also removeAt().
Sourcepub unsafe fn first(&self) -> CppBox<QJsonValue>
pub unsafe fn first(&self) -> CppBox<QJsonValue>
Returns the first value stored in the array.
Calls C++ function: QJsonValue QJsonArray::first() const
.
Sourcepub unsafe fn from_string_list(
list: impl CastInto<Ref<QStringList>>,
) -> CppBox<QJsonArray>
pub unsafe fn from_string_list( list: impl CastInto<Ref<QStringList>>, ) -> CppBox<QJsonArray>
Converts the string list list to a QJsonArray.
Calls C++ function: static QJsonArray QJsonArray::fromStringList(const QStringList& list)
.
Converts the string list list to a QJsonArray.
The values in list will be converted to JSON values.
See also toVariantList() and QJsonValue::fromVariant().
Sourcepub unsafe fn from_variant_list(
list: impl CastInto<Ref<QListOfQVariant>>,
) -> CppBox<QJsonArray>
pub unsafe fn from_variant_list( list: impl CastInto<Ref<QListOfQVariant>>, ) -> CppBox<QJsonArray>
Converts the variant list list to a QJsonArray.
Calls C++ function: static QJsonArray QJsonArray::fromVariantList(const QList<QVariant>& list)
.
Converts the variant list list to a QJsonArray.
The QVariant values in list will be converted to JSON values.
See also toVariantList() and QJsonValue::fromVariant().
Sourcepub unsafe fn index_mut(&self, i: c_int) -> CppBox<QJsonValueRef>
pub unsafe fn index_mut(&self, i: c_int) -> CppBox<QJsonValueRef>
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()
).
Calls C++ function: QJsonValueRef QJsonArray::operator[](int 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.
See also at().
Sourcepub unsafe fn index(&self, i: c_int) -> CppBox<QJsonValue>
pub unsafe fn index(&self, i: c_int) -> CppBox<QJsonValue>
This is an overloaded function.
Calls C++ function: QJsonValue QJsonArray::operator[](int i) const
.
This is an overloaded function.
Same as at().
Sourcepub unsafe fn insert_int_q_json_value(
&self,
i: c_int,
value: impl CastInto<Ref<QJsonValue>>,
)
pub unsafe fn insert_int_q_json_value( &self, i: c_int, value: impl CastInto<Ref<QJsonValue>>, )
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.
Calls C++ function: void QJsonArray::insert(int i, const QJsonValue& value)
.
Sourcepub unsafe fn insert_iterator_q_json_value(
&self,
before: impl CastInto<Ref<Iterator>>,
value: impl CastInto<Ref<QJsonValue>>,
) -> CppBox<Iterator>
pub unsafe fn insert_iterator_q_json_value( &self, before: impl CastInto<Ref<Iterator>>, value: impl CastInto<Ref<QJsonValue>>, ) -> CppBox<Iterator>
Inserts value before the position pointed to by before, and returns an iterator pointing to the newly inserted item.
Calls C++ function: QJsonArray::iterator QJsonArray::insert(QJsonArray::iterator before, const QJsonValue& value)
.
Sourcepub unsafe fn is_empty(&self) -> bool
pub unsafe fn is_empty(&self) -> bool
Returns true
if the object is empty. This is the same as size() == 0.
Calls C++ function: bool QJsonArray::isEmpty() const
.
Sourcepub unsafe fn last(&self) -> CppBox<QJsonValue>
pub unsafe fn last(&self) -> CppBox<QJsonValue>
Returns the last value stored in the array.
Calls C++ function: QJsonValue QJsonArray::last() const
.
Sourcepub unsafe fn new() -> CppBox<QJsonArray>
pub unsafe fn new() -> CppBox<QJsonArray>
Creates an empty array.
Calls C++ function: [constructor] void QJsonArray::QJsonArray()
.
Creates an empty array.
Sourcepub unsafe fn new_copy(
other: impl CastInto<Ref<QJsonArray>>,
) -> CppBox<QJsonArray>
pub unsafe fn new_copy( other: impl CastInto<Ref<QJsonArray>>, ) -> CppBox<QJsonArray>
Creates a copy of other.
Calls C++ function: [constructor] void QJsonArray::QJsonArray(const QJsonArray& other)
.
Creates a copy of other.
Since QJsonArray is implicitly shared, the copy is shallow as long as the object doesn't get modified.
Sourcepub unsafe fn pop_back(&self)
pub unsafe fn pop_back(&self)
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.
Calls C++ function: void QJsonArray::pop_back()
.
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.
Sourcepub unsafe fn pop_front(&self)
pub unsafe fn pop_front(&self)
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.
Calls C++ function: void QJsonArray::pop_front()
.
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.
Sourcepub unsafe fn prepend(&self, value: impl CastInto<Ref<QJsonValue>>)
pub unsafe fn prepend(&self, value: impl CastInto<Ref<QJsonValue>>)
Inserts value at the beginning of the array.
Calls C++ function: void QJsonArray::prepend(const QJsonValue& value)
.
Sourcepub unsafe fn push_back(&self, t: impl CastInto<Ref<QJsonValue>>)
pub unsafe fn push_back(&self, t: impl CastInto<Ref<QJsonValue>>)
This function is provided for STL compatibility. It is equivalent to append(value) and will append value to the array.
Calls C++ function: void QJsonArray::push_back(const QJsonValue& t)
.
This function is provided for STL compatibility. It is equivalent to append(value) and will append value to the array.
Sourcepub unsafe fn push_front(&self, t: impl CastInto<Ref<QJsonValue>>)
pub unsafe fn push_front(&self, t: impl CastInto<Ref<QJsonValue>>)
This function is provided for STL compatibility. It is equivalent to prepend(value) and will prepend value to the array.
Calls C++ function: void QJsonArray::push_front(const QJsonValue& t)
.
This function is provided for STL compatibility. It is equivalent to prepend(value) and will prepend value to the array.
Sourcepub unsafe fn remove_at(&self, i: c_int)
pub unsafe fn remove_at(&self, i: c_int)
Removes the value at index position i. i must be a valid index position in the array (i.e., 0 <= i < size()
).
Calls C++ function: void QJsonArray::removeAt(int i)
.
Sourcepub unsafe fn remove_first(&self)
pub unsafe fn remove_first(&self)
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.
Calls C++ function: void QJsonArray::removeFirst()
.
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.
See also removeAt() and removeLast().
Sourcepub unsafe fn remove_last(&self)
pub unsafe fn remove_last(&self)
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.
Calls C++ function: void QJsonArray::removeLast()
.
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.
See also removeAt() and removeFirst().
Sourcepub unsafe fn replace(&self, i: c_int, value: impl CastInto<Ref<QJsonValue>>)
pub unsafe fn replace(&self, i: c_int, value: impl CastInto<Ref<QJsonValue>>)
Replaces the item at index position i with value. i must be a valid index position in the array (i.e., 0 <= i < size()
).
Calls C++ function: void QJsonArray::replace(int 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()
).
See also operator[]() and removeAt().
Sourcepub unsafe fn size(&self) -> c_int
pub unsafe fn size(&self) -> c_int
Returns the number of values stored in the array.
Calls C++ function: int QJsonArray::size() const
.
Returns the number of values stored in the array.
Sourcepub unsafe fn swap(&self, other: impl CastInto<Ref<QJsonArray>>)
Available on cpp_lib_version="5.11.3"
or cpp_lib_version="5.12.2"
or cpp_lib_version="5.13.0"
or cpp_lib_version="5.14.0"
only.
pub unsafe fn swap(&self, other: impl CastInto<Ref<QJsonArray>>)
cpp_lib_version="5.11.3"
or cpp_lib_version="5.12.2"
or cpp_lib_version="5.13.0"
or cpp_lib_version="5.14.0"
only.Swaps the array other with this. This operation is very fast and never fails.
Calls C++ function: void QJsonArray::swap(QJsonArray& other)
.
Swaps the array other with this. This operation is very fast and never fails.
This function was introduced in Qt 5.10.
Sourcepub unsafe fn take_at(&self, i: c_int) -> CppBox<QJsonValue>
pub unsafe fn take_at(&self, i: c_int) -> CppBox<QJsonValue>
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()
).
Calls C++ function: QJsonValue QJsonArray::takeAt(int i)
.
Sourcepub unsafe fn to_variant_list(&self) -> CppBox<QListOfQVariant>
pub unsafe fn to_variant_list(&self) -> CppBox<QListOfQVariant>
Converts this object to a QVariantList.
Calls C++ function: QList<QVariant> QJsonArray::toVariantList() const
.
Converts this object to a QVariantList.
Returns the created map.
Trait Implementations§
Source§impl Add<Ref<QJsonValue>> for &QJsonArray
impl Add<Ref<QJsonValue>> for &QJsonArray
Source§fn add(self, v: Ref<QJsonValue>) -> CppBox<QJsonArray>
fn add(self, v: Ref<QJsonValue>) -> CppBox<QJsonArray>
Returns an array that contains all the items in this array followed by the provided value.
Calls C++ function: QJsonArray QJsonArray::operator+(const QJsonValue& v) const
.
Returns an array that contains all the items in this array followed by the provided value.
This function was introduced in Qt 5.3.
See also operator+=().
Source§type Output = CppBox<QJsonArray>
type Output = CppBox<QJsonArray>
+
operator.Source§impl Begin for QJsonArray
impl Begin for QJsonArray
Source§unsafe fn begin(&self) -> CppBox<ConstIterator>
unsafe fn begin(&self) -> CppBox<ConstIterator>
This is an overloaded function.
Calls C++ function: QJsonArray::const_iterator QJsonArray::begin() const
.
This is an overloaded function.
Source§type Output = CppBox<ConstIterator>
type Output = CppBox<ConstIterator>
Source§impl BeginMut for QJsonArray
impl BeginMut for QJsonArray
Source§unsafe fn begin_mut(&self) -> CppBox<Iterator>
unsafe fn begin_mut(&self) -> CppBox<Iterator>
Returns an STL-style iterator pointing to the first item in the array.
Calls C++ function: QJsonArray::iterator QJsonArray::begin()
.
Returns an STL-style iterator pointing to the first item in the array.
See also constBegin() and end().
Source§impl CppDeletable for QJsonArray
impl CppDeletable for QJsonArray
Source§impl End for QJsonArray
impl End for QJsonArray
Source§unsafe fn end(&self) -> CppBox<ConstIterator>
unsafe fn end(&self) -> CppBox<ConstIterator>
This is an overloaded function.
Calls C++ function: QJsonArray::const_iterator QJsonArray::end() const
.
This is an overloaded function.
Source§type Output = CppBox<ConstIterator>
type Output = CppBox<ConstIterator>
Source§impl EndMut for QJsonArray
impl EndMut for QJsonArray
Source§unsafe fn end_mut(&self) -> CppBox<Iterator>
unsafe fn end_mut(&self) -> CppBox<Iterator>
Returns an STL-style iterator pointing to the imaginary item after the last item in the array.
Calls C++ function: QJsonArray::iterator QJsonArray::end()
.
Returns an STL-style iterator pointing to the imaginary item after the last item in the array.
Source§impl PartialEq<Ref<QJsonArray>> for QJsonArray
impl PartialEq<Ref<QJsonArray>> for QJsonArray
Source§impl Shl<Ref<QJsonValue>> for &QJsonArray
impl Shl<Ref<QJsonValue>> for &QJsonArray
Source§fn shl(self, v: Ref<QJsonValue>) -> Ref<QJsonArray>
fn shl(self, v: Ref<QJsonValue>) -> Ref<QJsonArray>
Appends value to the array, and returns a reference to the array itself.
Calls C++ function: QJsonArray& QJsonArray::operator<<(const QJsonValue& v)
.
Appends value to the array, and returns a reference to the array itself.
This function was introduced in Qt 5.3.
See also operator+=() and append().
Source§type Output = Ref<QJsonArray>
type Output = Ref<QJsonArray>
<<
operator.