mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-14 18:10:30 +01:00
lang/c/msgpack: added msgpack::define
git-svn-id: file:///Users/frsyuki/project/msgpack-git/svn/x@75 5a5092ae-2292-43ba-b2d5-dcab9c1a2731
This commit is contained in:
parent
1ad04b22d8
commit
c3021d3236
@ -81,21 +81,6 @@ inline object& operator>> (object o, object& v)
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const object& v);
|
||||
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline T& operator>> (object o, T& v)
|
||||
{
|
||||
v.msgpack_unpack(o);
|
||||
return v;
|
||||
}
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const T& v)
|
||||
{
|
||||
o << v.msgpack_pack();
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
@ -123,6 +108,44 @@ inline void pack_copy(packer<Stream>& o, T v)
|
||||
pack(o, v);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline T& operator>> (object o, T& v)
|
||||
{
|
||||
v.msgpack_unpack(o);
|
||||
return v;
|
||||
}
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const T& v)
|
||||
{
|
||||
o << v.msgpack_pack();
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
template <typename Type>
|
||||
class define : public Type {
|
||||
public:
|
||||
typedef Type msgpack_type;
|
||||
typedef define<Type> define_type;
|
||||
|
||||
define() {}
|
||||
define(msgpack_type v) : msgpack_type(v) {}
|
||||
|
||||
msgpack_type msgpack_pack() const
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
void msgpack_unpack(object o)
|
||||
{
|
||||
convert(static_cast<msgpack_type&>(*this), o);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator<< (packer<Stream>& o, const object& v)
|
||||
|
Loading…
x
Reference in New Issue
Block a user