diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2012-01-09 10:12:21 +0100 |
---|---|---|
committer | Jamey Hicks <jamey.hicks@nokia.com> | 2012-01-09 12:31:09 +0100 |
commit | 888f593502f68cb059db2269c5b0593546b5898c (patch) | |
tree | 68f0dc661092cf0b358cba7d0bf8412b5def808a /src | |
parent | c9222f8c8c13d9c3bb64be8588add41a5c584488 (diff) |
Class names should start with a Q
Now all class names are prefixed with QJson.
Change-Id: If6d1ebcdcec983dbf7a0cd6356f68afc117dbbc7
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Jamey Hicks <jamey.hicks@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qjson.cpp | 28 | ||||
-rw-r--r-- | src/qjson_p.h | 24 | ||||
-rw-r--r-- | src/qjsonarray.cpp | 74 | ||||
-rw-r--r-- | src/qjsonarray.h | 40 | ||||
-rw-r--r-- | src/qjsondocument.cpp | 88 | ||||
-rw-r--r-- | src/qjsondocument.h | 38 | ||||
-rw-r--r-- | src/qjsonglobal.h | 8 | ||||
-rw-r--r-- | src/qjsonobject.cpp | 70 | ||||
-rw-r--r-- | src/qjsonobject.h | 28 | ||||
-rw-r--r-- | src/qjsonparser.cpp | 20 | ||||
-rw-r--r-- | src/qjsonparser_p.h | 2 | ||||
-rw-r--r-- | src/qjsonvalue.cpp | 116 | ||||
-rw-r--r-- | src/qjsonvalue.h | 46 | ||||
-rw-r--r-- | src/qjsonwriter.cpp | 14 |
14 files changed, 298 insertions, 298 deletions
diff --git a/src/qjson.cpp b/src/qjson.cpp index 8206f88..c05b7bc 100644 --- a/src/qjson.cpp +++ b/src/qjson.cpp @@ -224,12 +224,12 @@ int Value::usedStorage(const Base *b) const { int s = 0; switch (type) { - case JsonValue::Number: + case QJsonValue::Number: if (latinOrIntValue) break; s = sizeof(double); break; - case JsonValue::String: { + case QJsonValue::String: { char *d = data(b); if (latinOrIntValue) s = sizeof(ushort) + *(ushort *)d; @@ -237,12 +237,12 @@ int Value::usedStorage(const Base *b) const s = sizeof(int) + sizeof(ushort)*(*(int *)d); break; } - case JsonValue::Array: - case JsonValue::Object: + case QJsonValue::Array: + case QJsonValue::Object: s = objectOrArray(b)->size; break; - case JsonValue::Null: - case JsonValue::Boolean: + case QJsonValue::Null: + case QJsonValue::Boolean: default: break; } @@ -253,17 +253,17 @@ bool Value::isValid(const Base *b) const { int offset = 0; switch (type) { - case JsonValue::Number: + case QJsonValue::Number: if (latinOrIntValue) break; // fall through - case JsonValue::String: - case JsonValue::Array: - case JsonValue::Object: + case QJsonValue::String: + case QJsonValue::Array: + case QJsonValue::Object: offset = val; break; - case JsonValue::Null: - case JsonValue::Boolean: + case QJsonValue::Null: + case QJsonValue::Boolean: default: break; } @@ -278,9 +278,9 @@ bool Value::isValid(const Base *b) const return true; if (s < 0 || offset + s > (int)b->tableOffset) return false; - if (type == JsonValue::Array) + if (type == QJsonValue::Array) return static_cast<Array *>(objectOrArray(b))->isValid(); - if (type == JsonValue::Object) + if (type == QJsonValue::Object) return static_cast<Object *>(objectOrArray(b))->isValid(); return true; } diff --git a/src/qjson_p.h b/src/qjson_p.h index 5c3256d..11814f7 100644 --- a/src/qjson_p.h +++ b/src/qjson_p.h @@ -524,13 +524,13 @@ struct Header { inline bool Value::toBoolean() const { - Q_ASSERT(type == JsonValue::Boolean); + Q_ASSERT(type == QJsonValue::Boolean); return val != 0; } inline double Value::toNumber(const Base *b) const { - Q_ASSERT(type == JsonValue::Number); + Q_ASSERT(type == QJsonValue::Number); if (latinOrIntValue) return int_val; @@ -544,7 +544,7 @@ inline double Value::toNumber(const Base *b) const inline int Value::toInt() const { - Q_ASSERT(type == JsonValue::Number && latinOrIntValue); + Q_ASSERT(type == QJsonValue::Number && latinOrIntValue); return int_val; } @@ -562,19 +562,19 @@ inline QString Value::toString(const Base *b) const inline String Value::asString(const Base *b) const { - Q_ASSERT(type == JsonValue::String && !latinOrIntValue); + Q_ASSERT(type == QJsonValue::String && !latinOrIntValue); return String(data(b)); } inline Latin1String Value::asLatin1String(const Base *b) const { - Q_ASSERT(type == JsonValue::String && latinOrIntValue); + Q_ASSERT(type == QJsonValue::String && latinOrIntValue); return Latin1String(data(b)); } inline Base *Value::objectOrArray(const Base *b) const { - Q_ASSERT(type == JsonValue::Array || type == JsonValue::Object); + Q_ASSERT(type == QJsonValue::Array || type == QJsonValue::Object); return reinterpret_cast<Base *>(data(b)); } @@ -590,7 +590,7 @@ struct Data { { ref.store(0); } - inline Data(int reserved, JsonValue::ValueType valueType) + inline Data(int reserved, QJsonValue::ValueType valueType) : compactionCounter(0), valid(Validated), rawData(0) { ref.store(0); @@ -601,7 +601,7 @@ struct Data { header->version = 1; Base *b = header->root(); b->size = sizeof(Base); - b->is_object = (valueType == JsonValue::Object); + b->is_object = (valueType == QJsonValue::Object); b->tableOffset = sizeof(Base); b->length = 0; } @@ -625,14 +625,14 @@ struct Data { Array *array(int offset) const { return reinterpret_cast<Array *>(rawData + offset); } - JsonObject toObject(Object *o) const + QJsonObject toObject(Object *o) const { - return JsonObject(const_cast<Data *>(this), o); + return QJsonObject(const_cast<Data *>(this), o); } - JsonArray toArray(Array *a) const + QJsonArray toArray(Array *a) const { - return JsonArray(const_cast<Data *>(this), a); + return QJsonArray(const_cast<Data *>(this), a); } Data *detach(Base *b, int reserve = 0) diff --git a/src/qjsonarray.cpp b/src/qjsonarray.cpp index 34298aa..ae1d68b 100644 --- a/src/qjsonarray.cpp +++ b/src/qjsonarray.cpp @@ -50,24 +50,24 @@ using namespace QtJson; -JsonArray::JsonArray() +QJsonArray::QJsonArray() : d(0), a(0) { } -JsonArray::JsonArray(Private::Data *data, Private::Array *array) +QJsonArray::QJsonArray(Private::Data *data, Private::Array *array) : d(data), a(array) { d->ref.ref(); } -JsonArray::~JsonArray() +QJsonArray::~QJsonArray() { if (d && !d->ref.deref()) delete d; } -JsonArray::JsonArray(const JsonArray &other) +QJsonArray::QJsonArray(const QJsonArray &other) { d = other.d; a = other.a; @@ -75,7 +75,7 @@ JsonArray::JsonArray(const JsonArray &other) d->ref.ref(); } -JsonArray &JsonArray::operator =(const JsonArray &other) +QJsonArray &QJsonArray::operator =(const QJsonArray &other) { if (d != other.d) { if (d && !d->ref.deref()) @@ -89,35 +89,35 @@ JsonArray &JsonArray::operator =(const JsonArray &other) return *this; } -JsonArray JsonArray::fromStringList(const QStringList &list) +QJsonArray QJsonArray::fromStringList(const QStringList &list) { - JsonArray array; + QJsonArray array; for (QStringList::const_iterator it = list.constBegin(); it != list.constEnd(); ++it) - array.append(JsonValue(*it)); + array.append(QJsonValue(*it)); return array; } -JsonArray JsonArray::fromVariantList(const QVariantList &list) +QJsonArray QJsonArray::fromVariantList(const QVariantList &list) { - JsonArray array; + QJsonArray array; for (QVariantList::const_iterator it = list.constBegin(); it != list.constEnd(); ++it) - array.append(JsonValue::fromVariant(*it)); + array.append(QJsonValue::fromVariant(*it)); return array; } -QVariantList JsonArray::toVariantList() const +QVariantList QJsonArray::toVariantList() const { QVariantList list; if (a) { for (int i = 0; i < (int)a->length; ++i) - list.append(JsonValue(d, a, a->at(i)).toVariant()); + list.append(QJsonValue(d, a, a->at(i)).toVariant()); } return list; } -int JsonArray::size() const +int QJsonArray::size() const { if (!d) return 0; @@ -125,7 +125,7 @@ int JsonArray::size() const return (int)a->length; } -bool JsonArray::isEmpty() const +bool QJsonArray::isEmpty() const { if (!d) return true; @@ -133,30 +133,30 @@ bool JsonArray::isEmpty() const return !a->length; } -JsonValue JsonArray::at(int i) const +QJsonValue QJsonArray::at(int i) const { if (!a || i < 0 || i >= (int)a->length) - return JsonValue(JsonValue::Undefined); + return QJsonValue(QJsonValue::Undefined); - return JsonValue(d, a, a->at(i)); + return QJsonValue(d, a, a->at(i)); } -JsonValue JsonArray::first() const +QJsonValue QJsonArray::first() const { return at(0); } -JsonValue JsonArray::last() const +QJsonValue QJsonArray::last() const { return at(a ? (a->length - 1) : 0); } -void JsonArray::append(const JsonValue &value) +void QJsonArray::append(const QJsonValue &value) { insert(a ? a->length : 0, value); } -void JsonArray::removeAt(int i) +void QJsonArray::removeAt(int i) { if (!a || i < 0 || i >= (int)a->length) return; @@ -168,14 +168,14 @@ void JsonArray::removeAt(int i) compact(); } -JsonValue JsonArray::takeAt(int i) +QJsonValue QJsonArray::takeAt(int i) { if (!a || i < 0 || i >= (int)a->length) - return JsonValue(JsonValue::Undefined); + return QJsonValue(QJsonValue::Undefined); detach(); - JsonValue v(d, a, a->at(i)); + QJsonValue v(d, a, a->at(i)); v.detach(); removeAt(i); @@ -183,7 +183,7 @@ JsonValue JsonArray::takeAt(int i) return v; } -void JsonArray::insert(int i, const JsonValue &value) +void QJsonArray::insert(int i, const QJsonValue &value) { Q_ASSERT (i >= 0 && i <= (int)(a ? a->length : 0)); @@ -197,7 +197,7 @@ void JsonArray::insert(int i, const JsonValue &value) int valueOffset = a->reserveSpace(valueSize, i, 1); Private::Value &v = (*a)[i]; - v.type = (value.t == JsonValue::Undefined ? JsonValue::Null : value.t); + v.type = (value.t == QJsonValue::Undefined ? QJsonValue::Null : value.t); v.latinOrIntValue = compressed; v.latinKey = false; v.val = value.valueToStore(valueOffset); @@ -205,7 +205,7 @@ void JsonArray::insert(int i, const JsonValue &value) value.copyData((char *)a + valueOffset, compressed); } -bool JsonArray::contains(const JsonValue &element) const +bool QJsonArray::contains(const QJsonValue &element) const { for (int i = 0; i < size(); i++) { if (at(i) == element) @@ -221,12 +221,12 @@ bool JsonArray::contains(const JsonValue &element) const //} -JsonValue JsonArray::operator[](int i) const +QJsonValue QJsonArray::operator[](int i) const { return at(i); } -bool JsonArray::operator==(const JsonArray &other) const +bool QJsonArray::operator==(const QJsonArray &other) const { if (a == other.a) return true; @@ -239,21 +239,21 @@ bool JsonArray::operator==(const JsonArray &other) const return false; for (int i = 0; i < (int)a->length; ++i) { - if (JsonValue(d, a, a->at(i)) != JsonValue(other.d, other.a, other.a->at(i))) + if (QJsonValue(d, a, a->at(i)) != QJsonValue(other.d, other.a, other.a->at(i))) return false; } return true; } -bool JsonArray::operator!=(const JsonArray &other) const +bool QJsonArray::operator!=(const QJsonArray &other) const { return !(*this == other); } -void JsonArray::detach(uint reserve) +void QJsonArray::detach(uint reserve) { if (!d) { - d = new Private::Data(reserve, JsonValue::Array); + d = new Private::Data(reserve, QJsonValue::Array); a = static_cast<Private::Array *>(d->header->root()); d->ref.ref(); return; @@ -269,12 +269,12 @@ void JsonArray::detach(uint reserve) a = static_cast<Private::Array *>(d->header->root()); } -void JsonArray::compact() const +void QJsonArray::compact() const { if (!d || !d->compactionCounter) return; - const_cast<JsonArray *>(this)->detach(); + const_cast<QJsonArray *>(this)->detach(); d->compact(); - const_cast<JsonArray *>(this)->a = static_cast<Private::Array *>(d->header->root()); + const_cast<QJsonArray *>(this)->a = static_cast<Private::Array *>(d->header->root()); } diff --git a/src/qjsonarray.h b/src/qjsonarray.h index 7155052..931ed51 100644 --- a/src/qjsonarray.h +++ b/src/qjsonarray.h @@ -49,45 +49,45 @@ class QStringList; namespace QtJson { -class Q_JSON_EXPORT JsonArray +class Q_JSON_EXPORT QJsonArray { public: - JsonArray(); - ~JsonArray(); + QJsonArray(); + ~QJsonArray(); - JsonArray(const JsonArray &other); - JsonArray &operator =(const JsonArray &other); + QJsonArray(const QJsonArray &other); + QJsonArray &operator =(const QJsonArray &other); - static JsonArray fromStringList(const QStringList &list); - static JsonArray fromVariantList(const QVariantList &list); + static QJsonArray fromStringList(const QStringList &list); + static QJsonArray fromVariantList(const QVariantList &list); QVariantList toVariantList() const; int size() const; bool isEmpty() const; - JsonValue at(int i) const; - JsonValue first() const; - JsonValue last() const; + QJsonValue at(int i) const; + QJsonValue first() const; + QJsonValue last() const; - void append(const JsonValue &value); + void append(const QJsonValue &value); void removeAt(int i); - JsonValue takeAt(int i); + QJsonValue takeAt(int i); - void insert(int i, const JsonValue &value); + void insert(int i, const QJsonValue &value); - bool contains(const JsonValue &element) const; + bool contains(const QJsonValue &element) const; // JsonValue &operator[](int i); - JsonValue operator[](int i) const; + QJsonValue operator[](int i) const; - bool operator==(const JsonArray &other) const; - bool operator!=(const JsonArray &other) const; + bool operator==(const QJsonArray &other) const; + bool operator!=(const QJsonArray &other) const; void detach(uint reserve = 0); private: friend class Private::Data; - friend class JsonValue; - friend class JsonDocument; - JsonArray(Private::Data *data, Private::Array *array); + friend class QJsonValue; + friend class QJsonDocument; + QJsonArray(Private::Data *data, Private::Array *array); void compact() const; Private::Data *d; Private::Array *a; diff --git a/src/qjsondocument.cpp b/src/qjsondocument.cpp index 376770d..6816534 100644 --- a/src/qjsondocument.cpp +++ b/src/qjsondocument.cpp @@ -51,24 +51,24 @@ using namespace QtJson; -JsonDocument::JsonDocument() +QJsonDocument::QJsonDocument() : d(0) { } -JsonDocument::JsonDocument(const JsonObject &object) +QJsonDocument::QJsonDocument(const QJsonObject &object) : d(0) { setObject(object); } -JsonDocument::JsonDocument(const JsonArray &array) +QJsonDocument::QJsonDocument(const QJsonArray &array) : d(0) { setArray(array); } -JsonDocument::JsonDocument(Private::Data *data) +QJsonDocument::QJsonDocument(Private::Data *data) : d(data) { Q_ASSERT(d); @@ -76,20 +76,20 @@ JsonDocument::JsonDocument(Private::Data *data) } -JsonDocument::~JsonDocument() +QJsonDocument::~QJsonDocument() { if (d && !d->ref.deref()) delete d; } -JsonDocument::JsonDocument(const JsonDocument &other) +QJsonDocument::QJsonDocument(const QJsonDocument &other) { d = other.d; if (d) d->ref.ref(); } -JsonDocument &JsonDocument::operator =(const JsonDocument &other) +QJsonDocument &QJsonDocument::operator =(const QJsonDocument &other) { if (d != other.d) { if (d && !d->ref.deref()) @@ -102,47 +102,47 @@ JsonDocument &JsonDocument::operator =(const JsonDocument &other) return *this; } -JsonDocument JsonDocument::fromBinaryData(const QByteArray &data) +QJsonDocument QJsonDocument::fromBinaryData(const QByteArray &data) { Private::Header *h = (Private::Header *) data.constData(); if (data.size() < (int)(sizeof(Private::Header) + sizeof(Private::Base)) || h->tag != QBJS_Tag || h->version != 1u || sizeof(Private::Header) + h->root()->size > (uint)data.size()) - return JsonDocument(); + return QJsonDocument(); char *raw = (char *)malloc(data.size()); memcpy(raw, data.constData(), data.size()); Private::Data *d = new Private::Data(raw, data.size()); - return JsonDocument(d); + return QJsonDocument(d); } -JsonDocument JsonDocument::fromVariant(const QVariant &v) +QJsonDocument QJsonDocument::fromVariant(const QVariant &v) { - JsonDocument doc; + QJsonDocument doc; if (v.type() == QVariant::Map) { - doc.setObject(JsonObject::fromVariantMap(v.toMap())); + doc.setObject(QJsonObject::fromVariantMap(v.toMap())); } else if (v.type() == QVariant::List) { - doc.setArray(JsonArray::fromVariantList(v.toList())); + doc.setArray(QJsonArray::fromVariantList(v.toList())); } else if (v.type() == QVariant::StringList) { - doc.setArray(JsonArray::fromStringList(v.toStringList())); + doc.setArray(QJsonArray::fromStringList(v.toStringList())); } return doc; } -QVariant JsonDocument::toVariant() const +QVariant QJsonDocument::toVariant() const { if (!d) return QVariant(); if (d->header->root()->isArray()) - return JsonArray(d, static_cast<Private::Array *>(d->header->root())).toVariantList(); + return QJsonArray(d, static_cast<Private::Array *>(d->header->root())).toVariantList(); else - return JsonObject(d, static_cast<Private::Object *>(d->header->root())).toVariantMap(); + return QJsonObject(d, static_cast<Private::Object *>(d->header->root())).toVariantMap(); } -QByteArray JsonDocument::toJson() const +QByteArray QJsonDocument::toJson() const { if (!d) return QByteArray(); @@ -157,13 +157,13 @@ QByteArray JsonDocument::toJson() const return json; } -JsonDocument JsonDocument::fromJson(const QByteArray &json) +QJsonDocument QJsonDocument::fromJson(const QByteArray &json) { QJsonParser parser(json.constData(), json.length()); return parser.parse(); } -bool JsonDocument::isEmpty() const +bool QJsonDocument::isEmpty() const { if (!d) return true; @@ -171,7 +171,7 @@ bool JsonDocument::isEmpty() const return false; } -QByteArray JsonDocument::toBinaryData() const +QByteArray QJsonDocument::toBinaryData() const { if (!d || !d->rawData) return QByteArray(); @@ -179,48 +179,48 @@ QByteArray JsonDocument::toBinaryData() const return QByteArray(d->rawData, d->header->root()->size + sizeof(Private::Header)); } -JsonValue::ValueType JsonDocument::type() const +QJsonValue::ValueType QJsonDocument::type() const { if (!d) - return JsonValue::Null; + return QJsonValue::Null; Private::Header *h = (Private::Header *)d->rawData; - return h->root()->isArray() ? JsonValue::Array : JsonValue::Object; + return h->root()->isArray() ? QJsonValue::Array : QJsonValue::Object; } -JsonObject JsonDocument::object() const +QJsonObject QJsonDocument::object() const { if (d) { Private::Base *b = d->header->root(); if (b->isObject()) - return JsonObject(d, static_cast<Private::Object *>(b)); + return QJsonObject(d, static_cast<Private::Object *>(b)); } - return JsonObject(); + return QJsonObject(); } -JsonArray JsonDocument::array() const +QJsonArray QJsonDocument::array() const { if (d) { Private::Base *b = d->header->root(); if (b->isArray()) - return JsonArray(d, static_cast<Private::Array *>(b)); + return QJsonArray(d, static_cast<Private::Array *>(b)); } - return JsonArray(); + return QJsonArray(); } -void JsonDocument::setObject(const JsonObject &object) +void QJsonDocument::setObject(const QJsonObject &object) { if (d && !d->ref.deref()) delete d; d = object.d; if (!d) { - d = new Private::Data(0, JsonValue::Object); + d = new Private::Data(0, QJsonValue::Object); } else if (d->compactionCounter) { object.compact(); d = object.d; } else if (object.o != d->header->root()) { - JsonObject detached(object); + QJsonObject detached(object); detached.detach(); d = detached.d; d->ref.ref(); @@ -229,7 +229,7 @@ void JsonDocument::setObject(const JsonObject &object) d->ref.ref(); } -void JsonDocument::setArray(const JsonArray &array) +void QJsonDocument::setArray(const QJsonArray &array) { if (d && !d->ref.deref()) delete d; @@ -237,12 +237,12 @@ void JsonDocument::setArray(const JsonArray &array) d = array.d; if (!d) { - d = new Private::Data(0, JsonValue::Array); + d = new Private::Data(0, QJsonValue::Array); } else if (d->compactionCounter) { array.compact(); d = array.d; } else if (array.a != d->header->root()) { - JsonArray detached(array); + QJsonArray detached(array); detached.detach(); d = detached.d; d->ref.ref(); @@ -252,7 +252,7 @@ void JsonDocument::setArray(const JsonArray &array) } -bool JsonDocument::operator==(const JsonDocument &other) const +bool QJsonDocument::operator==(const QJsonDocument &other) const { if (d == other.d) return true; @@ -264,19 +264,19 @@ bool JsonDocument::operator==(const JsonDocument &other) const return false; if (d->header->root()->isObject()) - return JsonObject(d, static_cast<Private::Object *>(d->header->root())) - == JsonObject(other.d, static_cast<Private::Object *>(other.d->header->root())); + return QJsonObject(d, static_cast<Private::Object *>(d->header->root())) + == QJsonObject(other.d, static_cast<Private::Object *>(other.d->header->root())); else - return JsonArray(d, static_cast<Private::Array *>(d->header->root())) - == JsonArray(other.d, static_cast<Private::Array *>(other.d->header->root())); + return QJsonArray(d, static_cast<Private::Array *>(d->header->root())) + == QJsonArray(other.d, static_cast<Private::Array *>(other.d->header->root())); } -bool JsonDocument::operator!=(const JsonDocument &other) const +bool QJsonDocument::operator!=(const QJsonDocument &other) const { return !(*this == other); } -bool JsonDocument::isValid() +bool QJsonDocument::isValid() { if (!d) return false; diff --git a/src/qjsondocument.h b/src/qjsondocument.h index d24b7c2..4142e62 100644 --- a/src/qjsondocument.h +++ b/src/qjsondocument.h @@ -48,46 +48,46 @@ namespace QtJson { -class Q_JSON_EXPORT JsonDocument +class Q_JSON_EXPORT QJsonDocument { public: - JsonDocument(); - JsonDocument(const JsonObject &object); - JsonDocument(const JsonArray &array); - ~JsonDocument(); + QJsonDocument(); + QJsonDocument(const QJsonObject &object); + QJsonDocument(const QJsonArray &array); + ~QJsonDocument(); - JsonDocument(const JsonDocument &other); - JsonDocument &operator =(const JsonDocument &other); + QJsonDocument(const QJsonDocument &other); + QJsonDocument &operator =(const QJsonDocument &other); - static JsonDocument fromBinaryData(const QByteArray &data); + static QJsonDocument fromBinaryData(const QByteArray &data); QByteArray toBinaryData() const; - static JsonDocument fromVariant(const QVariant &v); + static QJsonDocument fromVariant(const QVariant &v); QVariant toVariant() const; QByteArray toJson() const; - static JsonDocument fromJson(const QByteArray &json); + static QJsonDocument fromJson(const QByteArray &json); bool isEmpty() const; - JsonValue::ValueType type() const; + QJsonValue::ValueType type() const; - JsonObject object() const; - JsonArray array() const; + QJsonObject object() const; + QJsonArray array() const; - void setObject(const JsonObject &object); - void setArray(const JsonArray &array); + void setObject(const QJsonObject &object); + void setArray(const QJsonArray &array); - bool operator==(const JsonDocument &other) const; - bool operator!=(const JsonDocument &other) const; + bool operator==(const QJsonDocument &other) const; + bool operator!=(const QJsonDocument &other) const; bool isValid(); private: friend class Private::Data; - friend class JsonValue; + friend class QJsonValue; friend class QJsonParser; - JsonDocument(Private::Data *data); + QJsonDocument(Private::Data *data); Private::Data *d; }; diff --git a/src/qjsonglobal.h b/src/qjsonglobal.h index 3f7c15d..b5f6364 100644 --- a/src/qjsonglobal.h +++ b/src/qjsonglobal.h @@ -62,10 +62,10 @@ namespace QtJson struct Value; }; - class JsonValue; - class JsonObject; - class JsonArray; - class JsonDocument; + class QJsonValue; + class QJsonObject; + class QJsonArray; + class QJsonDocument; class QJsonParser; const uint QBJS_Tag = ('q') | ('b' << 8) | ('j' << 16) | ('s' << 24); diff --git a/src/qjsonobject.cpp b/src/qjsonobject.cpp index fb4f0e0..c2259d9 100644 --- a/src/qjsonobject.cpp +++ b/src/qjsonobject.cpp @@ -49,12 +49,12 @@ using namespace QtJson; -JsonObject::JsonObject() +QJsonObject::QJsonObject() : d(0), o(0) { } -JsonObject::JsonObject(Private::Data *data, Private::Object *object) +QJsonObject::QJsonObject(Private::Data *data, Private::Object *object) : d(data), o(object) { Q_ASSERT(d); @@ -63,13 +63,13 @@ JsonObject::JsonObject(Private::Data *data, Private::Object *object) } -JsonObject::~JsonObject() +QJsonObject::~QJsonObject() { if (d && !d->ref.deref()) delete d; } -JsonObject::JsonObject(const JsonObject &other) +QJsonObject::QJsonObject(const QJsonObject &other) { d = other.d; o = other.o; @@ -77,7 +77,7 @@ JsonObject::JsonObject(const JsonObject &other) d->ref.ref(); } -JsonObject &JsonObject::operator =(const JsonObject &other) +QJsonObject &QJsonObject::operator =(const QJsonObject &other) { if (d != other.d) { if (d && !d->ref.deref()) @@ -91,27 +91,27 @@ JsonObject &JsonObject::operator =(const JsonObject &other) return *this; } -JsonObject JsonObject::fromVariantMap(const QVariantMap &map) +QJsonObject QJsonObject::fromVariantMap(const QVariantMap &map) { // ### this is implemented the trivial way, not the most efficient way - JsonObject object; + QJsonObject object; for (QVariantMap::const_iterator it = map.constBegin(); it != map.constEnd(); ++it) - object.insert(it.key(), JsonValue::fromVariant(it.value())); + object.insert(it.key(), QJsonValue::fromVariant(it.value())); return object; } -QVariantMap JsonObject::toVariantMap() const +QVariantMap QJsonObject::toVariantMap() const { QVariantMap map; for (uint i = 0; i < o->length; ++i) { Private::Entry *e = o->entryAt(i); - map.insert(e->key(), JsonValue(d, o, e->value).toVariant()); + map.insert(e->key(), QJsonValue(d, o, e->value).toVariant()); } return map; } -QByteArray JsonObject::toJson() const +QByteArray QJsonObject::toJson() const { QByteArray json; QJsonWriter::objectToJson(o, json, 0); @@ -119,7 +119,7 @@ QByteArray JsonObject::toJson() const } -QStringList JsonObject::keys() const +QStringList QJsonObject::keys() const { if (!d) return QStringList(); @@ -134,7 +134,7 @@ QStringList JsonObject::keys() const return keys; } -int JsonObject::numKeys() const +int QJsonObject::numKeys() const { if (!d) return 0; @@ -142,7 +142,7 @@ int JsonObject::numKeys() const return o->length; } -bool JsonObject::isEmpty() const +bool QJsonObject::isEmpty() const { if (!d) return true; @@ -150,27 +150,27 @@ bool JsonObject::isEmpty() const return !o->length; } -JsonValue JsonObject::value(const QString &key) const +QJsonValue QJsonObject::value(const QString &key) const { if (!d) - return JsonValue(); + return QJsonValue(); for (uint i = 0; i < o->length; ++i) { Private::Entry *e = o->entryAt(i); if (e->value.latinKey) { if (e->shallowLatin1Key() == key) - return JsonValue(d, o, e->value); + return QJsonValue(d, o, e->value); } else { if (e->shallowKey() == key) - return JsonValue(d, o, e->value); + return QJsonValue(d, o, e->value); } } - return JsonValue(JsonValue::Undefined); + return QJsonValue(QJsonValue::Undefined); } -void JsonObject::insert(const QString &key, const JsonValue &value) +void QJsonObject::insert(const QString &key, const QJsonValue &value) { - if (value.t == JsonValue::Undefined) { + if (value.t == QJsonValue::Undefined) { remove(key); return; } @@ -208,7 +208,7 @@ void JsonObject::insert(const QString &key, const JsonValue &value) value.copyData((char *)e + valueOffset, latinOrIntValue); } -void JsonObject::remove(const QString &key) +void QJsonObject::remove(const QString &key) { if (!d) return; @@ -224,14 +224,14 @@ void JsonObject::remove(const QString &key) compact(); } -JsonValue JsonObject::take(const QString &key) +QJsonValue QJsonObject::take(const QString &key) { if (!o) - return JsonValue(JsonValue::Undefined); + return QJsonValue(QJsonValue::Undefined); int index = o->indexOf(key); if (index < 0) - return JsonValue(JsonValue::Undefined); + return QJsonValue(QJsonValue::Undefined); Private::Entry *e = o->entryAt(index); o->removeItems(index, 1); @@ -239,10 +239,10 @@ JsonValue JsonObject::take(const QString &key) if (d->compactionCounter > 32 && d->compactionCounter >= (int)o->length/2) compact(); - return JsonValue(d, o, e->value); + return QJsonValue(d, o, e->value); } -bool JsonObject::contains(const QString &key) const +bool QJsonObject::contains(const QString &key) const { if (!o) return false; @@ -250,7 +250,7 @@ bool JsonObject::contains(const QString &key) const return o->indexOf(key) >= 0; } -bool JsonObject::operator==(const JsonObject &other) const +bool QJsonObject::operator==(const QJsonObject &other) const { if (o == other.o) return true; @@ -264,7 +264,7 @@ bool JsonObject::operator==(const JsonObject &other) const for (uint i = 0; i < o->length; ++i) { Private::Entry *e = o->entryAt(i); - JsonValue v(d, o, e->value); + QJsonValue v(d, o, e->value); if (other.value(e->key()) != v) return false; } @@ -272,15 +272,15 @@ bool JsonObject::operator==(const JsonObject &other) const return true; } -bool JsonObject::operator!=(const JsonObject &other) const +bool QJsonObject::operator!=(const QJsonObject &other) const { return !(*this == other); } -void JsonObject::detach(uint reserve) +void QJsonObject::detach(uint reserve) { if (!d) { - d = new Private::Data(reserve, JsonValue::Object); + d = new Private::Data(reserve, QJsonValue::Object); o = static_cast<Private::Object *>(d->header->root()); d->ref.ref(); return; @@ -296,12 +296,12 @@ void JsonObject::detach(uint reserve) o = static_cast<Private::Object *>(d->header->root()); } -void JsonObject::compact() const +void QJsonObject::compact() const { if (!d || !d->compactionCounter) return; - const_cast<JsonObject *>(this)->detach(); + const_cast<QJsonObject *>(this)->detach(); d->compact(); - const_cast<JsonObject *>(this)->o = static_cast<Private::Object *>(d->header->root()); + const_cast<QJsonObject *>(this)->o = static_cast<Private::Object *>(d->header->root()); } diff --git a/src/qjsonobject.h b/src/qjsonobject.h index 3e17a42..397131d 100644 --- a/src/qjsonobject.h +++ b/src/qjsonobject.h @@ -47,16 +47,16 @@ namespace QtJson { -class Q_JSON_EXPORT JsonObject +class Q_JSON_EXPORT QJsonObject { public: - JsonObject(); - ~JsonObject(); + QJsonObject(); + ~QJsonObject(); - JsonObject(const JsonObject &other); - JsonObject &operator =(const JsonObject &other); + QJsonObject(const QJsonObject &other); + QJsonObject &operator =(const QJsonObject &other); - static JsonObject fromVariantMap(const QVariantMap &map); + static QJsonObject fromVariantMap(const QVariantMap &map); QVariantMap toVariantMap() const; QByteArray toJson() const; @@ -69,24 +69,24 @@ public: // QString keyAt(int); // QSonValue valueAt(int) - JsonValue value(const QString & key) const; + QJsonValue value(const QString & key) const; - void insert(const QString &key, const JsonValue &value); + void insert(const QString &key, const QJsonValue &value); void remove(const QString &key); - JsonValue take(const QString &key); + QJsonValue take(const QString &key); bool contains(const QString &key) const; - bool operator==(const JsonObject &other) const; - bool operator!=(const JsonObject &other) const; + bool operator==(const QJsonObject &other) const; + bool operator!=(const QJsonObject &other) const; void detach(uint reserve = 0); private: friend class Private::Data; - friend class JsonValue; - friend class JsonDocument; + friend class QJsonValue; + friend class QJsonDocument; friend class QJsonParser; - JsonObject(Private::Data *data, Private::Object *object); + QJsonObject(Private::Data *data, Private::Object *object); void compact() const; Private::Data *d; diff --git a/src/qjsonparser.cpp b/src/qjsonparser.cpp index 1163bb6..f153ec1 100644 --- a/src/qjsonparser.cpp +++ b/src/qjsonparser.cpp @@ -151,7 +151,7 @@ char QJsonParser::nextToken() /* JSON-text = object / array */ -QtJson::JsonDocument QJsonParser::parse() +QtJson::QJsonDocument QJsonParser::parse() { #ifdef PARSER_DEBUG indent = 0; @@ -183,7 +183,7 @@ QtJson::JsonDocument QJsonParser::parse() END; { Private::Data *d = new Private::Data(data, current); - return JsonDocument(d); + return QJsonDocument(d); } error: @@ -191,7 +191,7 @@ error: qDebug() << ">>>>> parser error"; #endif free(data); - return JsonDocument(); + return QJsonDocument(); } /* @@ -341,7 +341,7 @@ bool QJsonParser::parseValue(Private::Value *val, int baseOffset) if (*json++ == 'u' && *json++ == 'l' && *json++ == 'l') { - val->type = JsonValue::Null; + val->type = QJsonValue::Null; DEBUG << "value: null"; END; return true; @@ -353,7 +353,7 @@ bool QJsonParser::parseValue(Private::Value *val, int baseOffset) if (*json++ == 'r' && *json++ == 'u' && *json++ == 'e') { - val->type = JsonValue::Boolean; + val->type = QJsonValue::Boolean; val->val = true; DEBUG << "value: true"; END; @@ -367,7 +367,7 @@ bool QJsonParser::parseValue(Private::Value *val, int baseOffset) *json++ == 'l' && *json++ == 's' && *json++ == 'e') { - val->type = JsonValue::Boolean; + val->type = QJsonValue::Boolean; val->val = false; DEBUG << "value: false"; END; @@ -375,7 +375,7 @@ bool QJsonParser::parseValue(Private::Value *val, int baseOffset) } return false; case Quote: { - val->type = JsonValue::String; + val->type = QJsonValue::String; val->val = current - baseOffset; bool latin1; if (!parseString(&latin1)) @@ -386,7 +386,7 @@ bool QJsonParser::parseValue(Private::Value *val, int baseOffset) return true; } case BeginArray: - val->type = JsonValue::Array; + val->type = QJsonValue::Array; val->val = current - baseOffset; if (!parseArray()) return false; @@ -394,7 +394,7 @@ bool QJsonParser::parseValue(Private::Value *val, int baseOffset) END; return true; case BeginObject: - val->type = JsonValue::Object; + val->type = QJsonValue::Object; val->val = current - baseOffset; if (!parseObject()) return false; @@ -433,7 +433,7 @@ bool QJsonParser::parseValue(Private::Value *val, int baseOffset) bool QJsonParser::parseNumber(Private::Value *val, int baseOffset) { BEGIN << "parseNumber" << json; - val->type = JsonValue::Number; + val->type = QJsonValue::Number; const char *start = json; bool isInt = true; diff --git a/src/qjsonparser_p.h b/src/qjsonparser_p.h index 98b5d8e..d3700b2 100644 --- a/src/qjsonparser_p.h +++ b/src/qjsonparser_p.h @@ -62,7 +62,7 @@ class QJsonParser public: QJsonParser(const char *json, int length); - QtJson::JsonDocument parse(); + QtJson::QJsonDocument parse(); private: inline bool eatSpace(); diff --git a/src/qjsonvalue.cpp b/src/qjsonvalue.cpp index 1df9edd..e77b484 100644 --- a/src/qjsonvalue.cpp +++ b/src/qjsonvalue.cpp @@ -54,12 +54,12 @@ using namespace QtJson; static const Private::Base emptyArray = { { qToLittleEndian(sizeof(Private::Base)) }, { 0 }, { 0 } }; static const Private::Base emptyObject = { { qToLittleEndian(sizeof(Private::Base)) }, { 0 }, { 0 } }; -JsonValue::JsonValue(ValueType type) +QJsonValue::QJsonValue(ValueType type) : t(type), d(0), dbl(0.) { } -JsonValue::JsonValue(Private::Data *data, Private::Base *base, const Private::Value &v) +QJsonValue::QJsonValue(Private::Data *data, Private::Base *base, const Private::Value &v) : d(0) { t = (ValueType)(uint)v.type; @@ -90,32 +90,32 @@ JsonValue::JsonValue(Private::Data *data, Private::Base *base, const Private::Va d->ref.ref(); } -JsonValue::JsonValue(bool b) +QJsonValue::QJsonValue(bool b) : t(Boolean), d(0) { this->b = b; } -JsonValue::JsonValue(double n) +QJsonValue::QJsonValue(double n) : t(Number), d(0) { this->dbl = n; } -JsonValue::JsonValue(int n) +QJsonValue::QJsonValue(int n) : t(Number), d(0) { this->dbl = n; } -JsonValue::JsonValue(const QString &s) +QJsonValue::QJsonValue(const QString &s) : t(String), d(0) { stringData = *(QStringData **)(&s); stringData->ref.ref(); } -JsonValue::JsonValue(const QLatin1String &s) +QJsonValue::QJsonValue(const QLatin1String &s) : t(String), d(0) { // ### FIXME: Avoid creating the temp QString below @@ -124,7 +124,7 @@ JsonValue::JsonValue(const QLatin1String &s) stringData->ref.ref(); } -JsonValue::JsonValue(const JsonArray &a) +QJsonValue::QJsonValue(const QJsonArray &a) : t(Array), d(a.d) { a.compact(); @@ -133,7 +133,7 @@ JsonValue::JsonValue(const JsonArray &a) d->ref.ref(); } -JsonValue::JsonValue(const JsonObject &o) +QJsonValue::QJsonValue(const QJsonObject &o) : t(Object), d(o.d) { o.compact(); @@ -143,7 +143,7 @@ JsonValue::JsonValue(const JsonObject &o) } -JsonValue::~JsonValue() +QJsonValue::~QJsonValue() { if (t == String && stringData && !stringData->ref.deref()) free(stringData); @@ -152,7 +152,7 @@ JsonValue::~JsonValue() delete d; } -JsonValue::JsonValue(const JsonValue &other) +QJsonValue::QJsonValue(const QJsonValue &other) { t = other.t; d = other.d; @@ -164,7 +164,7 @@ JsonValue::JsonValue(const JsonValue &other) stringData->ref.ref(); } -JsonValue &JsonValue::operator =(const JsonValue &other) +QJsonValue &QJsonValue::operator =(const QJsonValue &other) { if (t == String && stringData && !stringData->ref.deref()) free(stringData); @@ -188,36 +188,36 @@ JsonValue &JsonValue::operator =(const JsonValue &other) return *this; } -JsonValue JsonValue::fromVariant(const QVariant &variant) +QJsonValue QJsonValue::fromVariant(const QVariant &variant) { switch (variant.type()) { case QVariant::Bool: - return JsonValue(variant.toBool()); + return QJsonValue(variant.toBool()); case QVariant::Int: - return JsonValue(variant.toInt()); + return QJsonValue(variant.toInt()); case QVariant::Double: case QVariant::LongLong: case QVariant::ULongLong: case QVariant::UInt: - return JsonValue(variant.toDouble()); + return QJsonValue(variant.toDouble()); case QVariant::String: - return JsonValue(variant.toString()); + return QJsonValue(variant.toString()); case QVariant::StringList: - return JsonValue(JsonArray::fromStringList(variant.toStringList())); + return QJsonValue(QJsonArray::fromStringList(variant.toStringList())); case QVariant::List: - return JsonValue(JsonArray::fromVariantList(variant.toList())); + return QJsonValue(QJsonArray::fromVariantList(variant.toList())); case QVariant::Map: - return JsonValue(JsonObject::fromVariantMap(variant.toMap())); + return QJsonValue(QJsonObject::fromVariantMap(variant.toMap())); default: break; } QString string = variant.toString(); if (string.isEmpty()) - return JsonValue(); - return JsonValue(string); + return QJsonValue(); + return QJsonValue(string); } -QVariant JsonValue::toVariant() const +QVariant QJsonValue::toVariant() const { switch (t) { case Boolean: @@ -227,9 +227,9 @@ QVariant JsonValue::toVariant() const case String: return toString(); case Array: - return JsonArray(d, array).toVariantList(); + return QJsonArray(d, array).toVariantList(); case Object: - return JsonObject(d, object).toVariantMap(); + return QJsonObject(d, object).toVariantMap(); case Null: case Undefined: break; @@ -238,68 +238,68 @@ QVariant JsonValue::toVariant() const } -JsonValue::ValueType JsonValue::type() const +QJsonValue::ValueType QJsonValue::type() const { return t; } -void JsonValue::setValue(bool b) +void QJsonValue::setValue(bool b) { - *this = JsonValue(b); + *this = QJsonValue(b); } -void JsonValue::setValue(double d) +void QJsonValue::setValue(double d) { - *this = JsonValue(d); + *this = QJsonValue(d); } -void JsonValue::setValue(int i) +void QJsonValue::setValue(int i) { - *this = JsonValue(i); + *this = QJsonValue(i); } -void JsonValue::setValue(const QString &s) +void QJsonValue::setValue(const QString &s) { - *this = JsonValue(s); + *this = QJsonValue(s); } -void JsonValue::setValue(const QLatin1String &s) +void QJsonValue::setValue(const QLatin1String &s) { - *this = JsonValue(s); + *this = QJsonValue(s); } -void JsonValue::setValue(const JsonArray &a) +void QJsonValue::setValue(const QJsonArray &a) { - *this = JsonValue(a); + *this = QJsonValue(a); } -void JsonValue::setValue(const JsonObject &o) +void QJsonValue::setValue(const QJsonObject &o) { - *this = JsonValue(o); + *this = QJsonValue(o); } -bool JsonValue::toBool() const +bool QJsonValue::toBool() const { if (t != Boolean) return false; return b; } -double JsonValue::toNumber() const +double QJsonValue::toNumber() const { if (t != Number) return 0; return dbl; } -int JsonValue::toInt() const +int QJsonValue::toInt() const { if (t != Number) return 0; return (int)dbl; } -QString JsonValue::toString() const +QString QJsonValue::toString() const { if (t != String) return QString(); @@ -307,23 +307,23 @@ QString JsonValue::toString() const return QString(*(const QConstStringData<1> *)stringData); } -JsonArray JsonValue::toArray() const +QJsonArray QJsonValue::toArray() const { if (!d || t != Array) - return JsonArray(); + return QJsonArray(); - return JsonArray(d, array); + return QJsonArray(d, array); } -JsonObject JsonValue::toObject() const +QJsonObject QJsonValue::toObject() const { if (!d || t != Object) - return JsonObject(); + return QJsonObject(); - return JsonObject(d, object); + return QJsonObject(d, object); } -bool JsonValue::operator==(const JsonValue &other) const +bool QJsonValue::operator==(const QJsonValue &other) const { if (t != other.t) return false; @@ -339,19 +339,19 @@ bool JsonValue::operator==(const JsonValue &other) const case String: return toString() == other.toString(); case Array: - return JsonArray(d, array) == JsonArray(other.d, other.array); + return QJsonArray(d, array) == QJsonArray(other.d, other.array); case Object: - return JsonObject(d, object) == JsonObject(other.d, other.object); + return QJsonObject(d, object) == QJsonObject(other.d, other.object); } return true; } -bool JsonValue::operator!=(const JsonValue &other) const +bool QJsonValue::operator!=(const QJsonValue &other) const { return !(*this == other); } -void JsonValue::detach() +void QJsonValue::detach() { if (!d) return; @@ -364,7 +364,7 @@ void JsonValue::detach() object = static_cast<Private::Object *>(d->header->root()); } -int JsonValue::requiredStorage(bool *compressed) const +int QJsonValue::requiredStorage(bool *compressed) const { *compressed = false; switch (t) { @@ -390,7 +390,7 @@ int JsonValue::requiredStorage(bool *compressed) const return 0; } -uint JsonValue::valueToStore(uint offset) const +uint QJsonValue::valueToStore(uint offset) const { switch (t) { case Undefined: @@ -411,7 +411,7 @@ uint JsonValue::valueToStore(uint offset) const return 0; } -void JsonValue::copyData(char *dest, bool compressed) const +void QJsonValue::copyData(char *dest, bool compressed) const { switch (t) { case Number: diff --git a/src/qjsonvalue.h b/src/qjsonvalue.h index 0a66216..09af8b0 100644 --- a/src/qjsonvalue.h +++ b/src/qjsonvalue.h @@ -48,7 +48,7 @@ class QVariant; namespace QtJson { -class Q_JSON_EXPORT JsonValue { +class Q_JSON_EXPORT QJsonValue { public: enum ValueType { Null = 0x0, @@ -60,21 +60,21 @@ public: Undefined = 0x80 }; - JsonValue(ValueType = Null); - JsonValue(bool b); - JsonValue(double n); - JsonValue(int n); - JsonValue(const QString &s); - JsonValue(const QLatin1String &s); - JsonValue(const JsonArray &a); - JsonValue(const JsonObject &o); + QJsonValue(ValueType = Null); + QJsonValue(bool b); + QJsonValue(double n); + QJsonValue(int n); + QJsonValue(const QString &s); + QJsonValue(const QLatin1String &s); + QJsonValue(const QJsonArray &a); + QJsonValue(const QJsonObject &o); - ~JsonValue(); + ~QJsonValue(); - JsonValue(const JsonValue &other); - JsonValue &operator =(const JsonValue &other); + QJsonValue(const QJsonValue &other); + QJsonValue &operator =(const QJsonValue &other); - static JsonValue fromVariant(const QVariant &variant); + static QJsonValue fromVariant(const QVariant &variant); QVariant toVariant() const; ValueType type() const; @@ -85,29 +85,29 @@ public: void setValue(int); void setValue(const QString &); void setValue(const QLatin1String &); - void setValue(const JsonArray &); - void setValue(const JsonObject &); + void setValue(const QJsonArray &); + void setValue(const QJsonObject &); bool toBool() const; double toNumber() const; int toInt() const; QString toString() const; - JsonArray toArray() const; - JsonObject toObject() const; + QJsonArray toArray() const; + QJsonObject toObject() const; - bool operator==(const JsonValue &other) const; - bool operator!=(const JsonValue &other) const; + bool operator==(const QJsonValue &other) const; + bool operator!=(const QJsonValue &other) const; void detach(); private: // avoid implicit conversions from char * to bool - inline JsonValue(const void *) {} + inline QJsonValue(const void *) {} friend class Data; friend class Value; - friend class JsonArray; - friend class JsonObject; - JsonValue(Private::Data *d, Private::Base *b, const Private::Value& v); + friend class QJsonArray; + friend class QJsonObject; + QJsonValue(Private::Data *d, Private::Base *b, const Private::Value& v); int requiredStorage(bool *compressed) const; uint valueToStore(uint offset) const; void copyData(char *dest, bool compressed) const; diff --git a/src/qjsonwriter.cpp b/src/qjsonwriter.cpp index bbb6773..a18443c 100644 --- a/src/qjsonwriter.cpp +++ b/src/qjsonwriter.cpp @@ -177,32 +177,32 @@ static QByteArray escapedString(const QString &s) static void valueToJson(const Private::Base *b, const Private::Value &v, QByteArray &json, int indent) { - JsonValue::ValueType type = (JsonValue::ValueType)(uint)v.type; + QJsonValue::ValueType type = (QJsonValue::ValueType)(uint)v.type; switch (type) { - case JsonValue::Boolean: + case QJsonValue::Boolean: json += v.toBoolean() ? "true" : "false"; break; - case JsonValue::Number: + case QJsonValue::Number: json += QByteArray::number(v.toNumber(b)); break; - case JsonValue::String: + case QJsonValue::String: json += '"'; json += escapedString(v.toString(b)); json += '"'; break; - case JsonValue::Array: + case QJsonValue::Array: json += "[\n"; arrayContentToJson(static_cast<Private::Array *>(v.objectOrArray(b)), json, indent + 1); json += QByteArray(4*indent, ' '); json += "]"; break; - case JsonValue::Object: + case QJsonValue::Object: json += "{\n"; objectContentToJson(static_cast<Private::Object *>(v.objectOrArray(b)), json, indent + 1); json += QByteArray(4*indent, ' '); json += "}"; break; - case JsonValue::Null: + case QJsonValue::Null: default: json += "null"; } |