mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 10:19:51 +00:00
fix msgpack::unpack_return
This commit is contained in:
parent
4d708aa4da
commit
43360e3786
3 changed files with 16 additions and 11 deletions
|
|
@ -30,6 +30,7 @@ template <typename Stream>
|
|||
class packer {
|
||||
public:
|
||||
packer(Stream& s);
|
||||
~packer();
|
||||
|
||||
public:
|
||||
template <typename T>
|
||||
|
|
@ -129,6 +130,9 @@ private:
|
|||
template <typename Stream>
|
||||
packer<Stream>::packer(Stream& s) : m_stream(s) { }
|
||||
|
||||
template <typename Stream>
|
||||
packer<Stream>::~packer() { }
|
||||
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& packer<Stream>::pack_uint8(uint8_t d)
|
||||
{ _pack_uint8(m_stream, d); return *this; }
|
||||
|
|
|
|||
|
|
@ -128,10 +128,10 @@ private:
|
|||
|
||||
|
||||
typedef enum {
|
||||
MSGPACK_UNPACK_SUCCESS = 2,
|
||||
MSGPACK_UNPACK_EXTRA_BYTES = 1,
|
||||
MSGPACK_UNPACK_CONTINUE = 0,
|
||||
MSGPACK_UNPACK_PARSE_ERROR = -1,
|
||||
UNPACK_SUCCESS = 2,
|
||||
UNPACK_EXTRA_BYTES = 1,
|
||||
UNPACK_CONTINUE = 0,
|
||||
UNPACK_PARSE_ERROR = -1,
|
||||
} unpack_return;
|
||||
|
||||
static unpack_return unpack(const char* data, size_t len, size_t* off,
|
||||
|
|
@ -249,20 +249,20 @@ inline object unpack(const char* data, size_t len, zone& z, size_t* off)
|
|||
object result;
|
||||
|
||||
switch( msgpack::unpack(data, len, off, &z, &result) ) {
|
||||
case MSGPACK_UNPACK_SUCCESS:
|
||||
case UNPACK_SUCCESS:
|
||||
return result;
|
||||
|
||||
case MSGPACK_UNPACK_EXTRA_BYTES:
|
||||
case UNPACK_EXTRA_BYTES:
|
||||
if(off) {
|
||||
return result;
|
||||
} else {
|
||||
throw unpack_error("extra bytes");
|
||||
}
|
||||
|
||||
case MSGPACK_UNPACK_CONTINUE:
|
||||
case UNPACK_CONTINUE:
|
||||
throw unpack_error("insufficient bytes");
|
||||
|
||||
case MSGPACK_UNPACK_PARSE_ERROR:
|
||||
case UNPACK_PARSE_ERROR:
|
||||
default:
|
||||
throw unpack_error("parse error");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue