mirror of
https://github.com/romixlab/qmsgpack.git
synced 2025-06-25 01:21:33 +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)
|
||||
{
|
||||
quint8 *p = (quint8 *)data.data();
|
||||
quint8 *end = p + data.size() - 1;
|
||||
const quint8 *p = reinterpret_cast<const quint8*>(data.data());
|
||||
const quint8 *end = p + data.size() - 1;
|
||||
|
||||
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;
|
||||
QReadWriteLock MsgPackPrivate::unpackers_lock;
|
||||
|
||||
QVariant MsgPackPrivate::unpack(quint8 *p, quint8 *end)
|
||||
QVariant MsgPackPrivate::unpack(const quint8 *p, const quint8 *end)
|
||||
{
|
||||
QVariantList d;
|
||||
|
||||
QVariant v;
|
||||
while (p <= end) {
|
||||
p = unpack_type(v, p);
|
||||
quint8* pos = const_cast<quint8*>(p); // FIXME
|
||||
while (pos <= end) {
|
||||
pos = unpack_type(v, pos);
|
||||
d.append(v);
|
||||
}
|
||||
|
||||
if (p - end > 1)
|
||||
if (pos - end > 1)
|
||||
return QVariant();
|
||||
|
||||
if (d.length() == 1)
|
||||
|
@ -23,7 +23,7 @@ extern QHash<qint8, MsgPack::unpack_user_f> user_unpackers;
|
||||
extern QReadWriteLock unpackers_lock;
|
||||
|
||||
// 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
|
||||
quint8 * unpack_type(QVariant &v, quint8 *p);
|
||||
|
||||
|
Reference in New Issue
Block a user