53 for(
const auto &
value : mList)
55 if(
value->isObject() ==
true)
57 value->toObject()->clear();
61 if(
value->isArray() ==
true)
63 value->toArray()->clear();
68 while(mList.count() > 0)
79 return mList.length();
89 return mList.isEmpty();
99 return mList.contains(value);
104 return mList.indexOf(value);
109 return mList.lastIndexOf(value, from);
114 return mList.endsWith(value);
119 return mList.startsWith(value);
134 if(index < 0) index = 0;
135 if(index > mList.count()) index = mList.count();
137 if(value.isNull() ==
true)
139 auto newValue = QMPointer<QMJsonValue>(
new QMJsonValue);
141 mList.insert(index, newValue);
146 mList.insert(index, value);
153 if(array.isNull() ==
true)
156 for(
const auto &
value : array->values())
173 while(mList.contains(value) ==
true)
174 this->
removeAt(mList.indexOf(value));
179 this->
removeAt(mList.indexOf(value));
184 if(index < 0 || index >= mList.count())
207 return this->
takeAt(mList.count() - 1);
212 if(index < 0 || index >= mList.count())
215 auto value = mList.takeAt(index);
223 if(index < 0 || index >= mList.count())
226 auto value = mList.takeAt(index);
234 static auto defaultValue = QMPointer<QMJsonValue>(
new QMJsonValue);
236 if(mList.isEmpty() ==
true)
239 return mList.front();
244 static auto defaultValue = QMPointer<QMJsonValue>(
new QMJsonValue);
246 if(mList.isEmpty() ==
true)
254 static auto defaultValue = QMPointer<QMJsonValue>(
new QMJsonValue);
256 if(index < 0 || index >= mList.count())
259 return mList.at(index);
262 const QMPointer<QMJsonValue> &
QMJsonArray::value(int32_t index,
const QMPointer<QMJsonValue> &defaultValue)
const 264 if(index < 0 || index >= mList.count())
267 return mList.at(index);
277 if(mList.count() == 0)
278 return QList<QMPointer<QMJsonValue> >();
280 if(pos >= mList.count())
281 return QList<QMPointer<QMJsonValue> >();
285 return mList.mid(pos, length);
290 if(mList.count() == 0)
293 if(to < 0 || to >= mList.count())
return;
294 if(from < 0 || from >= mList.count())
return;
295 if(to == from)
return;
297 mList.move(from, to);
305 if(index >= mList.count())
308 auto removedValue = mList.at(index);
310 if(value.isNull() ==
true)
311 mList.replace(index, QMPointer<QMJsonValue>(
new QMJsonValue));
313 mList.replace(index, value);
321 if(index < 0 || index >= mList.count())
324 return mList.at(index)->isNull();
329 if(index < 0 || index >= mList.count())
332 return mList.at(index)->isBool();
337 if(index < 0 || index >= mList.count())
340 return mList.at(index)->isDouble();
345 if(index < 0 || index >= mList.count())
348 return mList.at(index)->isString();
353 if(index < 0 || index >= mList.count())
356 return mList.at(index)->isArray();
361 if(index < 0 || index >= mList.count())
364 return mList.at(index)->isObject();
369 return this->
value(index)->toBool();
374 return this->
value(index)->toDouble();
379 return this->
value(index)->toString();
384 return this->
value(index)->toArray();
389 return this->
value(index)->toObject();
394 return this->
value(index)->toBool(defaultValue);
399 return this->
value(index)->toDouble(defaultValue);
404 return this->
value(index)->toString(defaultValue);
407 const QMPointer<QMJsonArray> &
QMJsonArray::toArray(int32_t index,
const QMPointer<QMJsonArray> &defaultValue)
const 409 return this->
value(index)->toArray(defaultValue);
412 const QMPointer<QMJsonObject> &
QMJsonArray::toObject(int32_t index,
const QMPointer<QMJsonObject> &defaultValue)
const 414 return this->
value(index)->toObject(defaultValue);
419 return this->
value(index)->fromBool(value);
424 return this->
value(index)->fromDouble(value);
429 return this->
value(index)->fromString(value);
434 return this->
value(index)->fromArray(value);
439 return this->
value(index)->fromObject(value);
444 return this->
value(index)->from(value);
449 QDebugStateSaver saver(dbg);
450 auto started =
false;
452 dbg.nospace() <<
"QMJsonArray[";
454 for(
const auto &value : array.
values())
466 QDebug operator<<(QDebug dbg, const QMPointer<QMJsonArray> &value)
468 if(value.isNull() ==
true)
470 QDebugStateSaver saver(dbg);
472 dbg.nospace() <<
"QMPointer<";
473 dbg <<
"QMJsonArray" <<
">: NULL";
479 return dbg << *value;
virtual void append(const QMPointer< QMJsonValue > &value)
virtual bool isObject(int32_t index) const
virtual QList< QMPointer< QMJsonValue > > mid(int32_t pos, int32_t length=-1) const
virtual double toDouble(int32_t index) const
virtual QMPointer< QMJsonValue > takeAt(int32_t index)
virtual int32_t length(void) const
virtual bool startsWith(const QMPointer< QMJsonValue > &value) const
virtual QMPointer< QMJsonValue > takeLast(void)
virtual void replace(int32_t index, const QMPointer< QMJsonValue > &value)
virtual void removeOne(const QMPointer< QMJsonValue > &value)
void itemRemoved(int32_t index, const QMPointer< QMJsonValue > &value)
virtual int32_t size(void) const
virtual QString toString(int32_t index) const
virtual bool contains(const QMPointer< QMJsonValue > &value) const
virtual void prepend(const QMPointer< QMJsonValue > &value)
virtual void move(int32_t from, int32_t to)
QDebug operator<<(QDebug dbg, const QMJsonArray &array)
virtual void reserve(int32_t alloc)
virtual bool isEmpty(void) const
virtual bool endsWith(const QMPointer< QMJsonValue > &value) const
virtual bool toBool(int32_t index) const
virtual bool fromBool(int32_t index, bool value)
virtual const QMPointer< QMJsonValue > & value(int32_t index) const
virtual const QMPointer< QMJsonValue > & front(void) const
virtual bool from(int32_t index, const QMPointer< QMJsonValue > &value)
virtual bool fromArray(int32_t index, const QMPointer< QMJsonArray > &value)
virtual QMPointer< QMJsonValue > takeFirst(void)
virtual bool isArray(int32_t index) const
virtual QList< QMPointer< QMJsonValue > > values(void) const
virtual bool fromDouble(int32_t index, double value)
virtual void insert(int32_t index, const QMPointer< QMJsonValue > &value)
virtual void removeLast(void)
virtual void removeFirst(void)
virtual bool fromString(int32_t index, const QString &value)
virtual int32_t count(void) const
virtual int32_t lastIndexOf(const QMPointer< QMJsonValue > &value, int32_t from=-1) const
virtual void removeAt(int32_t index)
virtual bool isString(int32_t index) const
virtual int32_t indexOf(const QMPointer< QMJsonValue > &value) const
virtual bool isNull(int32_t index) const
void itemAdded(int32_t index, const QMPointer< QMJsonValue > &value)
virtual const QMPointer< QMJsonArray > & toArray(int32_t index) const
virtual bool empty(void) const
virtual void unite(const QMPointer< QMJsonArray > &array, QMJsonArrayUnitePolicy policy=QMJsonArrayUnitePolicy_Append)
virtual const QMPointer< QMJsonValue > & back(void) const
virtual bool fromObject(int32_t index, const QMPointer< QMJsonObject > &value)
virtual bool isDouble(int32_t index) const
virtual bool isBool(int32_t index) const
virtual void removeAll(const QMPointer< QMJsonValue > &value)
virtual const QMPointer< QMJsonObject > & toObject(int32_t index) const