Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QJsonArray Class

The QJsonArray class encapsulates a JSON array. More...

 #include <QJsonArray>

Note: All functions in this class are reentrant.

This class was introduced in Qt 5.0.

Public Types

class const_iterator
class iterator
typedef ConstIterator
typedef Iterator
typedef const_pointer
typedef const_reference
typedef difference_type
typedef pointer
typedef reference
typedef size_type
typedef value_type

Public Functions

QJsonArray()
QJsonArray(const QJsonArray & other)
~QJsonArray()
void append(const QJsonValue & value)
QJsonValue at(int i) const
iterator begin()
const_iterator begin() const
const_iterator constBegin() const
const_iterator constEnd() const
bool contains(const QJsonValue & value) const
int count() const
bool empty() const
iterator end()
const_iterator end() const
iterator erase(iterator pos)
QJsonValue first() const
void insert(int i, const QJsonValue & value)
iterator insert(iterator before, const QJsonValue & value)
bool isEmpty() const
QJsonValue last() const
void pop_back()
void pop_front()
void prepend(const QJsonValue & value)
void push_back(const QJsonValue & value)
void push_front(const QJsonValue & value)
void removeAt(int i)
void removeFirst()
void removeLast()
void replace(int i, const QJsonValue & value)
int size() const
QJsonValue takeAt(int i)
QVariantList toVariantList() const
bool operator!=(const QJsonArray & other) const
QJsonArray & operator=(const QJsonArray & other)
bool operator==(const QJsonArray & other) const
QJsonValueRef operator[](int i)
QJsonValue operator[](int i) const

Static Public Members

QJsonArray fromStringList(const QStringList & list)
QJsonArray fromVariantList(const QVariantList & list)

Detailed Description

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

Member Type Documentation

typedef QJsonArray::ConstIterator

typedef QJsonArray::Iterator

typedef QJsonArray::const_pointer

typedef QJsonArray::const_reference

typedef QJsonArray::difference_type

typedef QJsonArray::pointer

typedef QJsonArray::reference

typedef QJsonArray::size_type

typedef QJsonArray::value_type

Member Function Documentation

QJsonArray::QJsonArray()

Creates an empty array.

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.

QJsonArray::~QJsonArray()

Deletes the array.

void QJsonArray::append(const QJsonValue & value)

Inserts value at the end of the array.

See also prepend() and insert().

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.

iterator QJsonArray::begin()

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

See also constBegin() and end().

const_iterator QJsonArray::begin() const

This is an overloaded function.

const_iterator QJsonArray::constBegin() const

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

See also begin() and constEnd().

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

bool QJsonArray::contains(const QJsonValue & value) const

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

See also count().

int QJsonArray::count() const

bool QJsonArray::empty() const

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

iterator QJsonArray::end()

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

See also begin() and constEnd().

const_iterator QJsonArray::end() const

This is an overloaded function.

iterator QJsonArray::erase(iterator pos)

QJsonValue QJsonArray::first() const

Returns the first value stored in the array.

Same as at(0).

See also at.

QJsonArray QJsonArray::fromStringList(const QStringList & list) [static]

Converts the string list list to a QJsonArray.

The values in list will be converted to JSON values.

See also toVariantList and QJsonValue::fromString.

QJsonArray QJsonArray::fromVariantList(const QVariantList & list) [static]

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.

void QJsonArray::insert(int 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.

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

iterator QJsonArray::insert(iterator before, const QJsonValue & value)

bool QJsonArray::isEmpty() const

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

See also size.

QJsonValue QJsonArray::last() const

Returns the last value stored in the array.

Same as at(size() - 1).

See also at.

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.

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.

void QJsonArray::prepend(const QJsonValue & value)

Inserts value at the beginning of the array.

This is the same as insert(0, \a value).

See also append() and insert().

void QJsonArray::push_back(const QJsonValue & value)

This function is provided for STL compatibility. It is equivalent to append(value).

void QJsonArray::push_front(const QJsonValue & value)

This function is provided for STL compatibility. It is equivalent to prepend(value).

void QJsonArray::removeAt(int i)

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

See also insert() and replace().

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

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

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 <= \a i < size()).

See also operator[]() and removeAt().

int QJsonArray::size() const

Returns the number of values stored in the array.

QJsonValue QJsonArray::takeAt(int i)

Removes the item at index position i and returns it. i must be a valid index position in the array (i.e., 0 <= \a i < size()).

If you don't use the return value, removeAt() is more efficient.

See also removeAt().

QVariantList QJsonArray::toVariantList() const

Converts this object to a QVariantList.

Returns the created map.

bool QJsonArray::operator!=(const QJsonArray & other) const

Returns true if this array is not equal to other.

QJsonArray & QJsonArray::operator=(const QJsonArray & other)

Assigns other to this array.

bool QJsonArray::operator==(const QJsonArray & other) const

Returns true if this array is equal to other.

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 <= \a 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() and value().

QJsonValue QJsonArray::operator[](int i) const

This is an overloaded function.

Same as at().

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web