diff options
author | Jose Fonseca <jfonseca@vmware.com> | 2015-05-22 00:03:13 +0100 |
---|---|---|
committer | Jose Fonseca <jfonseca@vmware.com> | 2015-05-27 10:10:17 +0100 |
commit | 84f5e9ad2dd7d3cfc78d42a1e1923d671f41f2bf (patch) | |
tree | 17fd9d384061b03d504b2fa97ad576657aab075c /gui | |
parent | 265d2fd0c890cd69dc3a4aa0414c9077460e8c79 (diff) |
retrace,gui: Object members don't have string marker.
Diffstat (limited to 'gui')
-rw-r--r-- | gui/qubjson.cpp | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/gui/qubjson.cpp b/gui/qubjson.cpp index 90bf77e4..2649a41a 100644 --- a/gui/qubjson.cpp +++ b/gui/qubjson.cpp @@ -108,9 +108,8 @@ readFloat64(QDataStream &stream) static size_t -readSize(QDataStream &stream) +readSize(QDataStream &stream, Marker type) { - Marker type = readMarker(stream); switch (type) { case MARKER_INT8: return readInt8(stream); @@ -131,9 +130,26 @@ readSize(QDataStream &stream) static QString -readString(QDataStream &stream) +readChar(QDataStream &stream) +{ + qint8 c; + stream >> c; + Q_ASSERT(c >= 0); + return QChar(c); +} + + +static size_t +readSize(QDataStream &stream) +{ + Marker type = readMarker(stream); + return readSize(stream, type); +} + + +static QString +readString(QDataStream &stream, size_t size) { - size_t size = readSize(stream); char *buf = new char [size]; stream.readRawData(buf, size); QString str = QString::fromUtf8(buf, size); @@ -142,6 +158,14 @@ readString(QDataStream &stream) } +static QString +readString(QDataStream &stream) +{ + size_t size = readSize(stream); + return readString(stream, size); +} + + static QVariant readVariant(QDataStream &stream, Marker type); @@ -183,8 +207,8 @@ readObject(QDataStream &stream) Marker marker = readMarker(stream); while (marker != MARKER_OBJECT_END && marker != MARKER_EOF) { - Q_ASSERT(marker == MARKER_STRING); - QString name = readString(stream); + size_t nameSize = readSize(stream, marker); + QString name = readString(stream, nameSize); marker = readMarker(stream); QVariant value = readVariant(stream, marker); object[name] = value; @@ -224,8 +248,7 @@ readVariant(QDataStream &stream, Marker type) Q_UNIMPLEMENTED(); return QVariant(); case MARKER_CHAR: - Q_UNIMPLEMENTED(); - return QVariant(); + return readChar(stream); case MARKER_STRING: return readString(stream); case MARKER_ARRAY_BEGIN: |