unpack_decl.hpp
Go to the documentation of this file.
//
// MessagePack for C++ deserializing routine
//
// Copyright (C) 2008-2016 FURUHASHI Sadayuki and 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_V1_UNPACK_DECL_HPP
#define MSGPACK_V1_UNPACK_DECL_HPP
#include "msgpack/versioning.hpp"
#include "msgpack/unpack_define.h"
#include "msgpack/object.hpp"
#include "msgpack/zone.hpp"
#include "msgpack/cpp_config.hpp"
#include "msgpack/sysdep.h"
#include "msgpack/parse_return.hpp"
#include <memory>
#include <stdexcept>
#if !defined(MSGPACK_USE_CPP03)
#include <atomic>
#endif
#if defined(_MSC_VER)
// avoiding confliction std::max, std::min, and macro in windows.h
#ifndef NOMINMAX
#define NOMINMAX
#endif
#endif // defined(_MSC_VER)
#ifdef _msgpack_atomic_counter_header
#include _msgpack_atomic_counter_header
#endif
const size_t COUNTER_SIZE = sizeof(_msgpack_atomic_counter_t);
#ifndef MSGPACK_UNPACKER_INIT_BUFFER_SIZE
#define MSGPACK_UNPACKER_INIT_BUFFER_SIZE (64*1024)
#endif
#ifndef MSGPACK_UNPACKER_RESERVE_SIZE
#define MSGPACK_UNPACKER_RESERVE_SIZE (32*1024)
#endif
// backward compatibility
#ifndef MSGPACK_UNPACKER_DEFAULT_INITIAL_BUFFER_SIZE
#define MSGPACK_UNPACKER_DEFAULT_INITIAL_BUFFER_SIZE MSGPACK_UNPACKER_INIT_BUFFER_SIZE
#endif
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
typedef bool (*unpack_reference_func)(msgpack::type::object_type type, std::size_t size, void* user_data);
struct unpack_error;
struct parse_error;
struct insufficient_bytes;
struct size_overflow;
struct array_size_overflow;
struct map_size_overflow;
struct str_size_overflow;
struct bin_size_overflow;
struct ext_size_overflow;
struct depth_size_overflow;
class unpack_limit {
public:
unpack_limit(
std::size_t array = 0xffffffff,
std::size_t map = 0xffffffff,
std::size_t str = 0xffffffff,
std::size_t bin = 0xffffffff,
std::size_t ext = 0xffffffff,
std::size_t depth = 0xffffffff)
:array_(array),
map_(map),
str_(str),
bin_(bin),
ext_(ext),
depth_(depth) {}
std::size_t array() const { return array_; }
std::size_t map() const { return map_; }
std::size_t str() const { return str_; }
std::size_t bin() const { return bin_; }
std::size_t ext() const { return ext_; }
std::size_t depth() const { return depth_; }
private:
std::size_t array_;
std::size_t map_;
std::size_t str_;
std::size_t bin_;
std::size_t ext_;
std::size_t depth_;
};
namespace detail {
class unpack_user;
void unpack_uint8(uint8_t d, msgpack::object& o);
void unpack_uint16(uint16_t d, msgpack::object& o);
void unpack_uint32(uint32_t d, msgpack::object& o);
void unpack_uint64(uint64_t d, msgpack::object& o);
void unpack_int8(int8_t d, msgpack::object& o);
void unpack_int16(int16_t d, msgpack::object& o);
void unpack_int32(int32_t d, msgpack::object& o);
void unpack_int64(int64_t d, msgpack::object& o);
void unpack_float(float d, msgpack::object& o);
void unpack_double(double d, msgpack::object& o);
void unpack_nil(msgpack::object& o);
void unpack_true(msgpack::object& o);
void unpack_false(msgpack::object& o);
struct unpack_array;
void unpack_array_item(msgpack::object& c, msgpack::object const& o);
struct unpack_map;
void unpack_map_item(msgpack::object& c, msgpack::object const& k, msgpack::object const& v);
void unpack_str(unpack_user& u, const char* p, uint32_t l, msgpack::object& o);
void unpack_bin(unpack_user& u, const char* p, uint32_t l, msgpack::object& o);
void unpack_ext(unpack_user& u, const char* p, std::size_t l, msgpack::object& o);
class unpack_stack;
void init_count(void* buffer);
void decr_count(void* buffer);
void incr_count(void* buffer);
#if defined(MSGPACK_USE_CPP03)
_msgpack_atomic_counter_t get_count(void* buffer);
#else // defined(MSGPACK_USE_CPP03)
std::atomic<unsigned int> const& get_count(void* buffer);
#endif // defined(MSGPACK_USE_CPP03)
struct fix_tag {
char f1[65]; // FIXME unique size is required. or use is_same meta function.
};
template <typename T>
struct value;
template <typename T>
typename msgpack::enable_if<sizeof(T) == sizeof(fix_tag)>::type load(uint32_t& dst, const char* n);
template <typename T>
typename msgpack::enable_if<sizeof(T) == 1>::type load(T& dst, const char* n);
template <typename T>
typename msgpack::enable_if<sizeof(T) == 2>::type load(T& dst, const char* n);
template <typename T>
typename msgpack::enable_if<sizeof(T) == 4>::type load(T& dst, const char* n);
template <typename T>
typename msgpack::enable_if<sizeof(T) == 8>::type load(T& dst, const char* n);
class context;
} // detail
typedef object_handle unpacked;
class unpacker;
object_handle unpack(
const char* data, std::size_t len, std::size_t& off, bool& referenced,
unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
object_handle unpack(
const char* data, std::size_t len, std::size_t& off,
unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
object_handle unpack(
const char* data, std::size_t len, bool& referenced,
unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
object_handle unpack(
const char* data, std::size_t len,
unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
void unpack(
object_handle& result,
const char* data, std::size_t len, std::size_t& off, bool& referenced,
unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
void unpack(
object_handle& result,
const char* data, std::size_t len, std::size_t& off,
unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
void unpack(
object_handle& result,
const char* data, std::size_t len, bool& referenced,
unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
void unpack(
object_handle& result,
const char* data, std::size_t len,
unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len, std::size_t& off, bool& referenced,
unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len, std::size_t& off,
unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len, bool& referenced,
unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len,
unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
void unpack(
object_handle* result,
const char* data, std::size_t len, std::size_t* off = MSGPACK_NULLPTR, bool* referenced = MSGPACK_NULLPTR,
unpack_reference_func f = MSGPACK_NULLPTR, void* user_data = MSGPACK_NULLPTR, unpack_limit const& limit = unpack_limit());
namespace detail {
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, void* user_data,
unpack_limit const& limit);
} // detail
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_V1_UNPACK_DECL_HPP
parse_return.hpp
msgpack::detail::unpack_int8
void unpack_int8(int8_t d, msgpack::object &o)
Definition: unpack.hpp:80
msgpack::detail::incr_count
void incr_count(void *buffer)
Definition: unpack.hpp:248
msgpack::unpack_limit
Definition: unpack_decl.hpp:87
msgpack::str_size_overflow
Definition: unpack_exception.hpp:79
msgpack::unpack_limit::bin
std::size_t bin() const
Definition: unpack_decl.hpp:105
msgpack::unpack_limit::ext
std::size_t ext() const
Definition: unpack_decl.hpp:106
msgpack::detail::unpack_ext
void unpack_ext(unpack_user &u, const char *p, std::size_t l, msgpack::object &o)
Definition: unpack.hpp:190
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::detail::unpack_uint32
void unpack_uint32(uint32_t d, msgpack::object &o)
Definition: unpack.hpp:74
msgpack::unpack_limit::map
std::size_t map() const
Definition: unpack_decl.hpp:103
msgpack::detail::unpack_str
void unpack_str(unpack_user &u, const char *p, uint32_t l, msgpack::object &o)
Definition: unpack.hpp:158
msgpack::unpack_error
Definition: unpack_exception.hpp:25
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
object.hpp
msgpack::depth_size_overflow
Definition: unpack_exception.hpp:106
msgpack::unpacked
object_handle unpacked
Definition: unpack_decl.hpp:207
msgpack::detail::unpack_int16
void unpack_int16(int16_t d, msgpack::object &o)
Definition: unpack.hpp:84
msgpack::detail::unpack_bin
void unpack_bin(unpack_user &u, const char *p, uint32_t l, msgpack::object &o)
Definition: unpack.hpp:174
msgpack::detail::unpack_uint8
void unpack_uint8(uint8_t d, msgpack::object &o)
Definition: unpack.hpp:68
msgpack
Definition: adaptor_base.hpp:15
msgpack::parse_error
Definition: unpack_exception.hpp:34
msgpack::ext_size_overflow
Definition: unpack_exception.hpp:97
versioning.hpp
msgpack::zone
Definition: cpp03_zone.hpp:22
msgpack::detail::unpack_false
void unpack_false(msgpack::object &o)
Definition: unpack.hpp:108
msgpack::type::object_type
object_type
Definition: object_fwd_decl.hpp:28
msgpack::unpack_limit::unpack_limit
unpack_limit(std::size_t array=0xffffffff, std::size_t map=0xffffffff, std::size_t str=0xffffffff, std::size_t bin=0xffffffff, std::size_t ext=0xffffffff, std::size_t depth=0xffffffff)
Definition: unpack_decl.hpp:89
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::size_overflow
Definition: unpack_exception.hpp:52
cpp_config.hpp
msgpack::detail::context
Definition: unpack.hpp:303
msgpack::detail::unpack_float
void unpack_float(float d, msgpack::object &o)
Definition: unpack.hpp:96
msgpack::bin_size_overflow
Definition: unpack_exception.hpp:88
msgpack::detail::init_count
void init_count(void *buffer)
Definition: unpack.hpp:226
zone.hpp
msgpack::detail::unpack_double
void unpack_double(double d, msgpack::object &o)
Definition: unpack.hpp:99
msgpack::detail::unpack_uint64
void unpack_uint64(uint64_t d, msgpack::object &o)
Definition: unpack.hpp:77
msgpack::insufficient_bytes
Definition: unpack_exception.hpp:43
msgpack::detail::load
msgpack::enable_if< sizeof(T)==sizeof(fix_tag)>::type load(uint32_t &dst, const char *n)
Definition: unpack.hpp:279
msgpack::array_size_overflow
Definition: unpack_exception.hpp:61
msgpack::type::size
std::size_t size(T const &t)
Definition: size_equal_only.hpp:24
msgpack::detail::unpack_int64
void unpack_int64(int64_t d, msgpack::object &o)
Definition: unpack.hpp:92
msgpack::unpack_limit::str
std::size_t str() const
Definition: unpack_decl.hpp:104
msgpack::detail::unpack_uint16
void unpack_uint16(uint16_t d, msgpack::object &o)
Definition: unpack.hpp:71
msgpack::detail::unpack_true
void unpack_true(msgpack::object &o)
Definition: unpack.hpp:105
COUNTER_SIZE
const size_t COUNTER_SIZE
Definition: unpack_decl.hpp:40
msgpack::enable_if
Definition: cpp_config_decl.hpp:56
msgpack::detail::get_count
std::atomic< unsigned int > const & get_count(void *buffer)
Definition: unpack.hpp:263
msgpack::unpack_limit::array
std::size_t array() const
Definition: unpack_decl.hpp:102
msgpack::object
Object class that corresponding to MessagePack format object.
Definition: object_fwd.hpp:75
msgpack::map_size_overflow
Definition: unpack_exception.hpp:70
MSGPACK_API_VERSION_NAMESPACE
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:58
msgpack::detail::unpack_nil
void unpack_nil(msgpack::object &o)
Definition: unpack.hpp:102
msgpack::detail::unpack_map_item
void unpack_map_item(msgpack::object &c, msgpack::object const &k, msgpack::object const &v)
Definition: unpack.hpp:146
msgpack::detail::decr_count
void decr_count(void *buffer)
Definition: unpack.hpp:235
msgpack::unpacker
Unpacking class for a stream deserialization.
Definition: unpack.hpp:847
msgpack::detail::fix_tag
Definition: unpack_decl.hpp:180
msgpack::detail::unpack_int32
void unpack_int32(int32_t d, msgpack::object &o)
Definition: unpack.hpp:88
MSGPACK_NULLPTR
#define MSGPACK_NULLPTR
Definition: cpp_config_decl.hpp:35
msgpack::detail::unpack_array_item
void unpack_array_item(msgpack::object &c, msgpack::object const &o)
Definition: unpack.hpp:124
msgpack::detail::value
Definition: unpack.hpp:270
msgpack::unpack_limit::depth
std::size_t depth() const
Definition: unpack_decl.hpp:107
msgpack::object_handle
The class holds object and zone.
Definition: object.hpp:44