| | 84 | |
| | 85 | |
| | 86 | template <typename T> |
| | 87 | inline void convert(T& v, object o) |
| | 88 | { |
| | 89 | o >> v; |
| | 90 | } |
| | 91 | |
| | 92 | template <typename Stream, typename T> |
| | 93 | inline void pack(packer<Stream>& o, const T& v) |
| | 94 | { |
| | 95 | o << v; |
| | 96 | } |
| | 97 | |
| | 98 | template <typename Stream, typename T> |
| | 99 | inline void pack(Stream& s, const T& v) |
| | 100 | { |
| | 101 | packer<Stream> pk(s); |
| | 102 | pack(pk, v); |
| | 103 | } |
| | 104 | |
| | 105 | template <typename Stream, typename T> |
| | 106 | inline void pack_copy(packer<Stream>& o, T v) |
| | 107 | { |
| | 108 | pack(o, v); |
| | 109 | } |
| | 110 | |
| 101 | | template <typename T> |
| 102 | | inline void convert(T& v, object o) |
| 103 | | { |
| 104 | | o >> v; |
| 105 | | } |
| 106 | | |
| 107 | | template <typename Stream, typename T> |
| 108 | | inline void pack(packer<Stream>& o, const T& v) |
| 109 | | { |
| 110 | | o << v; |
| 111 | | } |
| 112 | | |
| 113 | | template <typename Stream, typename T> |
| 114 | | inline void pack(Stream& s, const T& v) |
| 115 | | { |
| 116 | | packer<Stream> pk(s); |
| 117 | | pack(pk, v); |
| 118 | | } |
| 119 | | |
| 120 | | template <typename Stream, typename T> |
| 121 | | inline void pack_copy(packer<Stream>& o, T v) |
| 122 | | { |
| 123 | | pack(o, v); |
| 124 | | } |
| | 128 | template <typename Type> |
| | 129 | class define : public Type { |
| | 130 | public: |
| | 131 | typedef Type msgpack_type; |
| | 132 | typedef define<Type> define_type; |
| | 133 | |
| | 134 | define() {} |
| | 135 | define(msgpack_type v) : msgpack_type(v) {} |
| | 136 | |
| | 137 | msgpack_type msgpack_pack() const |
| | 138 | { |
| | 139 | return *this; |
| | 140 | } |
| | 141 | |
| | 142 | void msgpack_unpack(object o) |
| | 143 | { |
| | 144 | convert(static_cast<msgpack_type&>(*this), o); |
| | 145 | } |
| | 146 | }; |
| | 147 | |