summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/pack.hpp4
-rw-r--r--cpp/unpack.hpp16
-rw-r--r--example/stream.cc7
3 files changed, 16 insertions, 11 deletions
diff --git a/cpp/pack.hpp b/cpp/pack.hpp
index 52854ac..257ccb6 100644
--- a/cpp/pack.hpp
+++ b/cpp/pack.hpp
@@ -30,6 +30,7 @@ template <typename Stream>
class packer {
public:
packer(Stream& s);
+ ~packer();
public:
template <typename T>
@@ -130,6 +131,9 @@ template <typename Stream>
packer<Stream>::packer(Stream& s) : m_stream(s) { }
template <typename Stream>
+packer<Stream>::~packer() { }
+
+template <typename Stream>
inline packer<Stream>& packer<Stream>::pack_uint8(uint8_t d)
{ _pack_uint8(m_stream, d); return *this; }
diff --git a/cpp/unpack.hpp b/cpp/unpack.hpp
index 4e7ccf5..e6d35da 100644
--- a/cpp/unpack.hpp
+++ b/cpp/unpack.hpp
@@ -128,10 +128,10 @@ private:
typedef enum {
- MSGPACK_UNPACK_SUCCESS = 2,
- MSGPACK_UNPACK_EXTRA_BYTES = 1,
- MSGPACK_UNPACK_CONTINUE = 0,
- MSGPACK_UNPACK_PARSE_ERROR = -1,
+ UNPACK_SUCCESS = 2,
+ UNPACK_EXTRA_BYTES = 1,
+ UNPACK_CONTINUE = 0,
+ UNPACK_PARSE_ERROR = -1,
} unpack_return;
static unpack_return unpack(const char* data, size_t len, size_t* off,
@@ -249,20 +249,20 @@ inline object unpack(const char* data, size_t len, zone& z, size_t* off)
object result;
switch( msgpack::unpack(data, len, off, &z, &result) ) {
- case MSGPACK_UNPACK_SUCCESS:
+ case UNPACK_SUCCESS:
return result;
- case MSGPACK_UNPACK_EXTRA_BYTES:
+ case UNPACK_EXTRA_BYTES:
if(off) {
return result;
} else {
throw unpack_error("extra bytes");
}
- case MSGPACK_UNPACK_CONTINUE:
+ case UNPACK_CONTINUE:
throw unpack_error("insufficient bytes");
- case MSGPACK_UNPACK_PARSE_ERROR:
+ case UNPACK_PARSE_ERROR:
default:
throw unpack_error("parse error");
}
diff --git a/example/stream.cc b/example/stream.cc
index e57318f..8fd92f9 100644
--- a/example/stream.cc
+++ b/example/stream.cc
@@ -113,6 +113,7 @@ int main(void)
// client thread:
fwriter writer(pair[1]);
+ msgpack::packer<fwriter> pk(writer);
typedef msgpack::type::tuple<std::string, std::string, std::string> put_t;
typedef msgpack::type::tuple<std::string, std::string> get_t;
@@ -120,9 +121,9 @@ int main(void)
put_t req1("put", "apple", "red");
put_t req2("put", "lemon", "yellow");
get_t req3("get", "apple");
- msgpack::pack(writer, req1);
- msgpack::pack(writer, req2);
- msgpack::pack(writer, req3);
+ pk.pack(req1);
+ pk.pack(req2);
+ pk.pack(req3);
writer.flush();
writer.close();