MessagePack for C++
Public Member Functions | List of all members
msgpack::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=MSGPACK_NULLPTR, std::size_t initial_buffer_size=MSGPACK_UNPACKER_INIT_BUFFER_SIZE, unpack_limit const &limit=unpack_limit())
 Constructor. More...
 
 unpacker (unpacker &&other)
 
unpackeroperator= (unpacker &&other)
 
 ~unpacker ()
 
void reserve_buffer (std::size_t size=MSGPACK_UNPACKER_RESERVE_SIZE)
 Reserve a buffer memory. More...
 
char * buffer ()
 Get buffer pointer. More...
 
std::size_t buffer_capacity () const
 Get buffer capacity. More...
 
void buffer_consumed (std::size_t size)
 Notify a buffer consumed information to msgpack::unpacker. More...
 
bool next (msgpack::object_handle *result)
 Unpack one msgpack::object. [obsolete]. More...
 
bool next (msgpack::object_handle &result, bool &referenced)
 Unpack one msgpack::object. More...
 
bool next (msgpack::object_handle &result)
 Unpack one msgpack::object. More...
 
std::size_t message_size () const
 Get message size. More...
 
bool execute ()
 
msgpack::object const & data ()
 
msgpack::zonerelease_zone ()
 
void reset_zone ()
 
void reset ()
 
std::size_t parsed_size () const
 Get parsed message size. More...
 
char * nonparsed_buffer ()
 Get the address that is not parsed in the buffer. More...
 
std::size_t nonparsed_size () const
 Get the size of the buffer that is not parsed. More...
 
void skip_nonparsed_buffer (std::size_t size)
 Skip the specified size of non-parsed buffer. More...
 
void remove_nonparsed_buffer ()
 Remove nonparsed buffer and reset the current position as a new start point. More...
 

Detailed Description

Unpacking class for a stream deserialization.

Constructor & Destructor Documentation

◆ unpacker() [1/2]

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

Constructor.

Parameters
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.

References buffer(), COUNTER_SIZE, msgpack::detail::context< VisitorHolder >::init(), msgpack::detail::init_count(), msgpack::detail::unpack_user::set_referenced(), msgpack::detail::unpack_user::set_zone(), and msgpack::detail::context< VisitorHolder >::user().

Referenced by operator=().

◆ unpacker() [2/2]

msgpack::unpacker::unpacker ( unpacker &&  other)
inline

References MSGPACK_NULLPTR.

◆ ~unpacker()

msgpack::unpacker::~unpacker ( )
inline

References msgpack::detail::decr_count().

Referenced by operator=().

Member Function Documentation

◆ buffer()

char * msgpack::unpacker::buffer ( )
inline

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

Referenced by unpacker().

◆ buffer_capacity()

std::size_t msgpack::unpacker::buffer_capacity ( ) const
inline

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

◆ buffer_consumed()

void msgpack::unpacker::buffer_consumed ( std::size_t  size)
inline

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

References msgpack::type::size().

◆ data()

msgpack::object const & msgpack::unpacker::data ( )
inline

for backward compatibility

References msgpack::detail::context< VisitorHolder >::data().

Referenced by next().

◆ execute()

bool msgpack::unpacker::execute ( )
inline

for backward compatibility

◆ message_size()

std::size_t msgpack::unpacker::message_size ( ) const
inline

Get message size.

Returns
Returns parsed_size() + nonparsed_size()

◆ next() [1/3]

bool msgpack::unpacker::next ( msgpack::object_handle result)
inline

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

References next().

◆ next() [2/3]

bool msgpack::unpacker::next ( msgpack::object_handle result,
bool &  referenced 
)
inline

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

References data(), msgpack::detail::unpack_user::referenced(), release_zone(), reset(), msgpack::object_handle::set(), msgpack::detail::context< VisitorHolder >::user(), and msgpack::object_handle::zone().

◆ next() [3/3]

bool msgpack::unpacker::next ( msgpack::object_handle result)
inline

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.

Referenced by next().

◆ nonparsed_buffer()

char * msgpack::unpacker::nonparsed_buffer ( )
inline

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.

◆ nonparsed_size()

std::size_t msgpack::unpacker::nonparsed_size ( ) const
inline

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.

◆ operator=()

unpacker & msgpack::unpacker::operator= ( unpacker &&  other)
inline

References unpacker(), and ~unpacker().

◆ parsed_size()

std::size_t msgpack::unpacker::parsed_size ( ) const
inline

Get parsed message size.

Returns
Parsed message size.

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

◆ release_zone()

msgpack::zone * msgpack::unpacker::release_zone ( )
inline

◆ remove_nonparsed_buffer()

void msgpack::unpacker::remove_nonparsed_buffer ( )
inline

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.

◆ reserve_buffer()

void msgpack::unpacker::reserve_buffer ( std::size_t  size = MSGPACK_UNPACKER_RESERVE_SIZE)
inline

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

References msgpack::type::size().

◆ reset()

void msgpack::unpacker::reset ( )
inline

for backward compatibility

References msgpack::detail::context< VisitorHolder >::init().

Referenced by next().

◆ reset_zone()

void msgpack::unpacker::reset_zone ( )
inline

for backward compatibility

◆ skip_nonparsed_buffer()

void msgpack::unpacker::skip_nonparsed_buffer ( std::size_t  size)
inline

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.

References msgpack::type::size().


The documentation for this class was generated from the following file: