MessagePack for C++
x3_unpack.hpp
Go to the documentation of this file.
1 //
2 // MessagePack for C++ deserializing routine
3 //
4 // Copyright (C) 2018 KONDO Takatoshi
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 // (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 //
10 #ifndef MSGPACK_V3_X3_UNPACK_HPP
11 #define MSGPACK_V3_X3_UNPACK_HPP
12 
13 #if defined(MSGPACK_USE_X3_PARSE)
14 
15 #include <boost/version.hpp>
16 
17 #if BOOST_VERSION >= 106100
18 
19 #include "msgpack/versioning.hpp"
22 #include "msgpack/x3_parse.hpp"
23 
24 namespace msgpack {
25 
29 
30 
31 template <typename Iterator>
33  Iterator&& begin, Iterator&& end,
34  bool& referenced,
35  unpack_reference_func f, void* user_data,
36  unpack_limit const& limit)
37 {
38  msgpack::object obj;
39  msgpack::unique_ptr<msgpack::zone> z(new msgpack::zone);
40  referenced = false;
42  std::forward<Iterator>(begin), std::forward<Iterator>(end), *z, obj, referenced, f, user_data, limit);
43  return msgpack::object_handle(obj, msgpack::move(z));
44 }
45 
46 template <typename Iterator>
48  Iterator&& begin, Iterator&& end,
49  unpack_reference_func f, void* user_data,
50  unpack_limit const& limit)
51 {
52  bool referenced;
53  return unpack(std::forward<Iterator>(begin), std::forward<Iterator>(end), referenced, f, user_data, limit);
54 }
55 
56 template <typename Iterator>
57 inline msgpack::object unpack(
58  msgpack::zone& z,
59  Iterator&& begin, Iterator&& end,
60  bool& referenced,
61  unpack_reference_func f, void* user_data,
62  unpack_limit const& limit)
63 {
64  msgpack::object obj;
65  referenced = false;
67  std::forward<Iterator>(begin), std::forward<Iterator>(end), z, obj, referenced, f, user_data, limit);
68  return obj;
69 }
70 
71 template <typename Iterator>
72 inline msgpack::object unpack(
73  msgpack::zone& z,
74  Iterator&& begin, Iterator&& end,
75  unpack_reference_func f, void* user_data,
76  unpack_limit const& limit)
77 {
78  bool referenced;
79  return unpack(
80  z, std::forward<Iterator>(begin), std::forward<Iterator>(end), referenced, f, user_data, limit);
81 }
82 
84 } // MSGPACK_API_VERSION_NAMESPACE(v3)
86 
87 } // namespace msgpack
88 
89 #else // BOOST_VERSION >= 106100
90 
91 #error Boost 1.61.0 or later is required to use x3 parse
92 
93 #endif // BOOST_VERSION >= 106100
94 
95 #endif // defined(MSGPACK_USE_X3_PARSE)
96 
97 #endif // MSGPACK_V3_X3_UNPACK_HPP
The class holds object and zone.
Definition: object.hpp:44
Definition: cpp03_zone.hpp:31
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
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
msgpack::object_kv * end(msgpack::object_map &map)
Definition: iterator.hpp:25
msgpack::object_kv * begin(msgpack::object_map &map)
Definition: iterator.hpp:23
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_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:66