Removed obsolete APIs form v2.

Removed MSGPACK_DISABLE_LEGACY_CONVERT from v2. Those APIs are removed
from v2.
This commit is contained in:
Takatoshi Kondo
2016-03-21 22:34:57 +09:00
parent 72c7feb2c4
commit 31a06a0682
17 changed files with 362 additions and 80 deletions

View File

@@ -13,5 +13,6 @@
#include "msgpack/object_decl.hpp"
#include "msgpack/v1/object.hpp"
#include "msgpack/v2/object.hpp"
#endif // MSGPACK_OBJECT_HPP

View File

@@ -43,7 +43,7 @@ struct object_with_zone;
// operators
template <typename T>
msgpack::object const& operator>> (msgpack::object const& o, T& v);
msgpack::object const& operator>> (msgpack::object const& o, T& v);
template <typename Stream, typename T>
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, T const& v);

View File

@@ -26,6 +26,19 @@ namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v1) {
/// @endcond
struct object_kv {
msgpack::object key;
msgpack::object val;
};
struct object::with_zone : msgpack::object {
with_zone(msgpack::zone& z) : zone(z) { }
msgpack::zone& zone;
private:
with_zone();
};
/// The class holds object and zone
class object_handle {
public:
@@ -171,16 +184,8 @@ inline object_handle clone(msgpack::object const& obj) {
return object_handle(newobj, msgpack::move(z));
}
struct object::implicit_type {
implicit_type(object const& o) : obj(o) { }
~implicit_type() { }
template <typename T>
operator T() { return obj.as<T>(); }
private:
msgpack::object const& obj;
};
template <typename T>
inline object::implicit_type::operator T() { return obj.as<T>(); }
namespace detail {
template <typename Stream, typename T>
@@ -515,9 +520,9 @@ inline bool operator!=(const T& y, const msgpack::object& x)
{ return x != y; }
inline msgpack::object::implicit_type object::convert() const
inline object::implicit_type object::convert() const
{
return msgpack::object::implicit_type(*this);
return object::implicit_type(*this);
}
template <typename T>
@@ -580,7 +585,7 @@ inline object::object()
template <typename T>
inline object::object(const T& v)
{
msgpack::operator<<(*this, v);
*this << v;
}
template <typename T>

View File

@@ -212,7 +212,7 @@ struct object {
struct with_zone;
private:
protected:
struct implicit_type;
public:
@@ -221,16 +221,15 @@ public:
class type_error : public std::bad_cast { };
struct object_kv {
msgpack::object key;
msgpack::object val;
};
struct object::implicit_type {
implicit_type(object const& o) : obj(o) { }
~implicit_type() { }
template <typename T>
operator T();
struct object::with_zone : object {
with_zone(msgpack::zone& z) : zone(z) { }
msgpack::zone& zone;
private:
with_zone();
object const& obj;
};
/// @cond

View File

@@ -1003,7 +1003,7 @@ public:
* This function is obsolete. Use the reference inteface version of next() function instead of
* the pointer interface version.
*/
bool next(object_handle* result);
bool next(msgpack::object_handle* result);
/// Unpack one msgpack::object.
/**
@@ -1019,7 +1019,7 @@ public:
* See:
* https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_unpacker#msgpack-controls-a-buffer
*/
bool next(object_handle& result, bool& referenced);
bool next(msgpack::object_handle& result, bool& referenced);
/// Unpack one msgpack::object.
/**
@@ -1033,7 +1033,7 @@ public:
* See:
* https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_unpacker#msgpack-controls-a-buffer
*/
bool next(object_handle& result);
bool next(msgpack::object_handle& result);
/// Get message size.
/**
@@ -1281,7 +1281,7 @@ inline void unpacker::buffer_consumed(std::size_t size)
m_free -= size;
}
inline bool unpacker::next(object_handle& result, bool& referenced)
inline bool unpacker::next(msgpack::object_handle& result, bool& referenced)
{
referenced = false;
int ret = execute_imp();
@@ -1291,7 +1291,7 @@ inline bool unpacker::next(object_handle& result, bool& referenced)
if(ret == 0) {
result.zone().reset();
result.set(object());
result.set(msgpack::object());
return false;
} else {
@@ -1303,13 +1303,13 @@ inline bool unpacker::next(object_handle& result, bool& referenced)
}
}
inline bool unpacker::next(object_handle& result)
inline bool unpacker::next(msgpack::object_handle& result)
{
bool referenced;
return next(result, referenced);
}
inline bool unpacker::next(object_handle* result)
inline bool unpacker::next(msgpack::object_handle* result)
{
return next(*result);
}
@@ -1461,7 +1461,7 @@ unpack_imp(const char* data, std::size_t len, std::size_t& off,
// reference version
inline object_handle unpack(
inline msgpack::object_handle unpack(
const char* data, std::size_t len, std::size_t& off, bool& referenced,
unpack_reference_func f, void* user_data,
unpack_limit const& limit
@@ -1477,20 +1477,20 @@ inline object_handle unpack(
switch(ret) {
case UNPACK_SUCCESS:
off = noff;
return object_handle(obj, msgpack::move(z));
return msgpack::object_handle(obj, msgpack::move(z));
case UNPACK_EXTRA_BYTES:
off = noff;
return object_handle(obj, msgpack::move(z));
return msgpack::object_handle(obj, msgpack::move(z));
case UNPACK_CONTINUE:
throw msgpack::insufficient_bytes("insufficient bytes");
case UNPACK_PARSE_ERROR:
default:
throw msgpack::parse_error("parse error");
}
return object_handle();
return msgpack::object_handle();
}
inline object_handle unpack(
inline msgpack::object_handle unpack(
const char* data, std::size_t len, std::size_t& off,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
@@ -1499,7 +1499,7 @@ inline object_handle unpack(
return unpack(data, len, off, referenced, f, user_data, limit);
}
inline object_handle unpack(
inline msgpack::object_handle unpack(
const char* data, std::size_t len, bool& referenced,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
@@ -1508,7 +1508,7 @@ inline object_handle unpack(
return unpack(data, len, off, referenced, f, user_data, limit);
}
inline object_handle unpack(
inline msgpack::object_handle unpack(
const char* data, std::size_t len,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
@@ -1519,7 +1519,7 @@ inline object_handle unpack(
}
inline void unpack(
object_handle& result,
msgpack::object_handle& result,
const char* data, std::size_t len, std::size_t& off, bool& referenced,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
@@ -1551,7 +1551,7 @@ inline void unpack(
}
inline void unpack(
object_handle& result,
msgpack::object_handle& result,
const char* data, std::size_t len, std::size_t& off,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
@@ -1561,7 +1561,7 @@ inline void unpack(
}
inline void unpack(
object_handle& result,
msgpack::object_handle& result,
const char* data, std::size_t len, bool& referenced,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
@@ -1571,7 +1571,7 @@ inline void unpack(
}
inline void unpack(
object_handle& result,
msgpack::object_handle& result,
const char* data, std::size_t len,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
@@ -1644,7 +1644,7 @@ inline msgpack::object unpack(
// obsolete
// pointer version
inline void unpack(
object_handle* result,
msgpack::object_handle* result,
const char* data, std::size_t len, std::size_t* off, bool* referenced,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)

View File

@@ -0,0 +1,33 @@
//
// MessagePack for C++ static resolution routine
//
// Copyright (C) 2016 KONDO Takatoshi
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef MSGPACK_V2_OBJECT_HPP
#define MSGPACK_V2_OBJECT_HPP
#include "msgpack/object_fwd.hpp"
namespace msgpack {
/// @cond
MSGPACK_API_VERSION_NAMESPACE(v2) {
/// @endcond
inline object::implicit_type object::convert() const
{
return v1::object::convert();
}
/// @cond
} // MSGPACK_API_VERSION_NAMESPACE(v2)
/// @endcond
} // namespace msgpack
#endif // MSGPACK_V2_OBJECT_HPP

View File

@@ -37,21 +37,9 @@ using v1::detail::packer_serializer;
} // namespace detail
// obsolete
using v1::define;
using v1::operator==;
using v1::operator!=;
// obsolete
using v1::convert;
// obsolete
using v1::pack;
// obsolete
using v1::pack_copy;
/// @cond
} // MSGPACK_API_VERSION_NAMESPACE(v2)
/// @endcond

View File

@@ -12,6 +12,7 @@
#define MSGPACK_V2_OBJECT_FWD_HPP
#include "msgpack/v2/object_fwd_decl.hpp"
#include "msgpack/object_fwd.hpp"
namespace msgpack {
@@ -19,6 +20,49 @@ namespace msgpack {
MSGPACK_API_VERSION_NAMESPACE(v2) {
/// @endcond
struct object : v1::object {
object() {}
object(v1::object const& o):v1::object(o) {}
/// Construct object from T
/**
* If `v` is the type that is corresponding to MessegePack format str, bin, ext, array, or map,
* you need to call `object(const T& v, msgpack::zone& z)` instead of this constructor.
*
* @tparam T The type of `v`.
* @param v The value you want to convert.
*/
template <typename T>
explicit object(const T& v) {
*this << v;
}
/// Construct object from T
/**
* The object is constructed on the zone `z`.
* See https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_object
*
* @tparam T The type of `v`.
* @param v The value you want to convert.
* @param z The zone that is used by the object.
*/
template <typename T>
object(const T& v, msgpack::zone& z):v1::object(v, z) {}
public:
/// Convert the object
/**
* If the object can't be converted to T, msgpack::type_error would be thrown.
* @tparam T The type of v.
* @param v The value you want to get. `v` is output parameter. `v` is overwritten by converted value from the object.
* @return The reference of `v`.
*/
template <typename T>
T& convert(T& v) const { return v1::object::convert(v); }
using v1::object::with_zone;
implicit_type convert() const;
};
#if !defined(MSGPACK_USE_CPP03)
namespace adaptor {

View File

@@ -36,7 +36,8 @@ using v1::type::MAP;
using v1::type::EXT;
} // namespace type
using v1::object;
struct object;
using v1::object_kv;
using v1::object_array;