Hideaki Tai / msgpack-embedded

Dependents:   hello_message_pack

Embed: (wiki syntax)

« Back to documentation index

unpacker Class Reference

unpacker Class Reference

Unpacking class for a stream deserialization. More...

#include <unpack.hpp>

Public Member Functions

 unpacker (unpack_reference_func f=&unpacker::default_reference_func, void *user_data=nullptr, std::size_t initial_buffer_size=MSGPACK_UNPACKER_INIT_BUFFER_SIZE, unpack_limit const &limit=unpack_limit())
 Constructor.
void reserve_buffer (std::size_t size=MSGPACK_UNPACKER_RESERVE_SIZE)
 Reserve a buffer memory.
char * buffer ()
 Get buffer pointer.
std::size_t buffer_capacity () const
 Get buffer capacity.
void buffer_consumed (std::size_t size)
 Notify a buffer consumed information to msgpack::unpacker.
bool next (unpacked *result)
 Unpack one msgpack::object. [obsolete].
bool next (unpacked &result, bool &referenced)
 Unpack one msgpack::object.
bool next (unpacked &result)
 Unpack one msgpack::object.
std::size_t message_size () const
 Get message size.
bool execute ()
msgpack::object const & data ()
msgpack::zone * release_zone ()
void reset_zone ()
void reset ()
std::size_t parsed_size () const
 Get parsed message size.
char * nonparsed_buffer ()
 Get the address that is not parsed in the buffer.
std::size_t nonparsed_size () const
 Get the size of the buffer that is not parsed.
void skip_nonparsed_buffer (std::size_t size)
 Skip the specified size of non-parsed buffer.
void remove_nonparsed_buffer ()
 Remove nonparsed buffer and reset the current position as a new start point.

Detailed Description

Unpacking class for a stream deserialization.

Definition at line 1025 of file unpack.hpp.


Constructor & Destructor Documentation

unpacker ( unpack_reference_func  f = &unpacker::default_reference_func,
void *  user_data = nullptr,
std::size_t  initial_buffer_size = MSGPACK_UNPACKER_INIT_BUFFER_SIZE,
unpack_limit const &  limit = unpack_limit() 
)

Constructor.

Parameters:
referencedIf the unpacked object contains reference of the buffer, then set as true, otherwise false.
fA judging function that msgpack::object refer to the buffer.
user_dataThis parameter is passed to f.
initial_buffer_sizeThe memory size to allocate when unpacker is constructed.
limitThe size limit information of msgpack::object.

Definition at line 1467 of file unpack.hpp.


Member Function Documentation

char * buffer (  )

Get buffer pointer.

You need to care about the memory is enable between buffer() and buffer() + buffer_capacity() See: https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_unpacker#msgpack-controls-a-buffer

Definition at line 1609 of file unpack.hpp.

std::size_t buffer_capacity (  ) const

Get buffer capacity.

Returns:
The memory size that you can write.

See: https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_unpacker#msgpack-controls-a-buffer

Definition at line 1614 of file unpack.hpp.

void buffer_consumed ( std::size_t  size )

Notify a buffer consumed information to msgpack::unpacker.

Parameters:
sizeThe size of memory that you consumed.

After copying the data to the memory that is pointed by buffer(), you need to call the function to notify how many bytes are consumed. Then you can call next() functions.

See: https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_unpacker#msgpack-controls-a-buffer

Definition at line 1619 of file unpack.hpp.

msgpack::object const & data (  )

for backward compatibility

Definition at line 1684 of file unpack.hpp.

bool execute (  )

for backward compatibility

Definition at line 1660 of file unpack.hpp.

std::size_t message_size (  ) const

Get message size.

Returns:
Returns parsed_size() + nonparsed_size()

Definition at line 1731 of file unpack.hpp.

bool next ( unpacked result )

Unpack one msgpack::object.

Parameters:
resultThe object that contains unpacked data.
Returns:
If one msgpack::object is unpacked, then return true, if msgpack::object is incomplete and additional data is required, then return false. If data format is invalid, throw msgpack::parse_error.

See: https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_unpacker#msgpack-controls-a-buffer

Definition at line 1648 of file unpack.hpp.

bool next ( unpacked result )

Unpack one msgpack::object. [obsolete].

Parameters:
resultThe object that contains unpacked data.
Returns:
If one msgpack::object is unpacked, then return true, if msgpack::object is incomplete and additional data is required, then return false. If data format is invalid, throw msgpack::parse_error.

See: https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_unpacker#msgpack-controls-a-buffer This function is obsolete. Use the reference inteface version of next() function instead of the pointer interface version.

Definition at line 1654 of file unpack.hpp.

bool next ( unpacked result,
bool &  referenced 
)

Unpack one msgpack::object.

Parameters:
resultThe object that contains unpacked data.
referencedIf the unpacked object contains reference of the buffer, then set as true, otherwise false.
Returns:
If one msgpack::object is unpacked, then return true, if msgpack::object is incomplete and additional data is required, then return false. If data format is invalid, throw msgpack::parse_error.

See: https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_unpacker#msgpack-controls-a-buffer

Definition at line 1625 of file unpack.hpp.

char * nonparsed_buffer (  )

Get the address that is not parsed in the buffer.

Returns:
Address of the buffer that is not parsed

This function is usable when non-MessagePack message follows after MessagePack message.

Definition at line 1741 of file unpack.hpp.

std::size_t nonparsed_size (  ) const

Get the size of the buffer that is not parsed.

Returns:
Size of the buffer that is not parsed

This function is usable when non-MessagePack message follows after MessagePack message.

Definition at line 1746 of file unpack.hpp.

std::size_t parsed_size (  ) const

Get parsed message size.

Returns:
Parsed message size.

This function is usable when non-MessagePack message follows after MessagePack message.

Definition at line 1736 of file unpack.hpp.

msgpack::zone * release_zone (  )

for backward compatibility

Definition at line 1689 of file unpack.hpp.

void remove_nonparsed_buffer (  )

Remove nonparsed buffer and reset the current position as a new start point.

This function is usable when non-MessagePack message follows after MessagePack message.

Definition at line 1756 of file unpack.hpp.

void reserve_buffer ( std::size_t  size = MSGPACK_UNPACKER_RESERVE_SIZE )

Reserve a buffer memory.

Parameters:
sizeThe size of allocating memory.

After returning this function, buffer_capacity() returns at least 'size'. See: https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_unpacker#msgpack-controls-a-buffer

Definition at line 1528 of file unpack.hpp.

void reset (  )

for backward compatibility

Definition at line 1724 of file unpack.hpp.

void reset_zone (  )

for backward compatibility

Definition at line 1703 of file unpack.hpp.

void skip_nonparsed_buffer ( std::size_t  size )

Skip the specified size of non-parsed buffer.

Parameters:
sizeto skip

Note that the `size' argument must be smaller than nonparsed_size(). This function is usable when non-MessagePack message follows after MessagePack message.

Definition at line 1751 of file unpack.hpp.