MessagePack for C++
Public Member Functions | List of all members
msgpack::unpacker Class Reference

Unpacking class for a stream deserialization. More...

#include <unpack.hpp>

Inheritance diagram for msgpack::unpacker:
msgpack::parser< unpacker, zone_push_finalizer > msgpack::detail::create_object_visitor msgpack::detail::context< unpacker >

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...
 
 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())
 
detail::create_object_visitorvisitor ()
 
bool next (msgpack::object_handle &result, bool &referenced)
 Unpack one msgpack::object. More...
 
bool next (msgpack::object_handle &result)
 Unpack one msgpack::object. More...
 
msgpack::zonerelease_zone ()
 
void reset_zone ()
 
bool flush_zone ()
 
- Public Member Functions inherited from msgpack::parser< unpacker, zone_push_finalizer >
 parser (zone_push_finalizer &hook, std::size_t initial_buffer_size=MSGPACK_UNPACKER_INIT_BUFFER_SIZE)
 Constructor. More...
 
 parser (this_type &&other)
 
 parser (const this_type &)=delete
 
this_typeoperator= (this_type &&other)
 
this_typeoperator= (const this_type &)=delete
 
 ~parser ()
 
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 ()
 Unpack one msgpack::object. More...
 
std::size_t message_size () const
 Get message size. More...
 
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...
 
void reset ()
 
- Public Member Functions inherited from msgpack::detail::context< unpacker >
 context (unpack_reference_func f, void *user_data, unpack_limit const &limit)
 
 context ()
 
void init ()
 
void init ()
 
msgpack::object const & data () const
 
unpack_useruser ()
 
unpack_user const & user () const
 
int execute (const char *data, std::size_t len, std::size_t &off)
 
parse_return execute (const char *data, std::size_t len, std::size_t &off)
 
void check_ext_size (std::size_t size)
 
- Public Member Functions inherited from msgpack::detail::create_object_visitor
 create_object_visitor (unpack_reference_func f, void *user_data, unpack_limit const &limit)
 
 create_object_visitor (create_object_visitor &&other)
 
create_object_visitoroperator= (create_object_visitor &&other)
 
void init ()
 
msgpack::object const & data () const
 
msgpack::zone const & zone () const
 
msgpack::zonezone ()
 
void set_zone (msgpack::zone &zone)
 
bool referenced () const
 
void set_referenced (bool referenced)
 
bool visit_nil ()
 
bool visit_boolean (bool v)
 
bool visit_positive_integer (uint64_t v)
 
bool visit_negative_integer (int64_t v)
 
bool visit_float (double v)
 
bool visit_str (const char *v, uint32_t size)
 
bool visit_bin (const char *v, uint32_t size)
 
bool visit_ext (const char *v, uint32_t size)
 
bool start_array (uint32_t num_elements)
 
bool start_array_item ()
 
bool end_array_item ()
 
bool end_array ()
 
bool start_map (uint32_t num_kv_pairs)
 
bool start_map_key ()
 
bool end_map_key ()
 
bool start_map_value ()
 
bool end_map_value ()
 
bool end_map ()
 
void parse_error (size_t, size_t)
 
void insufficient_bytes (size_t, size_t)
 

Additional Inherited Members

- Public Attributes inherited from msgpack::detail::create_object_visitor
unpack_reference_func m_func
 
void * m_user_data
 
unpack_limit m_limit
 
msgpack::object m_obj
 
std::vector< msgpack::object * > m_stack
 
msgpack::zonem_zone
 
bool m_referenced
 
- Protected Member Functions inherited from msgpack::parser< unpacker, zone_push_finalizer >
char * get_raw_buffer ()
 

Detailed Description

Unpacking class for a stream deserialization.

Constructor & Destructor Documentation

◆ unpacker() [1/3]

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

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/3]

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

References MSGPACK_NULLPTR.

◆ ~unpacker()

msgpack::unpacker::~unpacker ( )
inline

References msgpack::detail::decr_count().

Referenced by operator=().

◆ unpacker() [3/3]

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

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

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

◆ flush_zone()

bool msgpack::unpacker::flush_zone ( )

◆ message_size()

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

Get message size.

Returns
Returns parsed_size() + nonparsed_size()

◆ next() [1/5]

bool msgpack::unpacker::next ( msgpack::object_handle 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

◆ next() [2/5]

bool msgpack::unpacker::next ( msgpack::object_handle 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

◆ next() [3/5]

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.

References msgpack::parser< unpacker, zone_push_finalizer >::next().

◆ next() [4/5]

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() [5/5]

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 msgpack::parser< unpacker, zone_push_finalizer >::next(), and msgpack::detail::create_object_visitor::referenced().

◆ 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

◆ 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() [1/2]

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

◆ release_zone() [2/2]

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

◆ reset()

void msgpack::unpacker::reset ( )
inline

for backward compatibility

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

Referenced by next().

◆ reset_zone() [1/2]

void msgpack::unpacker::reset_zone ( )

◆ reset_zone() [2/2]

void msgpack::unpacker::reset_zone ( )
inline

◆ 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().

◆ visitor()

detail::create_object_visitor& msgpack::unpacker::visitor ( )
inline

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