MessagePack for C++
adaptor_base.hpp
Go to the documentation of this file.
1 //
2 // MessagePack for C++ static resolution routine
3 //
4 // Copyright (C) 2015-2016 KONDO Takatoshi
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 // (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 //
10 #ifndef MSGPACK_V1_ADAPTOR_BASE_HPP
11 #define MSGPACK_V1_ADAPTOR_BASE_HPP
12 
14 
15 namespace msgpack {
16 
20 
21 
22 namespace adaptor {
23 
24 // Adaptor functors
25 
26 template <typename T, typename Enabler>
27 struct convert {
28  msgpack::object const& operator()(msgpack::object const& o, T& v) const;
29 };
30 
31 template <typename T, typename Enabler>
32 struct pack {
33  template <typename Stream>
35 };
36 
37 template <typename T, typename Enabler>
38 struct object {
39  void operator()(msgpack::object& o, T const& v) const;
40 };
41 
42 template <typename T, typename Enabler>
44  void operator()(msgpack::object::with_zone& o, T const& v) const;
45 };
46 
47 } // namespace adaptor
48 
49 // operators
50 
51 template <typename T>
52 inline
53 typename msgpack::enable_if<
54  !is_array<T>::value,
55  msgpack::object const&
56 >::type
57 operator>> (msgpack::object const& o, T& v) {
58  return msgpack::adaptor::convert<T>()(o, v);
59 }
60 template <typename T, std::size_t N>
61 inline
62 msgpack::object const& operator>> (msgpack::object const& o, T(&v)[N]) {
63  return msgpack::adaptor::convert<T[N]>()(o, v);
64 }
65 
66 template <typename Stream, typename T>
67 inline
68 typename msgpack::enable_if<
69  !is_array<T>::value,
71 >::type
72 operator<< (msgpack::packer<Stream>& o, T const& v) {
73  return msgpack::adaptor::pack<T>()(o, v);
74 }
75 template <typename Stream, typename T, std::size_t N>
76 inline
78  return msgpack::adaptor::pack<T[N]>()(o, v);
79 }
80 
81 template <typename T>
82 inline
83 typename msgpack::enable_if<
84  !is_array<T>::value
85 >::type
86 operator<< (msgpack::object& o, T const& v) {
88 }
89 template <typename T, std::size_t N>
90 inline
91 void operator<< (msgpack::v1::object& o, const T(&v)[N]) {
92  msgpack::v1::adaptor::object<T[N]>()(o, v);
93 }
94 
95 template <typename T>
96 inline
97 typename msgpack::enable_if<
98  !is_array<T>::value
99 >::type
100 operator<< (msgpack::object::with_zone& o, T const& v) {
102 }
103 template <typename T, std::size_t N>
104 inline
105 void operator<< (msgpack::object::with_zone& o, const T(&v)[N]) {
107 }
108 
110 } // MSGPACK_API_VERSION_NAMESPACE(v1)
112 
113 } // namespace msgpack
114 
115 
116 #endif // MSGPACK_V1_ADAPTOR_BASE_HPP
The class template that supports continuous packing.
Definition: pack.hpp:33
Definition: adaptor_base.hpp:15
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< !is_array< T >::value, msgpack::object const & >::type operator>>(msgpack::object const &o, T &v)
Definition: adaptor_base.hpp:57
Definition: carray.hpp:27
Definition: adaptor_base.hpp:27
msgpack::object const & operator()(msgpack::object const &o, T &v) const
Definition: object.hpp:641
Definition: adaptor_base.hpp:43
void operator()(msgpack::object::with_zone &o, T const &v) const
Definition: object.hpp:657
Definition: adaptor_base.hpp:38
void operator()(msgpack::object &o, T const &v) const
Definition: carray.hpp:86
Definition: adaptor_base.hpp:32
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, T const &v) const
Definition: object.hpp:650
Definition: object.hpp:35
Object class that corresponding to MessagePack format object.
Definition: object_fwd.hpp:75
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:66