From d078eb0ad5b2b1c7749942a4618f6cfedd1067d5 Mon Sep 17 00:00:00 2001 From: frsyuki Date: Sun, 22 Feb 2009 15:36:02 +0900 Subject: type conversion operator msgpack_object <-> msgpack::object --- cpp/object.hpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'cpp/object.hpp') diff --git a/cpp/object.hpp b/cpp/object.hpp index 08e715d..c3f2872 100644 --- a/cpp/object.hpp +++ b/cpp/object.hpp @@ -18,8 +18,10 @@ #ifndef MSGPACK_OBJECT_HPP__ #define MSGPACK_OBJECT_HPP__ +#include "msgpack/object.h" #include "msgpack/pack.hpp" #include +#include #include #include #include @@ -72,6 +74,7 @@ struct object { object_array array; object_map map; object_raw raw; + object_raw ref; // obsolete }; type::object_type type; @@ -85,6 +88,10 @@ struct object { template void convert(T* v); + object(); + object(msgpack_object obj); + operator msgpack_object(); + private: struct implicit_type; @@ -192,6 +199,23 @@ inline bool operator!=(const object x, const object y) { return !(x == y); } +inline object::object() { } + +inline object::object(msgpack_object obj) +{ + // FIXME beter way? + ::memcpy(this, &obj, sizeof(obj)); +} + +inline object::operator msgpack_object() +{ + // FIXME beter way? + msgpack_object obj; + ::memcpy(&obj, this, sizeof(obj)); + return obj; +} + + inline object::implicit_type object::convert() { return implicit_type(*this); -- cgit v1.2.1