mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-21 06:11:18 +01:00
add msgpack_unpacker_message_size
This commit is contained in:
parent
65ef9cab66
commit
c0baf9b873
10
c/unpack.h
10
c/unpack.h
@ -61,7 +61,8 @@ msgpack_zone* msgpack_unpacker_release_zone(msgpack_unpacker* mpac);
|
||||
|
||||
void msgpack_unpacker_reset(msgpack_unpacker* mpac);
|
||||
|
||||
static inline size_t msgpack_unpacker_parsed_size(const msgpack_unpacker* mpac);
|
||||
static inline size_t msgpack_unpacker_message_size(const msgpack_unpacker* mpac);
|
||||
|
||||
|
||||
|
||||
typedef enum {
|
||||
@ -76,6 +77,8 @@ msgpack_unpack(const char* data, size_t len, size_t* off,
|
||||
msgpack_zone* z, msgpack_object* result);
|
||||
|
||||
|
||||
static inline size_t msgpack_unpacker_parsed_size(const msgpack_unpacker* mpac);
|
||||
|
||||
bool msgpack_unpacker_flush_zone(msgpack_unpacker* mpac);
|
||||
|
||||
bool msgpack_unpacker_expand_buffer(msgpack_unpacker* mpac, size_t size);
|
||||
@ -102,6 +105,11 @@ void msgpack_unpacker_buffer_consumed(msgpack_unpacker* mpac, size_t size)
|
||||
mpac->free -= size;
|
||||
}
|
||||
|
||||
size_t msgpack_unpacker_message_size(const msgpack_unpacker* mpac)
|
||||
{
|
||||
return mpac->parsed - mpac->off + mpac->used;
|
||||
}
|
||||
|
||||
size_t msgpack_unpacker_parsed_size(const msgpack_unpacker* mpac)
|
||||
{
|
||||
return mpac->parsed;
|
||||
|
@ -67,8 +67,8 @@ public:
|
||||
/*! 5.3. after release_zone(), re-initialize unpacker */
|
||||
void reset();
|
||||
|
||||
/*! 6. check if the parsed message size doesn't exceed assumption. */
|
||||
size_t parsed_size() const;
|
||||
/*! 6. check if the size of message doesn't exceed assumption. */
|
||||
size_t message_size() const;
|
||||
|
||||
|
||||
// Basic usage of the unpacker is as following:
|
||||
@ -112,6 +112,7 @@ public:
|
||||
public:
|
||||
// These functions are usable when non-MessagePack message follows after
|
||||
// MessagePack message.
|
||||
size_t parsed_size() const;
|
||||
|
||||
/*! get address of the buffer that is not parsed */
|
||||
char* nonparsed_buffer();
|
||||
@ -218,12 +219,17 @@ inline void unpacker::reset()
|
||||
msgpack_unpacker_reset(this);
|
||||
}
|
||||
|
||||
inline size_t unpacker::message_size() const
|
||||
{
|
||||
return msgpack_unpacker_message_size(this);
|
||||
}
|
||||
|
||||
|
||||
inline size_t unpacker::parsed_size() const
|
||||
{
|
||||
return msgpack_unpacker_parsed_size(this);
|
||||
}
|
||||
|
||||
|
||||
inline char* unpacker::nonparsed_buffer()
|
||||
{
|
||||
return buf + off;
|
||||
|
Loading…
x
Reference in New Issue
Block a user