10 #ifndef MSGPACK_V2_UNPACK_HPP
11 #define MSGPACK_V2_UNPACK_HPP
13 #if MSGPACK_DEFAULT_API_VERSION >= 2
26 struct zone_push_finalizer {
29 void operator()(
char* buffer) {
35 class unpacker :
public parser<unpacker, zone_push_finalizer>,
36 public detail::create_object_visitor {
37 typedef parser<unpacker, zone_push_finalizer> parser_t;
42 unpack_limit
const& limit = unpack_limit())
43 :parser_t(m_finalizer, initial_buffer_size),
44 detail::create_object_visitor(f, user_data, limit),
48 set_referenced(
false);
51 detail::create_object_visitor& visitor() {
return *
this; }
88 msgpack::unique_ptr<msgpack::zone> m_z;
89 zone_push_finalizer m_finalizer;
93 bool ret = parser_t::next();
101 result.
zone().reset();
109 return next(result, referenced);
122 m_finalizer.set_zone(*m_z);
132 inline bool unpacker::flush_zone()
140 set_referenced(
false);
149 const char* data, std::size_t len, std::size_t& off,
bool& referenced,
151 unpack_limit
const& limit
157 std::size_t noff = off;
159 data, len, noff, *z, obj, referenced, f, user_data, limit);
175 const char* data, std::size_t len, std::size_t& off,
177 unpack_limit
const& limit)
184 const char* data, std::size_t len,
bool& referenced,
186 unpack_limit
const& limit)
193 const char* data, std::size_t len,
195 unpack_limit
const& limit)
204 const char* data, std::size_t len, std::size_t& off,
bool& referenced,
206 unpack_limit
const& limit)
211 std::size_t noff = off;
213 data, len, noff, *z, obj, referenced, f, user_data, limit);
219 result.
zone() = msgpack::move(z);
224 result.
zone() = msgpack::move(z);
233 const char* data, std::size_t len, std::size_t& off,
235 unpack_limit
const& limit)
243 const char* data, std::size_t len,
bool& referenced,
245 unpack_limit
const& limit)
253 const char* data, std::size_t len,
255 unpack_limit
const& limit)
265 const char* data, std::size_t len, std::size_t& off,
bool& referenced,
267 unpack_limit
const& limit)
270 std::size_t noff = off;
273 data, len, noff, z, obj, referenced, f, user_data, limit);
290 const char* data, std::size_t len, std::size_t& off,
292 unpack_limit
const& limit)
300 const char* data, std::size_t len,
bool& referenced,
302 unpack_limit
const& limit)
310 const char* data, std::size_t len,
312 unpack_limit
const& limit)
322 unpack_imp(
const char* data, std::size_t len, std::size_t& off,
325 unpack_limit
const& limit = unpack_limit())
327 create_object_visitor v(f, user_data, limit);
328 v.set_zone(result_zone);
330 v.set_referenced(referenced);
332 referenced = v.referenced();
bool referenced() const
Definition: create_object_visitor.hpp:66
The class holds object and zone.
Definition: object.hpp:44
msgpack::unique_ptr< msgpack::zone > & zone()
Get unique_ptr reference of zone.
Definition: object.hpp:90
void set(msgpack::object const &obj)
Definition: object.hpp:64
msgpack::zone * release_zone()
Definition: unpack.hpp:1278
void reset_zone()
Definition: unpack.hpp:1292
msgpack::object const & data()
Definition: unpack.hpp:1273
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.
Definition: unpack.hpp:1063
void reset()
Definition: unpack.hpp:1313
bool next(msgpack::object_handle *result)
Unpack one msgpack::object. [obsolete].
Definition: unpack.hpp:1245
Definition: cpp03_zone.hpp:31
void push_finalizer(void(*func)(void *), void *data)
Definition: cpp03_zone.hpp:311
parse_return parse_imp(const char *data, size_t len, size_t &off, Visitor &v)
parse_return unpack_imp(const char *data, std::size_t len, std::size_t &off, msgpack::zone &result_zone, msgpack::object &result, bool &referenced, unpack_reference_func f=MSGPACK_NULLPTR, void *user_data=MSGPACK_NULLPTR, unpack_limit const &limit=unpack_limit())
Definition: unpack.hpp:1353
void decr_count(void *buffer)
Definition: unpack.hpp:250
void incr_count(void *buffer)
Definition: unpack.hpp:263
object_type
Definition: object_fwd_decl.hpp:27
Definition: adaptor_base.hpp:15
bool(* unpack_reference_func)(msgpack::type::object_type type, std::size_t size, void *user_data)
The type of reference or copy judging function.
Definition: unpack_decl.hpp:74
void unpack(msgpack::object_handle &result, const char *data, std::size_t len, std::size_t &off, msgpack::v3::unpack_reference_func f, void *user_data, msgpack::unpack_limit const &limit)
Definition: unpack.hpp:100
parse_return
Definition: parse_return.hpp:23
@ PARSE_EXTRA_BYTES
Definition: parse_return.hpp:25
@ PARSE_SUCCESS
Definition: parse_return.hpp:24
msgpack::object_handle unpack(const char *data, std::size_t len, std::size_t &off, bool &referenced, unpack_reference_func f, void *user_data, unpack_limit const &limit)
Unpack msgpack::object from a buffer.
Definition: unpack.hpp:1397
Object class that corresponding to MessagePack format object.
Definition: object_fwd.hpp:75
#define MSGPACK_NULLPTR
Definition: cpp_config_decl.hpp:85
#define MSGPACK_UNPACKER_INIT_BUFFER_SIZE
Definition: unpack_decl.hpp:43
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:66