adaptor_base.hpp
Go to the documentation of this file.
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2015-2016 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_ADAPTOR_BASE_HPP
#define MSGPACK_V1_ADAPTOR_BASE_HPP
#include "msgpack/v1/adaptor/adaptor_base_decl.hpp"
namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
namespace adaptor {
// Adaptor functors
template <typename T, typename Enabler>
struct convert {
msgpack::object const& operator()(msgpack::object const& o, T& v) const;
};
template <typename T, typename Enabler>
struct pack {
template <typename Stream>
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, T const& v) const;
};
template <typename T, typename Enabler>
struct object {
void operator()(msgpack::object& o, T const& v) const;
};
template <typename T, typename Enabler>
struct object_with_zone {
void operator()(msgpack::object::with_zone& o, T const& v) const;
};
} // namespace adaptor
// operators
template <typename T>
inline
typename msgpack::enable_if<
!is_array<T>::value,
msgpack::object const&
>::type
operator>> (msgpack::object const& o, T& v) {
return msgpack::adaptor::convert<T>()(o, v);
}
template <typename T, std::size_t N>
inline
msgpack::object const& operator>> (msgpack::object const& o, T(&v)[N]) {
return msgpack::adaptor::convert<T[N]>()(o, v);
}
template <typename Stream, typename T>
inline
typename msgpack::enable_if<
!is_array<T>::value,
msgpack::packer<Stream>&
>::type
operator<< (msgpack::packer<Stream>& o, T const& v) {
return msgpack::adaptor::pack<T>()(o, v);
}
template <typename Stream, typename T, std::size_t N>
inline
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const T(&v)[N]) {
return msgpack::adaptor::pack<T[N]>()(o, v);
}
template <typename T>
inline
typename msgpack::enable_if<
!is_array<T>::value
>::type
operator<< (msgpack::object& o, T const& v) {
msgpack::adaptor::object<T>()(o, v);
}
template <typename T, std::size_t N>
inline
void operator<< (msgpack::v1::object& o, const T(&v)[N]) {
msgpack::v1::adaptor::object<T[N]>()(o, v);
}
template <typename T>
inline
typename msgpack::enable_if<
!is_array<T>::value
>::type
operator<< (msgpack::object::with_zone& o, T const& v) {
msgpack::adaptor::object_with_zone<T>()(o, v);
}
template <typename T, std::size_t N>
inline
void operator<< (msgpack::object::with_zone& o, const T(&v)[N]) {
msgpack::adaptor::object_with_zone<T[N]>()(o, v);
}
} // MSGPACK_API_VERSION_NAMESPACE(v1)
} // namespace msgpack
#endif // MSGPACK_V1_ADAPTOR_BASE_HPP
msgpack::is_array
Definition: cpp_config_decl.hpp:71
msgpack::adaptor::convert< T[N]>
Definition: carray.hpp:27
msgpack::adaptor::object_with_zone< T[N]>
Definition: carray.hpp:150
msgpack
Definition: adaptor_base.hpp:15
adaptor_base_decl.hpp
msgpack::object::with_zone
Definition: object.hpp:34
msgpack::adaptor::object_with_zone
Definition: adaptor_base.hpp:43
msgpack::adaptor::pack< T[N]>
Definition: carray.hpp:86
msgpack::adaptor::pack
Definition: adaptor_base.hpp:32
msgpack::operator<<
msgpack::enable_if< !is_array< T >::value, msgpack::packer< Stream > & >::type operator<<(msgpack::packer< Stream > &o, T const &v)
Definition: adaptor_base.hpp:72
msgpack::enable_if
Definition: cpp_config_decl.hpp:56
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::adaptor::object
Definition: adaptor_base.hpp:38
msgpack::packer
The class template that supports continuous packing.
Definition: adaptor_base_decl.hpp:24
msgpack::adaptor::convert
Definition: adaptor_base.hpp:27
msgpack::adaptor::convert::operator()
msgpack::object const & operator()(msgpack::object const &o, T &v) const
Definition: object.hpp:208
msgpack::operator>>
msgpack::enable_if< !is_array< T >::value, msgpack::object const & >::type operator>>(msgpack::object const &o, T &v)
Definition: adaptor_base.hpp:57