object_fwd.hpp
Go to the documentation of this file.
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2008-2014 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_OBJECT_FWD_HPP
#define MSGPACK_V1_OBJECT_FWD_HPP
#include "msgpack/object_fwd_decl.hpp"
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
struct object_array {
uint32_t size;
msgpack::object* ptr;
};
struct object_map {
uint32_t size;
msgpack::object_kv* ptr;
};
struct object_str {
uint32_t size;
const char* ptr;
};
struct object_bin {
uint32_t size;
const char* ptr;
};
struct object_ext {
int8_t type() const { return ptr[0]; }
const char* data() const { return &ptr[1]; }
uint32_t size;
const char* ptr;
};
#if !defined(MSGPACK_USE_CPP03)
template <typename T>
struct has_as {
private:
template <typename U>
static auto check(U*) ->
// Check v1 specialization
typename std::is_same<
decltype(adaptor::as<U>()(std::declval<msgpack::object>())),
T
>::type;
template <typename...>
static std::false_type check(...);
public:
using type = decltype(check<T>(MSGPACK_NULLPTR));
static constexpr bool value = type::value;
};
#endif // !defined(MSGPACK_USE_CPP03)
struct object {
union union_type {
bool boolean;
uint64_t u64;
int64_t i64;
#if defined(MSGPACK_USE_LEGACY_NAME_AS_FLOAT)
MSGPACK_DEPRECATED("please use f64 instead")
double dec; // obsolete
#endif // MSGPACK_USE_LEGACY_NAME_AS_FLOAT
double f64;
msgpack::object_array array;
msgpack::object_map map;
msgpack::object_str str;
msgpack::object_bin bin;
msgpack::object_ext ext;
};
msgpack::type::object_type type;
union_type via;
bool is_nil() const { return type == msgpack::type::NIL; }
#if defined(MSGPACK_USE_CPP03)
template <typename T>
T as() const;
#else // defined(MSGPACK_USE_CPP03)
template <typename T>
typename std::enable_if<msgpack::has_as<T>::value, T>::type as() const;
template <typename T>
typename std::enable_if<!msgpack::has_as<T>::value, T>::type as() const;
#endif // defined(MSGPACK_USE_CPP03)
template <typename T>
typename msgpack::enable_if<
!msgpack::is_array<T>::value && !msgpack::is_pointer<T>::value,
T&
>::type
convert(T& v) const;
template <typename T, std::size_t N>
T (&convert(T(&v)[N]) const)[N];
#if !defined(MSGPACK_DISABLE_LEGACY_CONVERT)
template <typename T>
MSGPACK_DEPRECATED("please use reference version instead")
typename msgpack::enable_if<
msgpack::is_pointer<T>::value,
T
>::type
convert(T v) const;
#endif // !defined(MSGPACK_DISABLE_LEGACY_CONVERT)
template <typename T>
bool convert_if_not_nil(T& v) const;
object();
object(const msgpack_object& o);
template <typename T>
explicit object(const T& v);
template <typename T>
object(const T& v, msgpack::zone& z);
template <typename T>
MSGPACK_DEPRECATED("please use zone reference version instead of the pointer version")
object(const T& v, msgpack::zone* z);
template <typename T>
object& operator=(const T& v);
operator msgpack_object() const;
struct with_zone;
protected:
struct implicit_type;
public:
implicit_type convert() const;
};
class type_error : public std::bad_cast { };
struct object::implicit_type {
implicit_type(object const& o) : obj(o) { }
~implicit_type() { }
template <typename T>
operator T();
private:
object const& obj;
};
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_V1_OBJECT_FWD_HPP
msgpack::is_array
Definition: cpp_config_decl.hpp:71
msgpack::object_ext
Definition: object_fwd.hpp:42
msgpack::object_ext::data
const char * data() const
Definition: object_fwd.hpp:44
msgpack::object_map::ptr
msgpack::object_kv * ptr
Definition: object_fwd.hpp:29
msgpack::object_array::size
uint32_t size
Definition: object_fwd.hpp:23
msgpack::object_bin::ptr
const char * ptr
Definition: object_fwd.hpp:39
msgpack::adaptor::as
Definition: object_fwd_decl.hpp:62
msgpack::object::via
union_type via
Definition: object_fwd.hpp:93
msgpack::object::implicit_type::~implicit_type
~implicit_type()
Definition: object_fwd.hpp:240
msgpack::object::union_type
Definition: object_fwd.hpp:76
msgpack::object_ext::ptr
const char * ptr
Definition: object_fwd.hpp:46
msgpack::object_array::ptr
msgpack::object * ptr
Definition: object_fwd.hpp:24
msgpack::object_bin::size
uint32_t size
Definition: object_fwd.hpp:38
msgpack
Definition: adaptor_base.hpp:15
msgpack::object::implicit_type
Definition: object_fwd.hpp:238
msgpack::object_str::ptr
const char * ptr
Definition: object_fwd.hpp:34
msgpack::object::implicit_type::implicit_type
implicit_type(object const &o)
Definition: object_fwd.hpp:239
msgpack::zone
Definition: cpp03_zone.hpp:22
msgpack::type::object_type
object_type
Definition: object_fwd_decl.hpp:28
msgpack::object::union_type::boolean
bool boolean
Definition: object_fwd.hpp:77
msgpack::convert
void convert(T &v, msgpack::object const &o)
Definition: object.hpp:1194
msgpack::object::is_nil
bool is_nil() const
Cheking nil.
Definition: object_fwd.hpp:99
msgpack::object_kv
Definition: object.hpp:30
msgpack::type::NIL
Definition: object_fwd_decl.hpp:29
msgpack::object::union_type::i64
int64_t i64
Definition: object_fwd.hpp:79
msgpack::has_as::type
decltype(check< T >(MSGPACK_NULLPTR)) type
Definition: object_fwd.hpp:65
msgpack::is_pointer
Definition: cpp_config_decl.hpp:81
msgpack::object_ext::size
uint32_t size
Definition: object_fwd.hpp:45
msgpack::object_array
Definition: object_fwd.hpp:22
msgpack::type_error
Definition: object_fwd.hpp:236
msgpack::object::union_type::f64
double f64
Definition: object_fwd.hpp:84
msgpack::object::union_type::array
msgpack::object_array array
Definition: object_fwd.hpp:85
msgpack::enable_if
Definition: cpp_config_decl.hpp:56
msgpack::object::union_type::map
msgpack::object_map map
Definition: object_fwd.hpp:86
msgpack::object::union_type::str
msgpack::object_str str
Definition: object_fwd.hpp:87
msgpack::object
Object class that corresponding to MessagePack format object.
Definition: object_fwd.hpp:75
msgpack::object::type
msgpack::type::object_type type
Definition: object_fwd.hpp:92
MSGPACK_API_VERSION_NAMESPACE
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:58
msgpack::object_map::size
uint32_t size
Definition: object_fwd.hpp:28
msgpack::false_type
integral_constant< bool, false > false_type
Definition: cpp_config_decl.hpp:62
msgpack::object_str::size
uint32_t size
Definition: object_fwd.hpp:33
msgpack::has_as
Definition: object_fwd.hpp:53
msgpack::object_ext::type
int8_t type() const
Definition: object_fwd.hpp:43
msgpack::object_map
Definition: object_fwd.hpp:27
MSGPACK_NULLPTR
#define MSGPACK_NULLPTR
Definition: cpp_config_decl.hpp:35
msgpack::object::union_type::ext
msgpack::object_ext ext
Definition: object_fwd.hpp:89
object_fwd_decl.hpp
msgpack::object_bin
Definition: object_fwd.hpp:37
MSGPACK_DEPRECATED
#define MSGPACK_DEPRECATED(msg)
Definition: cpp_config.hpp:132
msgpack::object_str
Definition: object_fwd.hpp:32
msgpack::object::union_type::u64
uint64_t u64
Definition: object_fwd.hpp:78
msgpack::object::union_type::bin
msgpack::object_bin bin
Definition: object_fwd.hpp:88