Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions include/msgpack/unpack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
#include "msgpack/unpack_decl.hpp"

#include "msgpack/v1/unpack.hpp"
#include "msgpack/v2/unpack.hpp"

#endif // MSGPACK_UNPACK_HPP
134 changes: 134 additions & 0 deletions include/msgpack/v2/unpack.hpp
Original file line number Diff line number Diff line change
@@ -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
208 changes: 206 additions & 2 deletions include/msgpack/v2/unpack_decl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
4 changes: 4 additions & 0 deletions test/limit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Loading