unpack.hpp
Go to the documentation of this file.
//
// MessagePack for C++ deserializing routine
//
// Copyright (C) 2018 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_V3_UNPACK_HPP
#define MSGPACK_V3_UNPACK_HPP
#include "msgpack/unpack_decl.hpp"
#include "msgpack/parse.hpp"
#include "msgpack/create_object_visitor.hpp"
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v3) {
inline msgpack::object_handle unpack(
const char* data, std::size_t len, std::size_t& off, bool& referenced,
msgpack::unpack_reference_func f, void* user_data,
msgpack::unpack_limit const& limit
)
{
msgpack::object obj;
msgpack::unique_ptr<msgpack::zone> z(new msgpack::zone);
referenced = false;
parse_return ret = detail::unpack_imp(
data, len, off, *z, obj, referenced, f, user_data, limit);
switch(ret) {
case msgpack::PARSE_SUCCESS:
return msgpack::object_handle(obj, msgpack::move(z));
case msgpack::PARSE_EXTRA_BYTES:
return msgpack::object_handle(obj, msgpack::move(z));
default:
break;
}
return msgpack::object_handle();
}
inline msgpack::object_handle unpack(
const char* data, std::size_t len, std::size_t& off,
msgpack::unpack_reference_func f, void* user_data,
msgpack::unpack_limit const& limit)
{
bool referenced;
return msgpack::v3::unpack(data, len, off, referenced, f, user_data, limit);
}
inline msgpack::object_handle unpack(
const char* data, std::size_t len, bool& referenced,
msgpack::unpack_reference_func f, void* user_data,
msgpack::unpack_limit const& limit)
{
std::size_t off = 0;
return msgpack::v3::unpack(data, len, off, referenced, f, user_data, limit);
}
inline msgpack::object_handle unpack(
const char* data, std::size_t len,
msgpack::unpack_reference_func f, void* user_data,
msgpack::unpack_limit const& limit)
{
bool referenced;
std::size_t off = 0;
return msgpack::v3::unpack(data, len, off, referenced, f, user_data, limit);
}
inline void unpack(
msgpack::object_handle& result,
const char* data, std::size_t len, std::size_t& off, bool& referenced,
msgpack::unpack_reference_func f, void* user_data,
msgpack::unpack_limit const& limit)
{
msgpack::object obj;
msgpack::unique_ptr<msgpack::zone> z(new msgpack::zone);
referenced = false;
parse_return ret = detail::unpack_imp(
data, len, off, *z, obj, referenced, f, user_data, limit);
switch(ret) {
case msgpack::PARSE_SUCCESS:
result.set(obj);
result.zone() = msgpack::move(z);
return;
case msgpack::PARSE_EXTRA_BYTES:
result.set(obj);
result.zone() = msgpack::move(z);
return;
default:
return;
}
}
inline 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)
{
bool referenced;
msgpack::v3::unpack(result, data, len, off, referenced, f, user_data, limit);
}
inline void unpack(
msgpack::object_handle& result,
const char* data, std::size_t len, bool& referenced,
msgpack::unpack_reference_func f, void* user_data,
msgpack::unpack_limit const& limit)
{
std::size_t off = 0;
msgpack::v3::unpack(result, data, len, off, referenced, f, user_data, limit);
}
inline void unpack(
msgpack::object_handle& result,
const char* data, std::size_t len,
msgpack::unpack_reference_func f, void* user_data,
msgpack::unpack_limit const& limit)
{
bool referenced;
std::size_t off = 0;
msgpack::v3::unpack(result, data, len, off, referenced, f, user_data, limit);
}
inline msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len, std::size_t& off, bool& referenced,
msgpack::unpack_reference_func f, void* user_data,
msgpack::unpack_limit const& limit)
{
msgpack::object obj;
referenced = false;
parse_return ret = detail::unpack_imp(
data, len, off, z, obj, referenced, f, user_data, limit);
switch(ret) {
case msgpack::PARSE_SUCCESS:
return obj;
case msgpack::PARSE_EXTRA_BYTES:
return obj;
default:
break;
}
return obj;
}
inline msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len, std::size_t& off,
msgpack::unpack_reference_func f, void* user_data,
msgpack::unpack_limit const& limit)
{
bool referenced;
return msgpack::v3::unpack(z, data, len, off, referenced, f, user_data, limit);
}
inline msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len, bool& referenced,
msgpack::unpack_reference_func f, void* user_data,
msgpack::unpack_limit const& limit)
{
std::size_t off = 0;
return msgpack::v3::unpack(z, data, len, off, referenced, f, user_data, limit);
}
inline msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len,
msgpack::unpack_reference_func f, void* user_data,
msgpack::unpack_limit const& limit)
{
bool referenced;
std::size_t off = 0;
return msgpack::v3::unpack(z, data, len, off, referenced, f, user_data, limit);
}
} // MSGPACK_API_VERSION_NAMESPACE(v3)
} // namespace msgpack
#endif // MSGPACK_V3_UNPACK_HPP
msgpack::unpack
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
msgpack::unpack_limit
Definition: unpack_decl.hpp:87
msgpack::parse_return
parse_return
Definition: parse_return.hpp:23
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::object_handle::set
void set(msgpack::object const &obj)
Definition: object.hpp:64
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
Definition: adaptor_base.hpp:15
msgpack::zone
Definition: cpp03_zone.hpp:22
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 >
unpack_decl.hpp
create_object_visitor.hpp
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
msgpack::PARSE_SUCCESS
Definition: parse_return.hpp:24
parse.hpp
msgpack::PARSE_EXTRA_BYTES
Definition: parse_return.hpp:25
msgpack::object_handle::zone
msgpack::unique_ptr< msgpack::zone > & zone()
Get unique_ptr reference of zone.
Definition: object.hpp:90
msgpack::move
T & move(T &t)
msgpack::object_handle
The class holds object and zone.
Definition: object.hpp:44