Removed obsolete unpack() API.

This commit is contained in:
Takatoshi Kondo 2016-03-26 11:16:56 +09:00
parent 62048e1aa0
commit db90ee4283
7 changed files with 350 additions and 2 deletions

View File

@ -374,6 +374,7 @@ IF (MSGPACK_ENABLE_CXX)
include/msgpack/v2/object_fwd_decl.hpp
include/msgpack/v2/pack_decl.hpp
include/msgpack/v2/sbuffer_decl.hpp
include/msgpack/v2/unpack.hpp
include/msgpack/v2/unpack_decl.hpp
include/msgpack/v2/vrefbuffer_decl.hpp
include/msgpack/v2/zbuffer_decl.hpp

View File

@ -13,5 +13,6 @@
#include "msgpack/unpack_decl.hpp"
#include "msgpack/v1/unpack.hpp"
#include "msgpack/v2/unpack.hpp"
#endif // MSGPACK_UNPACK_HPP

View File

@ -0,0 +1,134 @@
//
// MessagePack for C++ deserializing 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_UNPACK_HPP
#define MSGPACK_V2_UNPACK_HPP
#include "msgpack/unpack_decl.hpp"
namespace msgpack {
/// @cond
MSGPACK_API_VERSION_NAMESPACE(v2) {
/// @endcond
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
)
{
return v1::unpack(data, len, off, referenced, f, user_data, limit);
}
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)
{
return v1::unpack(data, len, off, f, user_data, limit);
}
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)
{
return v1::unpack(data, len, referenced, f, user_data, limit);
}
inline msgpack::object_handle unpack(
const char* data, std::size_t len,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
{
return v1::unpack(data, len, f, user_data, limit);
}
inline void unpack(
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)
{
v1::unpack(result, data, len, off, referenced, f, user_data, limit);
}
inline void unpack(
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)
{
v1::unpack(result, data, len, off, f, user_data, limit);
}
inline void unpack(
msgpack::object_handle& result,
const char* data, std::size_t len, bool& referenced,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
{
v1::unpack(result, data, len, referenced, f, user_data, limit);
}
inline void unpack(
msgpack::object_handle& result,
const char* data, std::size_t len,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
{
v1::unpack(result, data, len, f, user_data, limit);
}
inline msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len, std::size_t& off, bool& referenced,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
{
return v1::unpack(z, data, len, off, referenced, f, user_data, limit);
}
inline msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len, std::size_t& off,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
{
return v1::unpack(z, data, len, off, f, user_data, limit);
}
inline msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len, bool& referenced,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
{
return v1::unpack(z, data, len, referenced, f, user_data, limit);
}
inline msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len,
unpack_reference_func f, void* user_data,
unpack_limit const& limit)
{
return v1::unpack(z, data, len, f, user_data, limit);
}
/// @cond
} // MSGPACK_API_VERSION_NAMESPACE(v2)
/// @endcond
} // namespace msgpack
#endif // MSGPACK_V2_UNPACK_HPP

View File

