summaryrefslogtreecommitdiff
path: root/cpp/object.hpp
diff options
context:
space:
mode:
authorfrsyuki <frsyuki@5a5092ae-2292-43ba-b2d5-dcab9c1a2731>2009-02-15 09:09:59 +0000
committerfrsyuki <frsyuki@5a5092ae-2292-43ba-b2d5-dcab9c1a2731>2009-02-15 09:09:59 +0000
commitc3021d3236e1276bb575802597bfaf8279fced72 (patch)
tree321525d884b1328952baef8441ef5814bf4f9d0c /cpp/object.hpp
parent1ad04b22d8d3e5267ceec7fc1527651ee0eb0ffe (diff)
downloadmsgpack-python-c3021d3236e1276bb575802597bfaf8279fced72.tar.gz
lang/c/msgpack: added msgpack::define
git-svn-id: file:///Users/frsyuki/project/msgpack-git/svn/x@75 5a5092ae-2292-43ba-b2d5-dcab9c1a2731
Diffstat (limited to 'cpp/object.hpp')
-rw-r--r--cpp/object.hpp53
1 files changed, 38 insertions, 15 deletions
diff --git a/cpp/object.hpp b/cpp/object.hpp
index 13402cc..5ed1fab 100644
--- a/cpp/object.hpp
+++ b/cpp/object.hpp
@@ -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)