unpack_decl.hpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. //
  2. // MessagePack for C++ deserializing routine
  3. //
  4. // Copyright (C) 2016 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_V2_UNPACK_DECL_HPP
  11. #define MSGPACK_V2_UNPACK_DECL_HPP
  12. #include "msgpack/v1/unpack_decl.hpp"
  13. namespace msgpack {
  14. /// @cond
  15. MSGPACK_API_VERSION_NAMESPACE(v2) {
  16. /// @endcond
  17. using v1::unpack_reference_func;
  18. using v1::unpack_error;
  19. using v1::parse_error;
  20. using v1::insufficient_bytes;
  21. using v1::size_overflow;
  22. using v1::array_size_overflow;
  23. using v1::map_size_overflow;
  24. using v1::str_size_overflow;
  25. using v1::bin_size_overflow;
  26. using v1::ext_size_overflow;
  27. using v1::depth_size_overflow;
  28. using v1::unpack_limit;
  29. namespace detail {
  30. using v1::detail::unpack_user;
  31. using v1::detail::unpack_uint8;
  32. using v1::detail::unpack_uint16;
  33. using v1::detail::unpack_uint32;
  34. using v1::detail::unpack_uint64;
  35. using v1::detail::unpack_int8;
  36. using v1::detail::unpack_int16;
  37. using v1::detail::unpack_int32;
  38. using v1::detail::unpack_int64;
  39. using v1::detail::unpack_float;
  40. using v1::detail::unpack_double;
  41. using v1::detail::unpack_nil;
  42. using v1::detail::unpack_true;
  43. using v1::detail::unpack_false;
  44. using v1::detail::unpack_array;
  45. using v1::detail::unpack_array_item;
  46. using v1::detail::unpack_map;
  47. using v1::detail::unpack_map_item;
  48. using v1::detail::unpack_str;
  49. using v1::detail::unpack_bin;
  50. using v1::detail::unpack_ext;
  51. using v1::detail::unpack_stack;
  52. using v1::detail::init_count;
  53. using v1::detail::decr_count;
  54. using v1::detail::incr_count;
  55. using v1::detail::get_count;
  56. using v1::detail::fix_tag;
  57. using v1::detail::value;
  58. using v1::detail::load;
  59. } // detail
  60. using v1::unpacked;
  61. /// Unpacking class for a stream deserialization.
  62. class unpacker;
  63. template <typename unpack_visitor, typename referenced_buffer_hook>
  64. class basic_unpacker;
  65. /// Unpack msgpack::object from a buffer.
  66. /**
  67. * @param data The pointer to the buffer.
  68. * @param len The length of the buffer.
  69. * @param off The offset position of the buffer. It is read and overwritten.
  70. * @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
  71. * @param f A judging function that msgpack::object refer to the buffer.
  72. * @param user_data This parameter is passed to f.
  73. * @param limit The size limit information of msgpack::object.
  74. *
  75. * @return object_handle that contains unpacked data.
  76. *
  77. */
  78. msgpack::object_handle unpack(
  79. const char* data, std::size_t len, std::size_t& off, bool& referenced,
  80. unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
  81. /// Unpack msgpack::object from a buffer.
  82. /**
  83. * @param data The pointer to the buffer.
  84. * @param len The length of the buffer.
  85. * @param off The offset position of the buffer. It is read and overwritten.
  86. * @param f A judging function that msgpack::object refer to the buffer.
  87. * @param user_data This parameter is passed to f.
  88. * @param limit The size limit information of msgpack::object.
  89. *
  90. * @return object_handle that contains unpacked data.
  91. *
  92. */
  93. msgpack::object_handle unpack(
  94. const char* data, std::size_t len, std::size_t& off,
  95. unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
  96. /// Unpack msgpack::object from a buffer.
  97. /**
  98. * @param data The pointer to the buffer.
  99. * @param len The length of the buffer.
  100. * @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
  101. * @param f A judging function that msgpack::object refer to the buffer.
  102. * @param user_data This parameter is passed to f.
  103. * @param limit The size limit information of msgpack::object.
  104. *
  105. * @return object_handle that contains unpacked data.
  106. *
  107. */
  108. msgpack::object_handle unpack(
  109. const char* data, std::size_t len, bool& referenced,
  110. unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
  111. /// Unpack msgpack::object from a buffer.
  112. /**
  113. * @param data The pointer to the buffer.
  114. * @param len The length of the buffer.
  115. * @param f A judging function that msgpack::object refer to the buffer.
  116. * @param user_data This parameter is passed to f.
  117. * @param limit The size limit information of msgpack::object.
  118. *
  119. * @return object_handle that contains unpacked data.
  120. *
  121. */
  122. msgpack::object_handle unpack(
  123. const char* data, std::size_t len,
  124. unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
  125. /// Unpack msgpack::object from a buffer.
  126. /**
  127. * @param result The object_handle that contains unpacked data.
  128. * @param data The pointer to the buffer.
  129. * @param len The length of the buffer.
  130. * @param off The offset position of the buffer. It is read and overwritten.
  131. * @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
  132. * @param f A judging function that msgpack::object refer to the buffer.
  133. * @param user_data This parameter is passed to f.
  134. * @param limit The size limit information of msgpack::object.
  135. *
  136. *
  137. */
  138. void unpack(
  139. msgpack::object_handle& result,
  140. const char* data, std::size_t len, std::size_t& off, bool& referenced,
  141. unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
  142. /// Unpack msgpack::object from a buffer.
  143. /**
  144. * @param result The object_handle that contains unpacked data.
  145. * @param data The pointer to the buffer.
  146. * @param len The length of the buffer.
  147. * @param off The offset position of the buffer. It is read and overwritten.
  148. * @param f A judging function that msgpack::object refer to the buffer.
  149. * @param user_data This parameter is passed to f.
  150. * @param limit The size limit information of msgpack::object.
  151. *
  152. *
  153. */
  154. void unpack(
  155. msgpack::object_handle& result,
  156. const char* data, std::size_t len, std::size_t& off,
  157. unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
  158. /// Unpack msgpack::object from a buffer.
  159. /**
  160. * @param result The object_handle that contains unpacked data.
  161. * @param data The pointer to the buffer.
  162. * @param len The length of the buffer.
  163. * @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
  164. * @param f A judging function that msgpack::object refer to the buffer.
  165. * @param user_data This parameter is passed to f.
  166. * @param limit The size limit information of msgpack::object.
  167. *
  168. *
  169. */
  170. void unpack(
  171. msgpack::object_handle& result,
  172. const char* data, std::size_t len, bool& referenced,
  173. unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
  174. /// Unpack msgpack::object from a buffer.
  175. /**
  176. * @param result The object_handle that contains unpacked data.
  177. * @param data The pointer to the buffer.
  178. * @param len The length of the buffer.
  179. * @param f A judging function that msgpack::object refer to the buffer.
  180. * @param user_data This parameter is passed to f.
  181. * @param limit The size limit information of msgpack::object.
  182. *
  183. *
  184. */
  185. void unpack(
  186. msgpack::object_handle& result,
  187. const char* data, std::size_t len,
  188. unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
  189. /// Unpack msgpack::object from a buffer.
  190. /**
  191. * @param z The msgpack::zone that is used as a memory of unpacked msgpack objects.
  192. * @param data The pointer to the buffer.
  193. * @param len The length of the buffer.
  194. * @param off The offset position of the buffer. It is read and overwritten.
  195. * @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
  196. * @param f A judging function that msgpack::object refer to the buffer.
  197. * @param user_data This parameter is passed to f.
  198. * @param limit The size limit information of msgpack::object.
  199. *
  200. * @return msgpack::object that contains unpacked data.
  201. *
  202. */
  203. msgpack::object unpack(
  204. msgpack::zone& z,
  205. const char* data, std::size_t len, std::size_t& off, bool& referenced,
  206. unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
  207. /// Unpack msgpack::object from a buffer.
  208. /**
  209. * @param z The msgpack::zone that is used as a memory of unpacked msgpack objects.
  210. * @param data The pointer to the buffer.
  211. * @param len The length of the buffer.
  212. * @param off The offset position of the buffer. It is read and overwritten.
  213. * @param f A judging function that msgpack::object refer to the buffer.
  214. * @param user_data This parameter is passed to f.
  215. * @param limit The size limit information of msgpack::object.
  216. *
  217. * @return msgpack::object that contains unpacked data.
  218. *
  219. */
  220. msgpack::object unpack(
  221. msgpack::zone& z,
  222. const char* data, std::size_t len, std::size_t& off,
  223. unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
  224. /// Unpack msgpack::object from a buffer.
  225. /**
  226. * @param z The msgpack::zone that is used as a memory of unpacked msgpack objects.
  227. * @param data The pointer to the buffer.
  228. * @param len The length of the buffer.
  229. * @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
  230. * @param f A judging function that msgpack::object refer to the buffer.
  231. * @param user_data This parameter is passed to f.
  232. * @param limit The size limit information of msgpack::object.
  233. *
  234. * @return msgpack::object that contains unpacked data.
  235. *
  236. */
  237. msgpack::object unpack(
  238. msgpack::zone& z,
  239. const char* data, std::size_t len, bool& referenced,
  240. unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
  241. /// Unpack msgpack::object from a buffer.
  242. /**
  243. * @param z The msgpack::zone that is used as a memory of unpacked msgpack objects.
  244. * @param data The pointer to the buffer.
  245. * @param len The length of the buffer.
  246. * @param f A judging function that msgpack::object refer to the buffer.
  247. * @param user_data This parameter is passed to f.
  248. * @param limit The size limit information of msgpack::object.
  249. *
  250. * @return msgpack::object that contains unpacked data.
  251. *
  252. */
  253. msgpack::object unpack(
  254. msgpack::zone& z,
  255. const char* data, std::size_t len,
  256. unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
  257. namespace detail {
  258. parse_return
  259. unpack_imp(const char* data, std::size_t len, std::size_t& off,
  260. msgpack::zone& result_zone, msgpack::object& result, bool& referenced,
  261. unpack_reference_func f, void* user_data,
  262. unpack_limit const& limit);
  263. } // detail
  264. /// @cond
  265. } // MSGPACK_API_VERSION_NAMESPACE(v2)
  266. /// @endcond
  267. } // namespace msgpack
  268. #endif // MSGPACK_V2_UNPACK_DECL_HPP