x3_unpack.hpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. #if defined(MSGPACK_USE_X3_PARSE)
  13. #include <boost/version.hpp>
  14. #if BOOST_VERSION >= 106100
  15. #include "msgpack/versioning.hpp"
  16. #include "msgpack/create_object_visitor.hpp"
  17. #include "msgpack/x3_unpack_decl.hpp"
  18. #include "msgpack/x3_parse.hpp"
  19. namespace msgpack {
  20. /// @cond
  21. MSGPACK_API_VERSION_NAMESPACE(v3) {
  22. /// @endcond
  23. template <typename Iterator>
  24. inline msgpack::object_handle unpack(
  25. Iterator&& begin, Iterator&& end,
  26. bool& referenced,
  27. unpack_reference_func f, void* user_data,
  28. unpack_limit const& limit)
  29. {
  30. msgpack::object obj;
  31. msgpack::unique_ptr<msgpack::zone> z(new msgpack::zone);
  32. referenced = false;
  33. detail::unpack_imp(
  34. std::forward<Iterator>(begin), std::forward<Iterator>(end), *z, obj, referenced, f, user_data, limit);
  35. return msgpack::object_handle(obj, msgpack::move(z));
  36. }
  37. template <typename Iterator>
  38. inline msgpack::object_handle unpack(
  39. Iterator&& begin, Iterator&& end,
  40. unpack_reference_func f, void* user_data,
  41. unpack_limit const& limit)
  42. {
  43. bool referenced;
  44. return unpack(std::forward<Iterator>(begin), std::forward<Iterator>(end), referenced, f, user_data, limit);
  45. }
  46. template <typename Iterator>
  47. inline msgpack::object unpack(
  48. msgpack::zone& z,
  49. Iterator&& begin, Iterator&& end,
  50. bool& referenced,
  51. unpack_reference_func f, void* user_data,
  52. unpack_limit const& limit)
  53. {
  54. msgpack::object obj;
  55. referenced = false;
  56. detail::unpack_imp(
  57. std::forward<Iterator>(begin), std::forward<Iterator>(end), z, obj, referenced, f, user_data, limit);
  58. return obj;
  59. }
  60. template <typename Iterator>
  61. inline msgpack::object unpack(
  62. msgpack::zone& z,
  63. Iterator&& begin, Iterator&& end,
  64. unpack_reference_func f, void* user_data,
  65. unpack_limit const& limit)
  66. {
  67. bool referenced;
  68. return unpack(
  69. z, std::forward<Iterator>(begin), std::forward<Iterator>(end), referenced, f, user_data, limit);
  70. }
  71. /// @cond
  72. } // MSGPACK_API_VERSION_NAMESPACE(v3)
  73. /// @endcond
  74. } // namespace msgpack
  75. #else // BOOST_VERSION >= 106100
  76. #error Boost 1.61.0 or later is required to use x3 parse
  77. #endif // BOOST_VERSION >= 106100
  78. #endif // defined(MSGPACK_USE_X3_PARSE)
  79. #endif // MSGPACK_V3_X3_UNPACK_HPP