diff options
author | Lars Knoll <lars.knoll@nokia.com> | 2012-01-09 10:15:22 +0100 |
---|---|---|
committer | Jamey Hicks <jamey.hicks@nokia.com> | 2012-01-09 12:31:55 +0100 |
commit | 4d279270b41056f9494d78c3e855d96c2e735f0c (patch) | |
tree | 1a6d6b40c6073055bcc53e86967c0591216264c9 | |
parent | 888f593502f68cb059db2269c5b0593546b5898c (diff) |
Move the QBJS tag into QJsonDocument
Change-Id: Idc8f6c31d7b54dd53cb8a4b04b043815bddd3913
Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Jamey Hicks <jamey.hicks@nokia.com>
-rw-r--r-- | src/qjson.cpp | 4 | ||||
-rw-r--r-- | src/qjson_p.h | 5 | ||||
-rw-r--r-- | src/qjsondocument.cpp | 2 | ||||
-rw-r--r-- | src/qjsondocument.h | 2 | ||||
-rw-r--r-- | src/qjsonglobal.h | 2 | ||||
-rw-r--r-- | src/qjsonparser.cpp | 2 |
6 files changed, 9 insertions, 8 deletions
diff --git a/src/qjson.cpp b/src/qjson.cpp index c05b7bc..1148db5 100644 --- a/src/qjson.cpp +++ b/src/qjson.cpp @@ -69,7 +69,7 @@ void Data::compact() int size = sizeof(Base) + reserve + base->length*sizeof(offset); int alloc = sizeof(Header) + size; Header *h = (Header *) malloc(alloc); - h->tag = QBJS_Tag; + h->tag = QJsonDocument::Tag; h->version = 1; Base *b = h->root(); b->size = size; @@ -126,7 +126,7 @@ void Data::validate() if (valid != Unchecked) return; - if (header->tag != QBJS_Tag || header->version != 1u) { + if (header->tag != QJsonDocument::Tag || header->version != 1u) { valid = Invalid; return; } diff --git a/src/qjson_p.h b/src/qjson_p.h index 11814f7..b97a414 100644 --- a/src/qjson_p.h +++ b/src/qjson_p.h @@ -56,6 +56,7 @@ #include <qjsonglobal.h> #include <qjsonobject.h> #include <qjsonvalue.h> +#include <qjsondocument.h> #include <qjsonarray.h> #include <qbasicatomic.h> #include <qstring.h> @@ -597,7 +598,7 @@ struct Data { alloc = sizeof(Header) + sizeof(Base) + reserved + sizeof(offset); header = (Header *)malloc(alloc); - header->tag = QBJS_Tag; + header->tag = QJsonDocument::Tag; header->version = 1; Base *b = header->root(); b->size = sizeof(Base); @@ -641,7 +642,7 @@ struct Data { char *raw = (char *)malloc(size); memcpy(raw + sizeof(Header), b, b->size); Header *h = (Header *)raw; - h->tag = QBJS_Tag; + h->tag = QJsonDocument::Tag; h->version = 1; Data *d = new Data(raw, size); d->compactionCounter = compactionCounter; diff --git a/src/qjsondocument.cpp b/src/qjsondocument.cpp index 6816534..027a611 100644 --- a/src/qjsondocument.cpp +++ b/src/qjsondocument.cpp @@ -107,7 +107,7 @@ 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 || + h->tag != QJsonDocument::Tag || h->version != 1u || sizeof(Private::Header) + h->root()->size > (uint)data.size()) return QJsonDocument(); diff --git a/src/qjsondocument.h b/src/qjsondocument.h index 4142e62..818dbd8 100644 --- a/src/qjsondocument.h +++ b/src/qjsondocument.h @@ -51,6 +51,8 @@ namespace QtJson { class Q_JSON_EXPORT QJsonDocument { public: + static const uint Tag = ('q') | ('b' << 8) | ('j' << 16) | ('s' << 24); + QJsonDocument(); QJsonDocument(const QJsonObject &object); QJsonDocument(const QJsonArray &array); diff --git a/src/qjsonglobal.h b/src/qjsonglobal.h index b5f6364..5295061 100644 --- a/src/qjsonglobal.h +++ b/src/qjsonglobal.h @@ -67,8 +67,6 @@ namespace QtJson class QJsonArray; class QJsonDocument; class QJsonParser; - - const uint QBJS_Tag = ('q') | ('b' << 8) | ('j' << 16) | ('s' << 24); } #endif // QJSONGLOBAL_H diff --git a/src/qjsonparser.cpp b/src/qjsonparser.cpp index f153ec1..df23ae3 100644 --- a/src/qjsonparser.cpp +++ b/src/qjsonparser.cpp @@ -163,7 +163,7 @@ QtJson::QJsonDocument QJsonParser::parse() // fill in Header data Private::Header *h = (Private::Header *)data; - h->tag = QBJS_Tag; + h->tag = QJsonDocument::Tag; h->version = 1u; current = sizeof(Private::Header); |