@ -85,10 +85,214 @@ using v1::unpacked;
using v1::unpacker;
using v1::unpack;
using v1::unpack_return;
/// Unpack msgpack::object from a buffer.
/**
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param off The offset position of the buffer. It is read and overwritten.
* @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
* @return object_handle that contains unpacked data.
*
*/
object_handle unpack(
const char* data, std::size_t len, std::size_t& off, bool& referenced,
unpack_reference_func f = nullptr, void* user_data = nullptr, unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param off The offset position of the buffer. It is read and overwritten.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
* @return object_handle that contains unpacked data.
*
*/
object_handle unpack(
const char* data, std::size_t len, std::size_t& off,
unpack_reference_func f = nullptr, void* user_data = nullptr, unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
* @return object_handle that contains unpacked data.
*
*/
object_handle unpack(
const char* data, std::size_t len, bool& referenced,
unpack_reference_func f = nullptr, void* user_data = nullptr, unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
* @return object_handle that contains unpacked data.
*
*/
object_handle unpack(
const char* data, std::size_t len,
unpack_reference_func f = nullptr, void* user_data = nullptr, unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param result The object_handle that contains unpacked data.
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param off The offset position of the buffer. It is read and overwritten.
* @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
*
*/
void unpack(
object_handle& result,
const char* data, std::size_t len, std::size_t& off, bool& referenced,
unpack_reference_func f = nullptr, void* user_data = nullptr, unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param result The object_handle that contains unpacked data.
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param off The offset position of the buffer. It is read and overwritten.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
*
*/
void unpack(
object_handle& result,
const char* data, std::size_t len, std::size_t& off,
unpack_reference_func f = nullptr, void* user_data = nullptr, unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param result The object_handle that contains unpacked data.
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
*
*/
void unpack(
object_handle& result,
const char* data, std::size_t len, bool& referenced,
unpack_reference_func f = nullptr, void* user_data = nullptr, unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param result The object_handle that contains unpacked data.
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
*
*/
void unpack(
object_handle& result,
const char* data, std::size_t len,
unpack_reference_func f = nullptr, void* user_data = nullptr, unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param z The msgpack::zone that is used as a memory of unpacked msgpack objects.
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param off The offset position of the buffer. It is read and overwritten.
* @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
* @return msgpack::object that contains unpacked data.
*
*/
msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len, std::size_t& off, bool& referenced,
unpack_reference_func f = nullptr, void* user_data = nullptr, unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param z The msgpack::zone that is used as a memory of unpacked msgpack objects.
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param off The offset position of the buffer. It is read and overwritten.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
* @return msgpack::object that contains unpacked data.
*
*/
msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len, std::size_t& off,
unpack_reference_func f = nullptr, void* user_data = nullptr, unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param z The msgpack::zone that is used as a memory of unpacked msgpack objects.
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param referenced If the unpacked object contains reference of the buffer, then set as true, otherwise false.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
* @return msgpack::object that contains unpacked data.
*
*/
msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len, bool& referenced,
unpack_reference_func f = nullptr, void* user_data = nullptr, unpack_limit const& limit = unpack_limit());
/// Unpack msgpack::object from a buffer.
/**
* @param z The msgpack::zone that is used as a memory of unpacked msgpack objects.
* @param data The pointer to the buffer.
* @param len The length of the buffer.
* @param f A judging function that msgpack::object refer to the buffer.
* @param user_data This parameter is passed to f.
* @param limit The size limit information of msgpack::object.
*
* @return msgpack::object that contains unpacked data.
*
*/
msgpack::object unpack(
msgpack::zone& z,
const char* data, std::size_t len,
unpack_reference_func f = nullptr, void* user_data = nullptr, unpack_limit const& limit = unpack_limit());
namespace detail {
using v1::detail::unpack_imp;

View File

@ -363,6 +363,7 @@ nobase_include_HEADERS += \
../include/msgpack/v2/object_fwd_decl.hpp \
../include/msgpack/v2/pack_decl.hpp \
../include/msgpack/v2/sbuffer_decl.hpp \
../include/msgpack/v2/unpack.hpp \
../include/msgpack/v2/unpack_decl.hpp \
../include/msgpack/v2/vrefbuffer_decl.hpp \
../include/msgpack/v2/zbuffer_decl.hpp \

View File

@ -504,6 +504,8 @@ TEST(limit, unpack_array_over_off_ref)
}
// obsolete
#if MSGPACK_DEFAULT_API_VERSION == 1
TEST(limit, unpack_array_over_off_ref_pointer)
{
std::stringstream ss;
@ -528,6 +530,8 @@ TEST(limit, unpack_array_over_off_ref_pointer)
}
}
#endif // MSGPACK_DEFAULT_API_VERSION == 1
TEST(limit, unpacker_array_over)
{
std::stringstream ss;

View File

@ -145,6 +145,7 @@ TEST(unpack, int_offset_ref)
EXPECT_EQ(off, sbuf.size());
}
#if MSGPACK_DEFAULT_API_VERSION == 1
TEST(unpack, int_pointer_off_no_ref)
{
@ -214,6 +215,8 @@ TEST(unpack, int_default_null_pointer)
EXPECT_EQ(1, oh.get().as<int>());
}
#endif // MSGPACK_DEFAULT_API_VERSION == 1
TEST(unpack, int_zone_no_offset_no_ref)
{
msgpack::sbuffer sbuf;