Struct qt_core::QJsonArray

source ·
#[repr(C)]
pub struct QJsonArray { /* private fields */ }
Expand description

The QJsonArray class encapsulates a JSON array.

C++ class: QJsonArray.

C++ documentation:

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

source

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

C++ documentation:

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

source

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

C++ documentation:

Inserts value at the end of the array.

See also prepend() and insert().

source

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.

C++ documentation:

Returns a QJsonValue representing the value for index i.

The returned QJsonValue is Undefined, if i is out of bounds.

source

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

C++ documentation:

Returns an STL-style iterator pointing to the first item in the array.

See also constBegin() and end().

source

pub unsafe fn begin(&self) -> CppBox<ConstIterator>

This is an overloaded function.

Calls C++ function: QJsonArray::const_iterator QJsonArray::begin() const.

C++ documentation:

This is an overloaded function.

source

pub unsafe fn cbegin(&self) -> CppBox<ConstIterator>

Available on 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.

C++ documentation:

Returns a const STL-style iterator pointing to the first item in the array.

See also begin() and cend().

source

pub unsafe fn cend(&self) -> CppBox<ConstIterator>

Available on 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.

C++ documentation:

Returns a const STL-style iterator pointing to the imaginary item after the last item in the array.

See also cbegin() and end().

source

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.

C++ documentation:

Returns a const STL-style iterator pointing to the first item in the array.

See also begin() and constEnd().

source

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.

C++ documentation:

Returns a const STL-style iterator pointing to the imaginary item after the last item in the array.

See also constBegin() and end().

source

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.

C++ documentation:

Returns true if the array contains an occurrence of value, otherwise false.

See also count().

source

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

C++ documentation:

Assigns other to this array.

source

pub unsafe fn count(&self) -> c_int

Same as size().

Calls C++ function: int QJsonArray::count() const.

C++ documentation:

Same as size().

See also size().

source

pub unsafe fn empty(&self) -> bool

This function is provided for STL compatibility. It is equivalent to isEmpty() and returns true if the array is empty.

Calls C++ function: bool QJsonArray::empty() const.

C++ documentation:

This function is provided for STL compatibility. It is equivalent to isEmpty() and returns true if the array is empty.

source

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

C++ documentation:

Returns an STL-style iterator pointing to the imaginary item after the last item in the array.

See also begin() and constEnd().

source

pub unsafe fn end(&self) -> CppBox<ConstIterator>

This is an overloaded function.

Calls C++ function: QJsonArray::const_iterator QJsonArray::end() const.

C++ documentation:

This is an overloaded function.

source

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

C++ documentation:

Removes the item pointed to by it, and returns an iterator pointing to the next item.

See also removeAt().

source

pub unsafe fn first(&self) -> CppBox<QJsonValue>

Returns the first value stored in the array.

Calls C++ function: QJsonValue QJsonArray::first() const.

C++ documentation:

Returns the first value stored in the array.

Same as at(0).

See also at().

source

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

C++ documentation:

Converts the string list list to a QJsonArray.

The values in list will be converted to JSON values.

See also toVariantList() and QJsonValue::fromVariant().

source

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

C++ documentation:

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

source

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

C++ documentation:

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

source

pub unsafe fn index(&self, i: c_int) -> CppBox<QJsonValue>

This is an overloaded function.

Calls C++ function: QJsonValue QJsonArray::operator[](int i) const.

C++ documentation:

This is an overloaded function.

Same as at().

source

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

C++ documentation:

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.

See also append(), prepend(), replace(), and removeAt().

source

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

C++ documentation:

Inserts value before the position pointed to by before, and returns an iterator pointing to the newly inserted item.

See also erase() and insert().

source

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.

C++ documentation:

Returns true if the object is empty. This is the same as size() == 0.

See also size().

source

pub unsafe fn last(&self) -> CppBox<QJsonValue>

Returns the last value stored in the array.

Calls C++ function: QJsonValue QJsonArray::last() const.

C++ documentation:

Returns the last value stored in the array.

Same as at(size() - 1).

See also at().

source

pub unsafe fn new() -> CppBox<QJsonArray>

