diff options
author | frsyuki <frsyuki@5a5092ae-2292-43ba-b2d5-dcab9c1a2731> | 2009-02-15 09:09:58 +0000 |
---|---|---|
committer | frsyuki <frsyuki@5a5092ae-2292-43ba-b2d5-dcab9c1a2731> | 2009-02-15 09:09:58 +0000 |
commit | 921b0ff62ec99e9339d6cfaa6ba724ae7bb5f9ce (patch) | |
tree | 2d09786d2edef75c1c94efbaaeda67075be6cd32 /cpp/object.hpp | |
parent | 2c7f0b2b1aa78b28916c40171dc8fee07d414d64 (diff) | |
download | msgpack-python-921b0ff62ec99e9339d6cfaa6ba724ae7bb5f9ce.tar.gz |
lang/c/msgpack: C++ binding: pack()
git-svn-id: file:///Users/frsyuki/project/msgpack-git/svn/x@73 5a5092ae-2292-43ba-b2d5-dcab9c1a2731
Diffstat (limited to 'cpp/object.hpp')
-rw-r--r-- | cpp/object.hpp | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/cpp/object.hpp b/cpp/object.hpp index 8cce14c..77d55bb 100644 --- a/cpp/object.hpp +++ b/cpp/object.hpp @@ -83,51 +83,44 @@ packer<Stream>& operator<< (packer<Stream>& o, const object& v); -namespace type { - 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) - { - pack_copy(v.msgpack_pack(), o); - return o; - } +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> inline void convert(T& v, object o) { - using namespace type; o >> v; } - template <typename Stream, typename T> -inline void pack(T& v, packer<Stream>& o) +inline void pack(packer<Stream>& o, const T& v) { - using namespace type; o << v; } - template <typename Stream, typename T> -inline void pack(T& v, Stream& s) +inline void pack(Stream& s, const T& v) { packer<Stream> pk(s); - pack(v, pk); + pack(pk, v); } - template <typename Stream, typename T> -inline void pack_copy(T v, packer<Stream>& o) +inline void pack_copy(packer<Stream>& o, T v) { - pack(v, o); + pack(o, v); } |