summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfrsyuki <frsyuki@5a5092ae-2292-43ba-b2d5-dcab9c1a2731>2009-02-15 09:10:01 +0000
committerfrsyuki <frsyuki@5a5092ae-2292-43ba-b2d5-dcab9c1a2731>2009-02-15 09:10:01 +0000
commite893dde57e60e8e75b30b0e6a539ec233e112a4a (patch)
tree57b8033767e0871875e329bbbe24300c542caea1
parent823add403e5f0d905fc0003023c2b270adb22897 (diff)
downloadmsgpack-python-e893dde57e60e8e75b30b0e6a539ec233e112a4a.tar.gz
C++ binding: efficient serializing interface
git-svn-id: file:///Users/frsyuki/project/msgpack-git/svn/x@95 5a5092ae-2292-43ba-b2d5-dcab9c1a2731
-rw-r--r--cpp/object.hpp11
-rw-r--r--cpp/test.cpp4
-rw-r--r--cpp/unpack.hpp3
3 files changed, 10 insertions, 8 deletions
diff --git a/cpp/object.hpp b/cpp/object.hpp
index 5f77d3e..1f0dcdf 100644
--- a/cpp/object.hpp
+++ b/cpp/object.hpp
@@ -135,14 +135,14 @@ inline void pack_copy(packer<Stream>& o, T v)
template <typename T>
inline T& operator>> (object o, T& v)
{
- v.msgpack_unpack(o);
+ v.msgpack_unpack(o.convert());
return v;
}
template <typename Stream, typename T>
inline packer<Stream>& operator<< (packer<Stream>& o, const T& v)
{
- o << v.msgpack_pack();
+ v.msgpack_pack(o);
return o;
}
@@ -156,14 +156,15 @@ public:
define() {}
define(msgpack_type v) : msgpack_type(v) {}
- msgpack_type msgpack_pack() const
+ template <typename Packer>
+ void msgpack_pack(Packer& o) const
{
- return *this;
+ o << static_cast<const msgpack_type&>(*this);
}
void msgpack_unpack(object o)
{
- convert(static_cast<msgpack_type&>(*this), o);
+ o >> static_cast<msgpack_type&>(*this);
}
};
diff --git a/cpp/test.cpp b/cpp/test.cpp
index 02d461c..dd0b1fd 100644
--- a/cpp/test.cpp
+++ b/cpp/test.cpp
@@ -50,6 +50,7 @@ int main(void)
{
checker c;
+#if 0
{ // SimpleValue
const char d[] = {
0x93, 0xc0, 0xc2, 0xc3,
@@ -116,9 +117,10 @@ int main(void)
)
);
}
+#endif
- static const unsigned TASK_ARRAY = 100;
+ static const unsigned TASK_ARRAY = 1000;
static const unsigned TASK_REPEAT = 10;
std::vector<std::string> task;
diff --git a/cpp/unpack.hpp b/cpp/unpack.hpp
index fe20fc7..293a5d3 100644
--- a/cpp/unpack.hpp
+++ b/cpp/unpack.hpp
@@ -24,8 +24,7 @@
#include <stdexcept>
#ifndef MSGPACK_UNPACKER_DEFAULT_INITIAL_BUFFER_SIZE
-#define MSGPACK_UNPACKER_DEFAULT_INITIAL_BUFFER_SIZE 16
-//#define MSGPACK_UNPACKER_DEFAULT_INITIAL_BUFFER_SIZE 8*1024
+#define MSGPACK_UNPACKER_DEFAULT_INITIAL_BUFFER_SIZE (32*1024)
#endif
namespace msgpack {