Creates an empty array.

Calls C++ function: [constructor] void QJsonArray::QJsonArray().

C++ documentation:

Creates an empty array.

source

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

C++ documentation:

Creates a copy of other.

Since QJsonArray is implicitly shared, the copy is shallow as long as the object doesn't get modified.

source

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

C++ documentation:

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.

source

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

C++ documentation:

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.

source

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

C++ documentation:

Inserts value at the beginning of the array.

This is the same as insert(0, value) and will prepend value to the array.

See also append() and insert().

source

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

C++ documentation:

This function is provided for STL compatibility. It is equivalent to append(value) and will append value to the array.

source

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

C++ documentation:

This function is provided for STL compatibility. It is equivalent to prepend(value) and will prepend value to the array.

source

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

C++ documentation:

Removes the value at index position i. i must be a valid index position in the array (i.e., 0 <= i < size()).

See also insert() and replace().

source

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

C++ documentation:

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

source

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

C++ documentation:

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

source

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

C++ documentation:

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

source

pub unsafe fn size(&self) -> c_int

Returns the number of values stored in the array.

Calls C++ function: int QJsonArray::size() const.

C++ documentation:

Returns the number of values stored in the array.

source

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

Swaps the array other with this. This operation is very fast and never fails.

Calls C++ function: void QJsonArray::swap(QJsonArray& other).

C++ documentation:

Swaps the array other with this. This operation is very fast and never fails.

This function was introduced in Qt 5.10.

source

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

C++ documentation:

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.

See also removeAt().

source

pub unsafe fn to_variant_list(&self) -> CppBox<QListOfQVariant>

Converts this object to a QVariantList.

Calls C++ function: QList<QVariant> QJsonArray::toVariantList() const.

C++ documentation:

Converts this object to a QVariantList.

Returns the created map.

Trait Implementations§

source§

impl Add<Ref<QJsonValue>> for &QJsonArray

source§

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.

C++ documentation:

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

§

type Output = CppBox<QJsonArray>

The resulting type after applying the + operator.
source§

impl Begin for QJsonArray

source§

unsafe fn begin(&self) -> CppBox<ConstIterator>

This is an overloaded function.

Calls C++ function: QJsonArray::const_iterator QJsonArray::begin() const.

C++ documentation:

This is an overloaded function.

§

type Output = CppBox<ConstIterator>

Output type.
source§

impl BeginMut for QJsonArray

source§

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

C++ documentation:

Returns an STL-style iterator pointing to the first item in the array.

See also constBegin() and end().

§

type Output = CppBox<Iterator>

Output type.
source§

impl CppDeletable for QJsonArray

source§

unsafe fn delete(&self)

Deletes the array.

Calls C++ function: [destructor] void QJsonArray::~QJsonArray().

C++ documentation:

Deletes the array.

source§

impl End for QJsonArray

source§

unsafe fn end(&self) -> CppBox<ConstIterator>

This is an overloaded function.

Calls C++ function: QJsonArray::const_iterator QJsonArray::end() const.

C++ documentation:

This is an overloaded function.

§

type Output = CppBox<ConstIterator>

Output type.
source§

impl EndMut for QJsonArray

source§

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

C++ documentation:

Returns an STL-style iterator pointing to the imaginary item after the last item in the array.

See also begin() and constEnd().

§

type Output = CppBox<Iterator>

Output type.
source§

impl PartialEq<Ref<QJsonArray>> for QJsonArray

source§

fn eq(&self, other: &Ref<QJsonArray>) -> bool

Returns true if this array is equal to other.

Calls C++ function: bool QJsonArray::operator==(const QJsonArray& other) const.

C++ documentation:

Returns true if this array is equal to other.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Shl<Ref<QJsonValue>> for &QJsonArray

source§

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

C++ documentation:

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

§

type Output = Ref<QJsonArray>

The resulting type after applying the << operator.
source§

impl Size for QJsonArray

source§

unsafe fn size(&self) -> usize

Returns the number of values stored in the array.

Calls C++ function: int QJsonArray::size() const.

C++ documentation:

Returns the number of values stored in the array.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.