mirror of
https://github.com/romixlab/qmsgpack.git
synced 2025-07-29 18:07:16 +02:00
interim fix for the "const QByteArray&" casts
Did not dive much into the address logic here, but I think we would be better of with index counting instead of addresses.
This commit is contained in:
@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
QVariant MsgPack::unpack(const QByteArray &data)
|
QVariant MsgPack::unpack(const QByteArray &data)
|
||||||
{
|
{
|
||||||
quint8 *p = (quint8 *)data.data();
|
const quint8 *p = reinterpret_cast<const quint8*>(data.data());
|
||||||
quint8 *end = p + data.size() - 1;
|
const quint8 *end = p + data.size() - 1;
|
||||||
|
|
||||||
return MsgPackPrivate::unpack(p, end);
|
return MsgPackPrivate::unpack(p, end);
|
||||||
}
|
}
|
||||||
|
@ -47,17 +47,18 @@ MsgPackPrivate::type_parser_f MsgPackPrivate::unpackers[32] = {
|
|||||||
QHash<qint8, MsgPack::unpack_user_f> MsgPackPrivate::user_unpackers;
|
QHash<qint8, MsgPack::unpack_user_f> MsgPackPrivate::user_unpackers;
|
||||||
QReadWriteLock MsgPackPrivate::unpackers_lock;
|
QReadWriteLock MsgPackPrivate::unpackers_lock;
|
||||||
|
|
||||||
QVariant MsgPackPrivate::unpack(quint8 *p, quint8 *end)
|
QVariant MsgPackPrivate::unpack(const quint8 *p, const quint8 *end)
|
||||||
{
|
{
|
||||||
QVariantList d;
|
QVariantList d;
|
||||||
|
|
||||||
QVariant v;
|
QVariant v;
|
||||||
while (p <= end) {
|
quint8* pos = const_cast<quint8*>(p); // FIXME
|
||||||
p = unpack_type(v, p);
|
while (pos <= end) {
|
||||||
|
pos = unpack_type(v, pos);
|
||||||
d.append(v);
|
d.append(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p - end > 1)
|
if (pos - end > 1)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
if (d.length() == 1)
|
if (d.length() == 1)
|
||||||
|
@ -23,7 +23,7 @@ extern QHash<qint8, MsgPack::unpack_user_f> user_unpackers;
|
|||||||
extern QReadWriteLock unpackers_lock;
|
extern QReadWriteLock unpackers_lock;
|
||||||
|
|
||||||
// goes from p to end unpacking types with unpack_type function below
|
// goes from p to end unpacking types with unpack_type function below
|
||||||
QVariant unpack(quint8 *p, quint8 *end);
|
QVariant unpack(const quint8 *p, const quint8 *end);
|
||||||
// unpack some type, can be called recursively from other unpack functions
|
// unpack some type, can be called recursively from other unpack functions
|
||||||
quint8 * unpack_type(QVariant &v, quint8 *p);
|
quint8 * unpack_type(QVariant &v, quint8 *p);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user