Updated: msgpack::unpacked is the typedef of the msgpack::object_handle now.

See the following discussion:
https://github.com/msgpack/msgpack-c/pull/288
This commit is contained in:
Takatoshi Kondo
2015-05-31 20:40:05 +09:00
parent f75da23e1d
commit de721af166
3 changed files with 6 additions and 77 deletions

View File

@@ -36,67 +36,6 @@ namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) { MSGPACK_API_VERSION_NAMESPACE(v1) {
/// @endcond /// @endcond
#if defined(MSGPACK_USE_CPP03)
class unpacked;
struct unpacked_ref {
unpacked_ref(unpacked* unp):m_unp(unp) {}
unpacked* m_unp;
};
#endif // defined(MSGPACK_USE_CPP03)
// obsolete (use object_handle)
class unpacked {
public:
unpacked() {}
unpacked(msgpack::object const& obj, msgpack::unique_ptr<msgpack::zone> z) :
m_obj(obj), m_zone(msgpack::move(z)) { }
void set(msgpack::object const& obj)
{ m_obj = obj; }
const msgpack::object& get() const
{ return m_obj; }
msgpack::unique_ptr<msgpack::zone>& zone()
{ return m_zone; }
const msgpack::unique_ptr<msgpack::zone>& zone() const
{ return m_zone; }
#if defined(MSGPACK_USE_CPP03)
unpacked(unpacked& other):
m_obj(other.m_obj),
m_zone(msgpack::move(other.m_zone)) {
}
unpacked(unpacked_ref ref):
m_obj(ref.m_unp->m_obj),
m_zone(msgpack::move(ref.m_unp->m_zone)) {
}
unpacked& operator=(unpacked& other) {
m_obj = other.m_obj;
m_zone = msgpack::move(other.m_zone);
return *this;
}
unpacked& operator=(unpacked_ref ref) {
m_obj = ref.m_unp->m_obj;
m_zone = msgpack::move(ref.m_unp->m_zone);
return *this;
}
operator msgpack::unpacked_ref() {
return msgpack::unpacked_ref(this);
}
#endif // defined(MSGPACK_USE_CPP03)
private:
msgpack::object m_obj;
msgpack::unique_ptr<msgpack::zone> m_zone;
};
class object_handle { class object_handle {
public: public:
object_handle() {} object_handle() {}
@@ -104,6 +43,10 @@ public:
object_handle(msgpack::object const& obj, msgpack::unique_ptr<msgpack::zone> z) : object_handle(msgpack::object const& obj, msgpack::unique_ptr<msgpack::zone> z) :
m_obj(obj), m_zone(msgpack::move(z)) { } m_obj(obj), m_zone(msgpack::move(z)) { }
// obsolete
void set(msgpack::object const& obj)
{ m_obj = obj; }
const msgpack::object& get() const const msgpack::object& get() const
{ return m_obj; } { return m_obj; }
@@ -129,11 +72,6 @@ public:
m_zone(msgpack::move(ref.m_oh->m_zone)) { m_zone(msgpack::move(ref.m_oh->m_zone)) {
} }
object_handle(msgpack::unpacked_ref ref):
m_obj(ref.m_unp->get()),
m_zone(msgpack::move(ref.m_unp->zone())) {
}
object_handle& operator=(object_handle& other) { object_handle& operator=(object_handle& other) {
m_obj = other.m_obj; m_obj = other.m_obj;
m_zone = msgpack::move(other.m_zone); m_zone = msgpack::move(other.m_zone);
@@ -146,17 +84,9 @@ public:
return *this; return *this;
} }
object_handle& operator=(msgpack::unpacked_ref ref) {
m_obj = ref.m_unp->get();
m_zone = msgpack::move(ref.m_unp->zone());
return *this;
}
operator object_handle_ref() { operator object_handle_ref() {
return object_handle_ref(this); return object_handle_ref(this);
} }
#else // defined(MSGPACK_USE_CPP03)
object_handle(msgpack::unpacked&& unp): m_obj(unp.get()), m_zone(std::move(unp.zone())) {}
#endif // defined(MSGPACK_USE_CPP03) #endif // defined(MSGPACK_USE_CPP03)
private: private:

View File

@@ -991,6 +991,8 @@ inline int context::execute(const char* data, std::size_t len, std::size_t& off)
} // detail } // detail
typedef object_handle unpacked;
class unpacker { class unpacker {
public: public:
unpacker(unpack_reference_func f = &unpacker::default_reference_func, unpacker(unpack_reference_func f = &unpacker::default_reference_func,

View File

@@ -309,8 +309,6 @@ TEST(unpack, convert_to_object_handle_direct)
} }
#if !defined(MSGPACK_USE_CPP03)
TEST(unpack, convert_to_object_handle_direct_implicit) TEST(unpack, convert_to_object_handle_direct_implicit)
{ {
msgpack::sbuffer sbuf; msgpack::sbuffer sbuf;
@@ -319,4 +317,3 @@ TEST(unpack, convert_to_object_handle_direct_implicit)
EXPECT_EQ(1, oh.get().as<int>()); EXPECT_EQ(1, oh.get().as<int>());
} }
#endif // !defined(MSGPACK_USE_CPP03)