-
Notifications
You must be signed in to change notification settings - Fork 0
/
QJsonArray.h
132 lines (108 loc) · 3.59 KB
/
QJsonArray.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
Copyright (C) 2014 - 2014 Evan Teran
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef QJSON_ARRAY_H_
#define QJSON_ARRAY_H_
#include <QtCore/QtGlobal>
#if QT_VERSION >= 0x050000
#include <QtCore/QJsonArray>
#else
#include "QJsonRoot.h"
#include <QtCore/QList>
#include <QtCore/QVariantList>
class QJsonValue;
class QJsonValueRef;
class QJsonArray : public QJsonRoot {
friend class QJsonDocument;
friend class QJsonValue;
friend class QJsonValueRef;
friend class QJsonParser;
public:
// TODO: manually implement the array, for now we use QList
// but the real thing has a custom implementation
// I guess for the purposes of less interdependancies?
// maybe so it's easier to forward declare the iterators?
typedef QList<QJsonValue>::const_iterator const_iterator;
typedef QList<QJsonValue>::iterator iterator;
typedef const_iterator ConstIterator;
typedef iterator Iterator;
typedef QList<QJsonValue>::const_pointer const_pointer;
typedef QList<QJsonValue>::const_reference const_reference;
typedef QList<QJsonValue>::difference_type difference_type;
typedef QList<QJsonValue>::pointer pointer;
typedef QList<QJsonValue>::reference reference;
typedef QList<QJsonValue>::size_type size_type;
typedef QList<QJsonValue>::value_type value_type;
public:
QJsonArray();
QJsonArray(const QJsonArray &other);
~QJsonArray();
public:
QJsonArray &operator=(const QJsonArray &other);
public:
bool operator!=(const QJsonArray &other) const;
bool operator==(const QJsonArray &other) const;
public:
const_iterator begin() const;
const_iterator end() const;
iterator begin();
iterator end();
const_iterator constBegin() const;
const_iterator constEnd() const;
public:
QJsonValueRef operator[](int i);
QJsonValue operator[](int i) const;
QJsonValue at(int i) const;
QJsonValue first() const;
QJsonValue last() const;
public:
int size() const;
int count() const;
bool empty() const;
bool isEmpty() const;
public:
void pop_back();
void pop_front();
void push_back(const QJsonValue &value);
void push_front(const QJsonValue &value);
public:
void append(const QJsonValue &value);
bool contains(const QJsonValue &value) const;
iterator erase(iterator it);
void insert(int i, const QJsonValue &value);
iterator insert(iterator before, const QJsonValue &value);
void prepend(const QJsonValue &value);
void removeAt(int i);
void removeFirst();
void removeLast();
void replace(int i, const QJsonValue &value);
QJsonValue takeAt(int i);
public:
QVariantList toVariantList() const;
public:
static QJsonArray fromStringList(const QStringList &list);
static QJsonArray fromVariantList(const QVariantList &list);
private:
virtual QJsonRoot *clone() const;
virtual QJsonArray *toArray();
virtual QJsonObject *toObject();
virtual const QJsonArray *toArray() const;
virtual const QJsonObject *toObject() const;
private:
void swap(QJsonArray &other);
private:
QList<QJsonValue> values_;
};
#endif
#endif