x3_unpack.hpp
Go to the documentation of this file.
//
// MessagePack for C++ deserializing routine
//
// Copyright (C) 2017 KONDO Takatoshi
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef MSGPACK_V2_X3_UNPACK_HPP
#define MSGPACK_V2_X3_UNPACK_HPP
#if defined(MSGPACK_USE_X3_PARSE)
#include <boost/version.hpp>
#if BOOST_VERSION >= 106100
#include "msgpack/versioning.hpp"
#include "msgpack/create_object_visitor.hpp"
#include "msgpack/x3_unpack_decl.hpp"
#include "msgpack/x3_parse.hpp"
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v2) {
namespace detail {
template <typename Iterator>
inline void
unpack_imp(Iterator&& begin, Iterator&& end,
msgpack::zone& result_zone, msgpack::object& result, bool& referenced,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
{
create_object_visitor v(f, user_data, limit);
v.set_zone(result_zone);
referenced = false;
v.set_referenced(referenced);
if (!parse(std::forward<Iterator>(begin), std::forward<Iterator>(end), v)) {
throw msgpack::parse_error("parse error");
}
referenced = v.referenced();
result = v.data();
}
} // namespace detail
template <typename Iterator>
inline msgpack::object_handle unpack(
Iterator&& begin, Iterator&& end,
bool& referenced,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
{
msgpack::object obj;
msgpack::unique_ptr<msgpack::zone> z(new msgpack::zone);
referenced = false;
detail::unpack_imp(
std::forward<Iterator>(begin), std::forward<Iterator>(end), *z, obj, referenced, f, user_data, limit);
return msgpack::object_handle(obj, msgpack::move(z));
}
template <typename Iterator>
inline msgpack::object_handle unpack(
Iterator&& begin, Iterator&& end,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
{
bool referenced;
return unpack(std::forward<Iterator>(begin), std::forward<Iterator>(end), referenced, f, user_data, limit);
}
template <typename Iterator>
inline msgpack::object unpack(
msgpack::zone& z,
Iterator&& begin, Iterator&& end,
bool& referenced,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
{
msgpack::object obj;
referenced = false;
detail::unpack_imp(
std::forward<Iterator>(begin), std::forward<Iterator>(end), z, obj, referenced, f, user_data, limit);
return obj;
}
template <typename Iterator>
inline msgpack::object unpack(
msgpack::zone& z,
Iterator&& begin, Iterator&& end,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
{
bool referenced;
return unpack(
z, std::forward<Iterator>(begin), std::forward<Iterator>(end), referenced, f, user_data, limit);
}
} // MSGPACK_API_VERSION_NAMESPACE(v2)
} // namespace msgpack
#else // BOOST_VERSION >= 106100
#error Boost 1.61.0 or later is required to use x3 parse
#endif // BOOST_VERSION >= 106100
#endif // defined(MSGPACK_USE_X3_PARSE)
#endif // MSGPACK_V2_X3_UNPACK_HPP
v2
msgpack::detail::unpack_imp
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:1338
msgpack::unpack_reference_func
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::begin
msgpack::object_kv * begin(msgpack::object_map &map)
Definition: iterator.hpp:23
msgpack
Definition: adaptor_base.hpp:15
msgpack::parse_error
Definition: unpack_exception.hpp:34
versioning.hpp
msgpack::zone
Definition: cpp03_zone.hpp:22
msgpack::end
msgpack::object_kv * end(msgpack::object_map &map)
Definition: iterator.hpp:25
msgpack::unpack
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:1382
msgpack::unique_ptr< msgpack::zone >
create_object_visitor.hpp
msgpack::parse
bool parse(const char *data, size_t len, size_t &off, Visitor &v)
Unpack msgpack formatted data via a visitor.
msgpack::object
Object class that corresponding to MessagePack format object.
Definition: object_fwd.hpp:75
MSGPACK_API_VERSION_NAMESPACE
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:58
x3_unpack_decl.hpp
msgpack::move
T & move(T &t)
msgpack::object_handle
The class holds object and zone.
Definition: object.hpp:44
x3_parse.hpp