mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-23 08:31:45 +02:00
Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a277ea7c64 | ||
![]() |
285ccfeeea | ||
![]() |
232b8039a0 | ||
![]() |
10a315e00e | ||
![]() |
904dd65965 | ||
![]() |
dff7af2075 | ||
![]() |
ed91c18af8 | ||
![]() |
616b1d8fb0 | ||
![]() |
ce98964348 | ||
![]() |
07a509a53a | ||
![]() |
35483b95ae | ||
![]() |
a2c8154960 | ||
![]() |
e8d3c8d6c5 | ||
![]() |
ae5734e8d1 | ||
![]() |
6ec09053b1 | ||
![]() |
5401660b07 | ||
![]() |
f3caa8e160 | ||
![]() |
8921f9dcfc | ||
![]() |
1911513acb |
17
CHANGELOG.md
17
CHANGELOG.md
@@ -1,4 +1,19 @@
|
|||||||
2015-3-22 version 1.0.1:
|
2015-04-03 version 1.1.0
|
||||||
|
<< breaking change >>
|
||||||
|
* Remove msgpack_fwd.hpp
|
||||||
|
* Improve user types adaptation mechanism (#262)
|
||||||
|
Since version 1.0.0, users need to obey the correct include order.
|
||||||
|
However, it is very difficult to maintain the correct order in big
|
||||||
|
projects. version 1.1.0 removed this order. Users don't need to
|
||||||
|
care about include order. Migration guide from 1.0.x to 1.1.0 has
|
||||||
|
been written. See https://github.com/msgpack/msgpack-c/wiki
|
||||||
|
|
||||||
|
* Fix vector<bool> size check (#251)
|
||||||
|
* Fix inttypes.h inclusion on MSVC (#257)
|
||||||
|
* Support documents generation by Doxygen (#259)
|
||||||
|
* Remove C99 style variable declaration (#253)
|
||||||
|
* Improve documents (https://github.com/msgpack/msgpack-c/wiki)
|
||||||
|
2015-03-22 version 1.0.1:
|
||||||
* Fix compilation error on Mac 10.9 (#244)
|
* Fix compilation error on Mac 10.9 (#244)
|
||||||
* Fix typos in documents (#240)
|
* Fix typos in documents (#240)
|
||||||
* Update CHANGELOG.md for version 1.0.0 (#242)
|
* Update CHANGELOG.md for version 1.0.0 (#242)
|
||||||
|
@@ -98,65 +98,38 @@ LIST (APPEND msgpack_HEADERS
|
|||||||
IF (MSGPACK_ENABLE_CXX)
|
IF (MSGPACK_ENABLE_CXX)
|
||||||
LIST (APPEND msgpack_HEADERS
|
LIST (APPEND msgpack_HEADERS
|
||||||
include/msgpack.hpp
|
include/msgpack.hpp
|
||||||
include/msgpack_fwd.hpp
|
include/msgpack/adaptor/adaptor_base.hpp
|
||||||
include/msgpack/adaptor/bool.hpp
|
include/msgpack/adaptor/bool.hpp
|
||||||
include/msgpack/adaptor/bool_fwd.hpp
|
|
||||||
include/msgpack/adaptor/char_ptr.hpp
|
include/msgpack/adaptor/char_ptr.hpp
|
||||||
include/msgpack/adaptor/char_ptr_fwd.hpp
|
|
||||||
include/msgpack/adaptor/check_container_size.hpp
|
include/msgpack/adaptor/check_container_size.hpp
|
||||||
include/msgpack/adaptor/cpp11/array.hpp
|
include/msgpack/adaptor/cpp11/array.hpp
|
||||||
include/msgpack/adaptor/cpp11/array_fwd.hpp
|
|
||||||
include/msgpack/adaptor/cpp11/array_char.hpp
|
include/msgpack/adaptor/cpp11/array_char.hpp
|
||||||
include/msgpack/adaptor/cpp11/array_char_fwd.hpp
|
|
||||||
include/msgpack/adaptor/cpp11/forward_list.hpp
|
include/msgpack/adaptor/cpp11/forward_list.hpp
|
||||||
include/msgpack/adaptor/cpp11/forward_list_fwd.hpp
|
|
||||||
include/msgpack/adaptor/cpp11/tuple.hpp
|
include/msgpack/adaptor/cpp11/tuple.hpp
|
||||||
include/msgpack/adaptor/cpp11/tuple_fwd.hpp
|
|
||||||
include/msgpack/adaptor/cpp11/unordered_map.hpp
|
include/msgpack/adaptor/cpp11/unordered_map.hpp
|
||||||
include/msgpack/adaptor/cpp11/unordered_map_fwd.hpp
|
|
||||||
include/msgpack/adaptor/cpp11/unordered_set.hpp
|
include/msgpack/adaptor/cpp11/unordered_set.hpp
|
||||||
include/msgpack/adaptor/cpp11/unordered_set_fwd.hpp
|
|
||||||
include/msgpack/adaptor/define.hpp
|
include/msgpack/adaptor/define.hpp
|
||||||
include/msgpack/adaptor/deque.hpp
|
include/msgpack/adaptor/deque.hpp
|
||||||
include/msgpack/adaptor/deque_fwd.hpp
|
|
||||||
include/msgpack/adaptor/detail/cpp03_define.hpp
|
include/msgpack/adaptor/detail/cpp03_define.hpp
|
||||||
include/msgpack/adaptor/detail/cpp03_msgpack_tuple.hpp
|
include/msgpack/adaptor/detail/cpp03_msgpack_tuple.hpp
|
||||||
include/msgpack/adaptor/detail/cpp03_msgpack_tuple_fwd.hpp
|
|
||||||
include/msgpack/adaptor/detail/cpp11_define.hpp
|
include/msgpack/adaptor/detail/cpp11_define.hpp
|
||||||
include/msgpack/adaptor/detail/cpp11_msgpack_tuple.hpp
|
include/msgpack/adaptor/detail/cpp11_msgpack_tuple.hpp
|
||||||
include/msgpack/adaptor/detail/cpp11_msgpack_tuple_fwd.hpp
|
|
||||||
include/msgpack/adaptor/fixint.hpp
|
include/msgpack/adaptor/fixint.hpp
|
||||||
include/msgpack/adaptor/fixint_fwd.hpp
|
|
||||||
include/msgpack/adaptor/float.hpp
|
include/msgpack/adaptor/float.hpp
|
||||||
include/msgpack/adaptor/float_fwd.hpp
|
|
||||||
include/msgpack/adaptor/int.hpp
|
include/msgpack/adaptor/int.hpp
|
||||||
include/msgpack/adaptor/int_fwd.hpp
|
|
||||||
include/msgpack/adaptor/list.hpp
|
include/msgpack/adaptor/list.hpp
|
||||||
include/msgpack/adaptor/list_fwd.hpp
|
|
||||||
include/msgpack/adaptor/map.hpp
|
include/msgpack/adaptor/map.hpp
|
||||||
include/msgpack/adaptor/map_fwd.hpp
|
|
||||||
include/msgpack/adaptor/msgpack_tuple.hpp
|
include/msgpack/adaptor/msgpack_tuple.hpp
|
||||||
include/msgpack/adaptor/msgpack_tuple_fwd.hpp
|
|
||||||
include/msgpack/adaptor/nil.hpp
|
include/msgpack/adaptor/nil.hpp
|
||||||
include/msgpack/adaptor/nil_fwd.hpp
|
|
||||||
include/msgpack/adaptor/pair.hpp
|
include/msgpack/adaptor/pair.hpp
|
||||||
include/msgpack/adaptor/pair_fwd.hpp
|
|
||||||
include/msgpack/adaptor/raw.hpp
|
include/msgpack/adaptor/raw.hpp
|
||||||
include/msgpack/adaptor/raw_fwd.hpp
|
|
||||||
include/msgpack/adaptor/set.hpp
|
include/msgpack/adaptor/set.hpp
|
||||||
include/msgpack/adaptor/set_fwd.hpp
|
|
||||||
include/msgpack/adaptor/string.hpp
|
include/msgpack/adaptor/string.hpp
|
||||||
include/msgpack/adaptor/string_fwd.hpp
|
|
||||||
include/msgpack/adaptor/tr1/unordered_map.hpp
|
include/msgpack/adaptor/tr1/unordered_map.hpp
|
||||||
include/msgpack/adaptor/tr1/unordered_map_fwd.hpp
|
|
||||||
include/msgpack/adaptor/tr1/unordered_set.hpp
|
include/msgpack/adaptor/tr1/unordered_set.hpp
|
||||||
include/msgpack/adaptor/tr1/unordered_set_fwd.hpp
|
|
||||||
include/msgpack/adaptor/vector.hpp
|
include/msgpack/adaptor/vector.hpp
|
||||||
include/msgpack/adaptor/vector_fwd.hpp
|
|
||||||
include/msgpack/adaptor/vector_bool.hpp
|
include/msgpack/adaptor/vector_bool.hpp
|
||||||
include/msgpack/adaptor/vector_bool_fwd.hpp
|
|
||||||
include/msgpack/adaptor/vector_char.hpp
|
include/msgpack/adaptor/vector_char.hpp
|
||||||
include/msgpack/adaptor/vector_char_fwd.hpp
|
|
||||||
include/msgpack/cpp_config.hpp
|
include/msgpack/cpp_config.hpp
|
||||||
include/msgpack/detail/cpp03_zone.hpp
|
include/msgpack/detail/cpp03_zone.hpp
|
||||||
include/msgpack/detail/cpp11_zone.hpp
|
include/msgpack/detail/cpp11_zone.hpp
|
||||||
@@ -245,6 +218,8 @@ IF (DOXYGEN_FOUND)
|
|||||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo "FILE_PATTERNS = *.h" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
COMMAND ${CMAKE_COMMAND} -E echo "FILE_PATTERNS = *.h" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo "OUTPUT_DIRECTORY = doc_c" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
COMMAND ${CMAKE_COMMAND} -E echo "OUTPUT_DIRECTORY = doc_c" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo "INPUT = ${CMAKE_CURRENT_SOURCE_DIR}/include" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo "EXTRACT_ALL = YES" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo "PROJECT_NAME = \"MessagePack for C\"" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
COMMAND ${CMAKE_COMMAND} -E echo "PROJECT_NAME = \"MessagePack for C\"" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
||||||
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
||||||
VERBATIM
|
VERBATIM
|
||||||
@@ -254,6 +229,8 @@ IF (DOXYGEN_FOUND)
|
|||||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo "FILE_PATTERNS = *.hpp" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
COMMAND ${CMAKE_COMMAND} -E echo "FILE_PATTERNS = *.hpp" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo "OUTPUT_DIRECTORY = doc_cpp" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
COMMAND ${CMAKE_COMMAND} -E echo "OUTPUT_DIRECTORY = doc_cpp" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo "INPUT = ${CMAKE_CURRENT_SOURCE_DIR}/include" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E echo "EXTRACT_ALL = YES" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
||||||
COMMAND ${CMAKE_COMMAND} -E echo "PROJECT_NAME = \"MessagePack for C++\"" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
COMMAND ${CMAKE_COMMAND} -E echo "PROJECT_NAME = \"MessagePack for C++\"" >> ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
||||||
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
||||||
VERBATIM
|
VERBATIM
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
`msgpack` for C/C++
|
`msgpack` for C/C++
|
||||||
===================
|
===================
|
||||||
|
|
||||||
Version 1.0.1 [](https://travis-ci.org/msgpack/msgpack-c)
|
Version 1.1.0 [](https://travis-ci.org/msgpack/msgpack-c)
|
||||||
|
|
||||||
It's like JSON but small and fast.
|
It's like JSON but small and fast.
|
||||||
|
|
||||||
@@ -201,7 +201,7 @@ the binaries:' text box.
|
|||||||
### Documentation
|
### Documentation
|
||||||
|
|
||||||
You can get addtional information on the
|
You can get addtional information on the
|
||||||
[wiki](https://github.com/msgpack/msgpack-c/wiki/cpp_overview).
|
[wiki](https://github.com/msgpack/msgpack-c/wiki).
|
||||||
|
|
||||||
Contributing
|
Contributing
|
||||||
------------
|
------------
|
||||||
|
@@ -19,8 +19,8 @@
|
|||||||
#define MSGPACK_CPP03_DEFINE_HPP
|
#define MSGPACK_CPP03_DEFINE_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/adaptor/msgpack_tuple_fwd.hpp"
|
#include "msgpack/adaptor/msgpack_tuple.hpp"
|
||||||
#include "msgpack/adaptor/int_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/object_fwd.hpp"
|
||||||
|
|
||||||
#define MSGPACK_DEFINE(...) \
|
#define MSGPACK_DEFINE(...) \
|
||||||
@@ -40,44 +40,57 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MSGPACK_ADD_ENUM must be used in the global namespace.
|
// MSGPACK_ADD_ENUM must be used in the global namespace.
|
||||||
#define MSGPACK_ADD_ENUM(enum) \
|
#define MSGPACK_ADD_ENUM(enum_name) \
|
||||||
namespace msgpack { \
|
namespace msgpack { \
|
||||||
|
/** @cond */ \
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) { \
|
MSGPACK_API_VERSION_NAMESPACE(v1) { \
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, enum& v) \
|
/** @endcond */ \
|
||||||
{ \
|
namespace adaptor { \
|
||||||
int tmp; \
|
template<> \
|
||||||
o >> tmp; \
|
struct convert<enum_name> { \
|
||||||
v = static_cast<enum>(tmp); \
|
msgpack::object const& operator()(msgpack::object const& o, enum_name& v) const {\
|
||||||
return o; \
|
int tmp; \
|
||||||
} \
|
o >> tmp; \
|
||||||
inline void operator<< (msgpack::object& o, const enum& v) \
|
v = static_cast<enum_name>(tmp); \
|
||||||
{ \
|
return o; \
|
||||||
o << static_cast<int>(v); \
|
} \
|
||||||
} \
|
}; \
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const enum& v) \
|
template<> \
|
||||||
{ \
|
struct object<enum_name> { \
|
||||||
o << static_cast<int>(v); \
|
void operator()(msgpack::object& o, const enum_name& v) const {\
|
||||||
} \
|
o << static_cast<int>(v); \
|
||||||
namespace detail { \
|
} \
|
||||||
|
}; \
|
||||||
|
template<> \
|
||||||
|
struct object_with_zone<enum_name> { \
|
||||||
|
void operator()(msgpack::object::with_zone& o, const enum_name& v) const { \
|
||||||
|
o << static_cast<int>(v); \
|
||||||
|
} \
|
||||||
|
}; \
|
||||||
|
template<> \
|
||||||
|
struct pack<enum_name> { \
|
||||||
template <typename Stream> \
|
template <typename Stream> \
|
||||||
struct packer_serializer<Stream, enum> { \
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const enum_name& v) const { \
|
||||||
static msgpack::packer<Stream>& pack(msgpack::packer<Stream>& o, const enum& v) { \
|
return o << static_cast<int>(v); \
|
||||||
return o << static_cast<int>(v); \
|
} \
|
||||||
} \
|
}; \
|
||||||
}; \
|
|
||||||
} \
|
|
||||||
} \
|
} \
|
||||||
|
/** @cond */ \
|
||||||
|
} \
|
||||||
|
/** @endcond */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
<% GENERATION_LIMIT = 31 %>
|
<% GENERATION_LIMIT = 31 %>
|
||||||
template <typename A0 = void<%1.upto(GENERATION_LIMIT+1) {|i|%>, typename A<%=i%> = void<%}%>>
|
template <typename A0 = void<%1.upto(GENERATION_LIMIT+1) {|i|%>, typename A<%=i%> = void<%}%>>
|
||||||
struct define;
|
struct define;
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct define<> {
|
struct define<> {
|
||||||
@@ -99,6 +112,8 @@ struct define<> {
|
|||||||
o->via.array.size = 0;
|
o->via.array.size = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @cond
|
||||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||||
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||||
struct define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
|
struct define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
|
||||||
@@ -137,11 +152,14 @@ struct define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
|
|||||||
A<%=j%>& a<%=j%>;<%}%>
|
A<%=j%>& a<%=j%>;<%}%>
|
||||||
};
|
};
|
||||||
<%}%>
|
<%}%>
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
inline define<> make_define()
|
inline define<> make_define()
|
||||||
{
|
{
|
||||||
return define<>();
|
return define<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @cond
|
||||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||||
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||||
define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_define(A0& a0<%1.upto(i) {|j|%>, A<%=j%>& a<%=j%><%}%>)
|
define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_define(A0& a0<%1.upto(i) {|j|%>, A<%=j%>& a<%=j%><%}%>)
|
||||||
@@ -149,9 +167,12 @@ define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_define(A0& a0<%1.upto(i) {|j|%>,
|
|||||||
return define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>(a0<%1.upto(i) {|j|%>, a<%=j%><%}%>);
|
return define<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>(a0<%1.upto(i) {|j|%>, a<%=j%><%}%>);
|
||||||
}
|
}
|
||||||
<%}%>
|
<%}%>
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
|
||||||
|
@@ -20,10 +20,13 @@
|
|||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object.hpp"
|
#include "msgpack/object.hpp"
|
||||||
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
@@ -31,8 +34,10 @@ namespace type {
|
|||||||
// FIXME operator!=
|
// FIXME operator!=
|
||||||
<% GENERATION_LIMIT = 31 %>
|
<% GENERATION_LIMIT = 31 %>
|
||||||
|
|
||||||
template <typename A0<%1.upto(GENERATION_LIMIT+1) {|i|%>, typename A<%=i%><%}%>>
|
/// @cond
|
||||||
|
template <typename A0 = void<%1.upto(GENERATION_LIMIT+1) {|i|%>, typename A<%=i%> = void<%}%>>
|
||||||
struct tuple;
|
struct tuple;
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
template <typename Tuple, int N>
|
template <typename Tuple, int N>
|
||||||
struct tuple_element;
|
struct tuple_element;
|
||||||
@@ -67,6 +72,7 @@ struct tuple_type<const T&> {
|
|||||||
typedef const T& transparent_reference;
|
typedef const T& transparent_reference;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @cond
|
||||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||||
<%0.upto(i) {|j|%>
|
<%0.upto(i) {|j|%>
|
||||||
template <typename A0<%1.upto(i) {|k|%>, typename A<%=k%><%}%>>
|
template <typename A0<%1.upto(i) {|k|%>, typename A<%=k%><%}%>>
|
||||||
@@ -91,6 +97,7 @@ private:
|
|||||||
};
|
};
|
||||||
<%}%>
|
<%}%>
|
||||||
<%}%>
|
<%}%>
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct tuple<> {
|
struct tuple<> {
|
||||||
@@ -98,6 +105,8 @@ struct tuple<> {
|
|||||||
tuple(msgpack::object const& o) { o.convert(*this); }
|
tuple(msgpack::object const& o) { o.convert(*this); }
|
||||||
typedef tuple<> value_type;
|
typedef tuple<> value_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @cond
|
||||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||||
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||||
struct tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
|
struct tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> {
|
||||||
@@ -121,11 +130,14 @@ template <int N, typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
|||||||
inline typename type::const_tuple_element<type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>, N>::const_reference get(type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> const& t)
|
inline typename type::const_tuple_element<type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>, N>::const_reference get(type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> const& t)
|
||||||
{ return t.template get<N>(); }
|
{ return t.template get<N>(); }
|
||||||
<%}%>
|
<%}%>
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
inline tuple<> make_tuple()
|
inline tuple<> make_tuple()
|
||||||
{
|
{
|
||||||
return tuple<>();
|
return tuple<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @cond
|
||||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||||
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||||
inline tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_tuple(typename tuple_type<A0>::transparent_reference a0<%1.upto(i) {|j|%>, typename tuple_type<A<%=j%>>::transparent_reference a<%=j%><%}%>)
|
inline tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_tuple(typename tuple_type<A0>::transparent_reference a0<%1.upto(i) {|j|%>, typename tuple_type<A<%=j%>>::transparent_reference a<%=j%><%}%>)
|
||||||
@@ -133,84 +145,102 @@ inline tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_tuple(typename tuple_type<
|
|||||||
return tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>(a0<%1.upto(i) {|j|%>, a<%=j%><%}%>);
|
return tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>(a0<%1.upto(i) {|j|%>, a<%=j%><%}%>);
|
||||||
}
|
}
|
||||||
<%}%>
|
<%}%>
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (
|
namespace adaptor {
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct convert<type::tuple<> > {
|
||||||
|
msgpack::object const& operator()(
|
||||||
msgpack::object const& o,
|
msgpack::object const& o,
|
||||||
type::tuple<>&) {
|
type::tuple<>&) const {
|
||||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// @cond
|
||||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||||
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||||
inline msgpack::object const& operator>> (
|
struct convert<type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> > {
|
||||||
|
msgpack::object const& operator()(
|
||||||
msgpack::object const& o,
|
msgpack::object const& o,
|
||||||
type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) {
|
type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) const {
|
||||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||||
if(o.via.array.size < <%=i+1%>) { throw msgpack::type_error(); }
|
if(o.via.array.size < <%=i+1%>) { throw msgpack::type_error(); }
|
||||||
<%0.upto(i) {|j|%>
|
<%0.upto(i) {|j|%>
|
||||||
o.via.array.ptr[<%=j%>].convert<typename type::tuple_type<A<%=j%>>::type>(v.template get<<%=j%>>());<%}%>
|
// In order to avoid clang++'s invalid warning, msgpack::object:: has been added.
|
||||||
return o;
|
o.via.array.ptr[<%=j%>].msgpack::object::convert<typename type::tuple_type<A<%=j%>>::type>(v.template get<<%=j%>>());<%}%>
|
||||||
}
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
<%}%>
|
<%}%>
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline const msgpack::packer<Stream>& operator<< (
|
struct pack<type::tuple<> > {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(
|
||||||
msgpack::packer<Stream>& o,
|
msgpack::packer<Stream>& o,
|
||||||
const type::tuple<>&) {
|
const type::tuple<>&) const {
|
||||||
o.pack_array(0);
|
o.pack_array(0);
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
};
|
||||||
template <typename Stream, typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
|
||||||
inline const msgpack::packer<Stream>& operator<< (
|
|
||||||
msgpack::packer<Stream>& o,
|
|
||||||
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) {
|
|
||||||
o.pack_array(<%=i+1%>);
|
|
||||||
<%0.upto(i) {|j|%>
|
|
||||||
o.pack(v.template get<<%=j%>>());<%}%>
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
<%}%>
|
|
||||||
|
|
||||||
inline void operator<< (
|
/// @cond
|
||||||
msgpack::object::with_zone& o,
|
|
||||||
const type::tuple<>&) {
|
|
||||||
o.type = msgpack::type::ARRAY;
|
|
||||||
o.via.array.ptr = nullptr;
|
|
||||||
o.via.array.size = 0;
|
|
||||||
}
|
|
||||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||||
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||||
inline void operator<< (
|
struct pack<type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> > {
|
||||||
msgpack::object::with_zone& o,
|
template <typename Stream>
|
||||||
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) {
|
msgpack::packer<Stream>& operator()(
|
||||||
o.type = msgpack::type::ARRAY;
|
msgpack::packer<Stream>& o,
|
||||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*<%=i+1%>));
|
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) const {
|
||||||
o.via.array.size = <%=i+1%>;
|
o.pack_array(<%=i+1%>);
|
||||||
<%0.upto(i) {|j|%>
|
<%0.upto(i) {|j|%>
|
||||||
o.via.array.ptr[<%=j%>] = msgpack::object(v.template get<<%=j%>>(), o.zone);<%}%>
|
o.pack(v.template get<<%=j%>>());<%}%>
|
||||||
}
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
<%}%>
|
<%}%>
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct object_with_zone<type::tuple<> > {
|
||||||
|
void operator()(
|
||||||
|
msgpack::object::with_zone& o,
|
||||||
|
const type::tuple<>&) const {
|
||||||
|
o.type = msgpack::type::ARRAY;
|
||||||
|
o.via.array.ptr = nullptr;
|
||||||
|
o.via.array.size = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||||
|
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||||
|
struct object_with_zone<type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> > {
|
||||||
|
void operator()(
|
||||||
|
msgpack::object::with_zone& o,
|
||||||
|
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) const {
|
||||||
|
o.type = msgpack::type::ARRAY;
|
||||||
|
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*<%=i+1%>));
|
||||||
|
o.via.array.size = <%=i+1%>;
|
||||||
|
<%0.upto(i) {|j|%>
|
||||||
|
o.via.array.ptr[<%=j%>] = msgpack::object(v.template get<<%=j%>>(), o.zone);<%}%>
|
||||||
|
}
|
||||||
|
};
|
||||||
|
<%}%>
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
|
||||||
//inline std::ostream& operator<< (std::ostream& o, const msgpack::type::tuple<>& v) {
|
|
||||||
// return o << "[]";
|
|
||||||
//}
|
|
||||||
//<%0.upto(GENERATION_LIMIT) {|i|%>
|
|
||||||
//template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
|
||||||
//inline std::ostream& operator<< (std::ostream& o,
|
|
||||||
// const msgpack::type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) {
|
|
||||||
// return o << "["
|
|
||||||
// <%0.upto(i) {|j|%>
|
|
||||||
// <<<%if j != 0 then%> ", " <<<%end%> v.template get<<%=j%>>()<%}%>
|
|
||||||
// << "]";
|
|
||||||
//}
|
|
||||||
//<%}%>
|
|
||||||
|
|
||||||
#endif // MSGPACK_CPP03_MSGPACK_TUPLE_HPP
|
#endif // MSGPACK_CPP03_MSGPACK_TUPLE_HPP
|
||||||
|
@@ -1,125 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2013 FURUHASHI Sadayuki and KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_CPP03_MSGPACK_TUPLE_FWD_HPP
|
|
||||||
#define MSGPACK_CPP03_MSGPACK_TUPLE_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
namespace type {
|
|
||||||
|
|
||||||
// FIXME operator==
|
|
||||||
// FIXME operator!=
|
|
||||||
<% GENERATION_LIMIT = 31 %>
|
|
||||||
|
|
||||||
template <typename A0 = void<%1.upto(GENERATION_LIMIT+1) {|i|%>, typename A<%=i%> = void<%}%>>
|
|
||||||
struct tuple;
|
|
||||||
|
|
||||||
template <typename Tuple, int N>
|
|
||||||
struct tuple_element;
|
|
||||||
|
|
||||||
template <typename Tuple, int N>
|
|
||||||
struct const_tuple_element;
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct tuple_type;
|
|
||||||
|
|
||||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
|
||||||
<%0.upto(i) {|j|%>
|
|
||||||
template <typename A0<%1.upto(i) {|k|%>, typename A<%=k%><%}%>>
|
|
||||||
struct tuple_element<tuple<A0<%1.upto(i) {|k|%>, A<%=k%><%}%>>, <%=j%>>;
|
|
||||||
<%}%>
|
|
||||||
<%}%>
|
|
||||||
|
|
||||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
|
||||||
<%0.upto(i) {|j|%>
|
|
||||||
template <typename A0<%1.upto(i) {|k|%>, typename A<%=k%><%}%>>
|
|
||||||
struct const_tuple_element<tuple<A0<%1.upto(i) {|k|%>, A<%=k%><%}%>>, <%=j%>>;
|
|
||||||
<%}%>
|
|
||||||
<%}%>
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct tuple<>;
|
|
||||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
|
||||||
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
|
||||||
struct tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>;
|
|
||||||
|
|
||||||
template <int N, typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
|
||||||
typename type::tuple_element<type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>, N>::reference get(type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& t);
|
|
||||||
template <int N, typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
|
||||||
typename type::const_tuple_element<type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>, N>::const_reference get(type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> const& t);
|
|
||||||
<%}%>
|
|
||||||
|
|
||||||
tuple<> make_tuple();
|
|
||||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
|
||||||
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
|
||||||
tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_tuple(typename tuple_type<A0>::transparent_reference a0<%1.upto(i) {|j|%>, typename tuple_type<A<%=j%>>::transparent_reference a<%=j%><%}%>);
|
|
||||||
<%}%>
|
|
||||||
|
|
||||||
} // namespace type
|
|
||||||
|
|
||||||
msgpack::object const& operator>> (
|
|
||||||
msgpack::object const& o,
|
|
||||||
type::tuple<>&);
|
|
||||||
|
|
||||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
|
||||||
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
|
||||||
msgpack::object const& operator>> (
|
|
||||||
msgpack::object const& o,
|
|
||||||
type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v);
|
|
||||||
<%}%>
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
const msgpack::packer<Stream>& operator<< (
|
|
||||||
msgpack::packer<Stream>& o,
|
|
||||||
const type::tuple<>&);
|
|
||||||
|
|
||||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
|
||||||
template <typename Stream, typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
|
||||||
const msgpack::packer<Stream>& operator<< (
|
|
||||||
msgpack::packer<Stream>& o,
|
|
||||||
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v);
|
|
||||||
<%}%>
|
|
||||||
|
|
||||||
void operator<< (
|
|
||||||
msgpack::object::with_zone& o,
|
|
||||||
const type::tuple<>&);
|
|
||||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
|
||||||
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
|
||||||
void operator<< (
|
|
||||||
msgpack::object::with_zone& o,
|
|
||||||
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v);
|
|
||||||
<%}%>
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
|
|
||||||
//std::ostream& operator<< (std::ostream& o, const msgpack::type::tuple<>& v);
|
|
||||||
//<%0.upto(GENERATION_LIMIT) {|i|%>
|
|
||||||
//template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
|
||||||
//std::ostream& operator<< (std::ostream& o,
|
|
||||||
// const msgpack::type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v);
|
|
||||||
//<%}%>
|
|
||||||
|
|
||||||
#endif // MSGPACK_CPP03_MSGPACK_TUPLE_FWD_HPP
|
|
@@ -35,7 +35,9 @@
|
|||||||
<% GENERATION_LIMIT = 15 %>
|
<% GENERATION_LIMIT = 15 %>
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
class zone {
|
class zone {
|
||||||
struct finalizer {
|
struct finalizer {
|
||||||
@@ -179,10 +181,12 @@ public:
|
|||||||
{
|
{
|
||||||
::operator delete(p, place);
|
::operator delete(p, place);
|
||||||
}
|
}
|
||||||
|
/// @cond
|
||||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||||
template <typename T<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
template <typename T<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||||
T* allocate(<%=(1..i).map{|j|"A#{j} a#{j}"}.join(', ')%>);
|
T* allocate(<%=(1..i).map{|j|"A#{j} a#{j}"}.join(', ')%>);
|
||||||
<%}%>
|
<%}%>
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void undo_allocate(size_t size);
|
void undo_allocate(size_t size);
|
||||||
@@ -304,6 +308,7 @@ inline void zone::undo_allocate(size_t size)
|
|||||||
m_chunk_list.m_free += size;
|
m_chunk_list.m_free += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @cond
|
||||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||||
template <typename T<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
template <typename T<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||||
T* zone::allocate(<%=(1..i).map{|j|"A#{j} a#{j}"}.join(', ')%>)
|
T* zone::allocate(<%=(1..i).map{|j|"A#{j} a#{j}"}.join(', ')%>)
|
||||||
@@ -324,8 +329,11 @@ T* zone::allocate(<%=(1..i).map{|j|"A#{j} a#{j}"}.join(', ')%>)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
<%}%>
|
<%}%>
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -8,8 +8,6 @@ typedef struct receiver {
|
|||||||
size_t rest;
|
size_t rest;
|
||||||
} receiver;
|
} receiver;
|
||||||
|
|
||||||
receiver r;
|
|
||||||
|
|
||||||
void receiver_init(receiver *r) {
|
void receiver_init(receiver *r) {
|
||||||
msgpack_packer pk;
|
msgpack_packer pk;
|
||||||
|
|
||||||
@@ -52,6 +50,8 @@ void unpack(receiver* r) {
|
|||||||
msgpack_unpack_return ret;
|
msgpack_unpack_return ret;
|
||||||
char* buf;
|
char* buf;
|
||||||
size_t recv_len;
|
size_t recv_len;
|
||||||
|
int recv_count = 0;
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
msgpack_unpacked_init(&result);
|
msgpack_unpacked_init(&result);
|
||||||
if (msgpack_unpacker_buffer_capacity(unp) < EACH_RECV_SIZE) {
|
if (msgpack_unpacker_buffer_capacity(unp) < EACH_RECV_SIZE) {
|
||||||
@@ -64,16 +64,14 @@ void unpack(receiver* r) {
|
|||||||
msgpack_unpacker_buffer_consumed(unp, recv_len);
|
msgpack_unpacker_buffer_consumed(unp, recv_len);
|
||||||
|
|
||||||
|
|
||||||
int recv_count = 0;
|
while (recv_len > 0) {
|
||||||
while (recv_len > 0) {
|
printf("receive count: %d %zd bytes received.\n", recv_count++, recv_len);
|
||||||
int i = 0;
|
|
||||||
printf("receive count: %d %zd bytes received.:\n", recv_count++, recv_len);
|
|
||||||
ret = msgpack_unpacker_next(unp, &result);
|
ret = msgpack_unpacker_next(unp, &result);
|
||||||
while (ret == MSGPACK_UNPACK_SUCCESS) {
|
while (ret == MSGPACK_UNPACK_SUCCESS) {
|
||||||
msgpack_object obj = result.data;
|
msgpack_object obj = result.data;
|
||||||
|
|
||||||
/* Use obj. */
|
/* Use obj. */
|
||||||
printf("Object no %d:\n", i++);
|
printf("Object no %d:\n", ++i);
|
||||||
msgpack_object_print(stdout, obj);
|
msgpack_object_print(stdout, obj);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
/* If you want to allocate something on the zone, you can use zone. */
|
/* If you want to allocate something on the zone, you can use zone. */
|
||||||
@@ -110,10 +108,16 @@ int main(void) {
|
|||||||
/* Output */
|
/* Output */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
receive count: 0 4 bytes received.
|
||||||
|
receive count: 1 4 bytes received.
|
||||||
|
receive count: 2 4 bytes received.
|
||||||
Object no 1:
|
Object no 1:
|
||||||
[1, true, "example"]
|
[1, true, "example"]
|
||||||
|
receive count: 3 4 bytes received.
|
||||||
|
receive count: 4 4 bytes received.
|
||||||
Object no 2:
|
Object no 2:
|
||||||
"second"
|
"second"
|
||||||
|
receive count: 5 1 bytes received.
|
||||||
Object no 3:
|
Object no 3:
|
||||||
[42, false]
|
[42, false]
|
||||||
*/
|
*/
|
||||||
|
@@ -3,12 +3,15 @@
|
|||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
/* msgpack::sbuffer is a simple buffer implementation. */
|
|
||||||
msgpack_sbuffer sbuf;
|
msgpack_sbuffer sbuf;
|
||||||
|
msgpack_packer pk;
|
||||||
|
msgpack_zone mempool;
|
||||||
|
msgpack_object deserialized;
|
||||||
|
|
||||||
|
/* msgpack::sbuffer is a simple buffer implementation. */
|
||||||
msgpack_sbuffer_init(&sbuf);
|
msgpack_sbuffer_init(&sbuf);
|
||||||
|
|
||||||
/* serialize values into the buffer using msgpack_sbuffer_write callback function. */
|
/* serialize values into the buffer using msgpack_sbuffer_write callback function. */
|
||||||
msgpack_packer pk;
|
|
||||||
msgpack_packer_init(&pk, &sbuf, msgpack_sbuffer_write);
|
msgpack_packer_init(&pk, &sbuf, msgpack_sbuffer_write);
|
||||||
|
|
||||||
msgpack_pack_array(&pk, 3);
|
msgpack_pack_array(&pk, 3);
|
||||||
@@ -19,10 +22,8 @@ int main(void)
|
|||||||
|
|
||||||
/* deserialize the buffer into msgpack_object instance. */
|
/* deserialize the buffer into msgpack_object instance. */
|
||||||
/* deserialized object is valid during the msgpack_zone instance alive. */
|
/* deserialized object is valid during the msgpack_zone instance alive. */
|
||||||
msgpack_zone mempool;
|
|
||||||
msgpack_zone_init(&mempool, 2048);
|
msgpack_zone_init(&mempool, 2048);
|
||||||
|
|
||||||
msgpack_object deserialized;
|
|
||||||
msgpack_unpack(sbuf.data, sbuf.size, NULL, &mempool, &deserialized);
|
msgpack_unpack(sbuf.data, sbuf.size, NULL, &mempool, &deserialized);
|
||||||
|
|
||||||
/* print the deserialized object. */
|
/* print the deserialized object. */
|
||||||
|
@@ -1,13 +1,16 @@
|
|||||||
#include <msgpack.h>
|
#include <msgpack.h>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
void test()
|
void test()
|
||||||
{
|
{
|
||||||
size_t size = 10000000;
|
size_t size = 10000000;
|
||||||
msgpack_sbuffer buf;
|
msgpack_sbuffer buf;
|
||||||
|
msgpack_packer * pk;
|
||||||
|
size_t upk_pos = 0;
|
||||||
|
msgpack_unpacked msg;
|
||||||
|
|
||||||
msgpack_sbuffer_init(&buf);
|
msgpack_sbuffer_init(&buf);
|
||||||
|
|
||||||
msgpack_packer * pk = msgpack_packer_new(&buf, msgpack_sbuffer_write);
|
pk = msgpack_packer_new(&buf, msgpack_sbuffer_write);
|
||||||
|
|
||||||
msgpack_pack_array(pk, size);
|
msgpack_pack_array(pk, size);
|
||||||
{
|
{
|
||||||
@@ -17,9 +20,6 @@ void test()
|
|||||||
}
|
}
|
||||||
msgpack_packer_free(pk);
|
msgpack_packer_free(pk);
|
||||||
|
|
||||||
|
|
||||||
size_t upk_pos = 0;
|
|
||||||
msgpack_unpacked msg;
|
|
||||||
msgpack_unpacked_init(&msg);
|
msgpack_unpacked_init(&msg);
|
||||||
|
|
||||||
while (msgpack_unpack_next(&msg, buf.data, buf.size, &upk_pos)) {
|
while (msgpack_unpack_next(&msg, buf.data, buf.size, &upk_pos)) {
|
||||||
|
@@ -1,14 +1,17 @@
|
|||||||
#include <msgpack.h>
|
#include <msgpack.h>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
void test()
|
void test()
|
||||||
{
|
{
|
||||||
uint64_t test_u64 = 0xFFF0000000000001LL;
|
uint64_t test_u64 = 0xFFF0000000000001LL;
|
||||||
size_t size = 10000000;
|
size_t size = 10000000;
|
||||||
msgpack_sbuffer buf;
|
msgpack_sbuffer buf;
|
||||||
|
msgpack_packer * pk;
|
||||||
|
size_t upk_pos = 0;
|
||||||
|
msgpack_unpacked msg;
|
||||||
|
|
||||||
msgpack_sbuffer_init(&buf);
|
msgpack_sbuffer_init(&buf);
|
||||||
|
|
||||||
msgpack_packer * pk = msgpack_packer_new(&buf, msgpack_sbuffer_write);
|
pk = msgpack_packer_new(&buf, msgpack_sbuffer_write);
|
||||||
|
|
||||||
msgpack_pack_array(pk, size);
|
msgpack_pack_array(pk, size);
|
||||||
{
|
{
|
||||||
@@ -18,9 +21,6 @@ void test()
|
|||||||
}
|
}
|
||||||
msgpack_packer_free(pk);
|
msgpack_packer_free(pk);
|
||||||
|
|
||||||
|
|
||||||
size_t upk_pos = 0;
|
|
||||||
msgpack_unpacked msg;
|
|
||||||
msgpack_unpacked_init(&msg);
|
msgpack_unpacked_init(&msg);
|
||||||
|
|
||||||
while (msgpack_unpack_next(&msg, buf.data, buf.size, &upk_pos)) {
|
while (msgpack_unpack_next(&msg, buf.data, buf.size, &upk_pos)) {
|
||||||
|
@@ -33,7 +33,7 @@ void unpack(char const* buf, size_t len) {
|
|||||||
msgpack_object obj = result.data;
|
msgpack_object obj = result.data;
|
||||||
|
|
||||||
/* Use obj. */
|
/* Use obj. */
|
||||||
printf("Object no %d:\n", i++);
|
printf("Object no %d:\n", ++i);
|
||||||
msgpack_object_print(stdout, obj);
|
msgpack_object_print(stdout, obj);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
/* If you want to allocate something on the zone, you can use zone. */
|
/* If you want to allocate something on the zone, you can use zone. */
|
||||||
@@ -72,4 +72,5 @@ Object no 2:
|
|||||||
"second"
|
"second"
|
||||||
Object no 3:
|
Object no 3:
|
||||||
[42, false]
|
[42, false]
|
||||||
|
All msgpack_object in the buffer is consumed.
|
||||||
*/
|
*/
|
||||||
|
@@ -21,8 +21,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
// msgpack.hpp is also ok
|
#include <msgpack.hpp>
|
||||||
#include <msgpack_fwd.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
class my_class {
|
class my_class {
|
||||||
@@ -57,8 +56,6 @@ void print(std::string const& buf) {
|
|||||||
std::cout << std::dec << std::endl;
|
std::cout << std::dec << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <msgpack.hpp>
|
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
{ // pack, unpack
|
{ // pack, unpack
|
||||||
my_class my("John Smith", 42);
|
my_class my("John Smith", 42);
|
||||||
|
@@ -21,27 +21,6 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
// msgpack.hpp should be included at after user declarations
|
|
||||||
#include <msgpack_fwd.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
// declarations
|
|
||||||
class my_class;
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
|
||||||
|
|
||||||
object const& operator>> (msgpack::object const& o, my_class& v);
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
packer<Stream>& operator<< (msgpack::packer<Stream>& o, my_class const& v);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object::with_zone& o, my_class const& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#include <msgpack.hpp>
|
#include <msgpack.hpp>
|
||||||
|
|
||||||
class my_class {
|
class my_class {
|
||||||
@@ -63,40 +42,48 @@ private:
|
|||||||
int age_;
|
int age_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// User defined class template specialization
|
||||||
// definitions
|
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
inline object const& operator>> (msgpack::object const& o, my_class& v) {
|
template<>
|
||||||
if (o.type != msgpack::type::ARRAY) throw msgpack::type_error();
|
struct convert<my_class> {
|
||||||
if (o.via.array.size != 2) throw msgpack::type_error();
|
msgpack::object const& operator()(msgpack::object const& o, my_class& v) const {
|
||||||
v = my_class(
|
if (o.type != msgpack::type::ARRAY) throw msgpack::type_error();
|
||||||
o.via.array.ptr[0].as<std::string>(),
|
if (o.via.array.size != 2) throw msgpack::type_error();
|
||||||
o.via.array.ptr[1].as<int>());
|
v = my_class(
|
||||||
return o;
|
o.via.array.ptr[0].as<std::string>(),
|
||||||
}
|
o.via.array.ptr[1].as<int>());
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<>
|
||||||
|
struct pack<my_class> {
|
||||||
|
template <typename Stream>
|
||||||
|
packer<Stream>& operator()(msgpack::packer<Stream>& o, my_class const& v) const {
|
||||||
|
// packing member variables as an array.
|
||||||
|
o.pack_array(2);
|
||||||
|
o.pack(v.get_name());
|
||||||
|
o.pack(v.get_age());
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline packer<Stream>& operator<< (msgpack::packer<Stream>& o, my_class const& v) {
|
struct object_with_zone<my_class> {
|
||||||
// packing member variables as an array.
|
void operator()(msgpack::object::with_zone& o, my_class const& v) const {
|
||||||
o.pack_array(2);
|
o.type = type::ARRAY;
|
||||||
o.pack(v.get_name());
|
o.via.array.size = 2;
|
||||||
o.pack(v.get_age());
|
o.via.array.ptr = static_cast<msgpack::object*>(
|
||||||
return o;
|
o.zone.allocate_align(sizeof(msgpack::object) * o.via.array.size));
|
||||||
}
|
o.via.array.ptr[0] = msgpack::object(v.get_name(), o.zone);
|
||||||
|
o.via.array.ptr[1] = msgpack::object(v.get_age(), o.zone);
|
||||||
inline void operator<< (msgpack::object::with_zone& o, my_class const& v) {
|
}
|
||||||
o.type = type::ARRAY;
|
};
|
||||||
o.via.array.size = 2;
|
|
||||||
o.via.array.ptr = static_cast<object*>(o.zone.allocate_align(sizeof(object) * o.via.array.size));
|
|
||||||
o.via.array.ptr[0] = msgpack::object(v.get_name(), o.zone);
|
|
||||||
o.via.array.ptr[1] = msgpack::object(v.get_age(), o.zone);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
} // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -15,11 +15,12 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <msgpack_fwd.hpp>
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
|
#include <msgpack.hpp>
|
||||||
|
|
||||||
enum my_enum {
|
enum my_enum {
|
||||||
elem1,
|
elem1,
|
||||||
elem2,
|
elem2,
|
||||||
@@ -28,8 +29,6 @@ enum my_enum {
|
|||||||
|
|
||||||
MSGPACK_ADD_ENUM(my_enum);
|
MSGPACK_ADD_ENUM(my_enum);
|
||||||
|
|
||||||
#include <msgpack.hpp>
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
{ // pack, unpack
|
{ // pack, unpack
|
||||||
|
@@ -20,6 +20,8 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
// This example uses obsolete APIs
|
||||||
|
// See protocol_new.cpp
|
||||||
namespace myprotocol {
|
namespace myprotocol {
|
||||||
using namespace msgpack::type;
|
using namespace msgpack::type;
|
||||||
using msgpack::define;
|
using msgpack::define;
|
||||||
|
@@ -23,3 +23,4 @@
|
|||||||
#include "msgpack/sbuffer.hpp"
|
#include "msgpack/sbuffer.hpp"
|
||||||
#include "msgpack/vrefbuffer.hpp"
|
#include "msgpack/vrefbuffer.hpp"
|
||||||
#include "msgpack/version.hpp"
|
#include "msgpack/version.hpp"
|
||||||
|
#include "msgpack/type.hpp"
|
||||||
|
92
include/msgpack/adaptor/adaptor_base.hpp
Normal file
92
include/msgpack/adaptor/adaptor_base.hpp
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
//
|
||||||
|
// MessagePack for C++ static resolution routine
|
||||||
|
//
|
||||||
|
// Copyright (C) 2015 KONDO Takatoshi
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
//
|
||||||
|
#ifndef MSGPACK_ADAPTOR_BASE_HPP
|
||||||
|
#define MSGPACK_ADAPTOR_BASE_HPP
|
||||||
|
|
||||||
|
#include "msgpack/object_fwd.hpp"
|
||||||
|
|
||||||
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
template <typename Stream>
|
||||||
|
class packer;
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
|
// Adaptor functors
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct convert {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, T& v) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct pack {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, T const& v) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct object {
|
||||||
|
void operator()(msgpack::object& o, T const& v) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct object_with_zone {
|
||||||
|
void operator()(msgpack::object::with_zone& o, T const& v) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
// operators
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline
|
||||||
|
msgpack::object const& operator>> (msgpack::object const& o, T& v) {
|
||||||
|
return adaptor::convert<T>()(o, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Stream, typename T>
|
||||||
|
inline
|
||||||
|
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, T const& v) {
|
||||||
|
return adaptor::pack<T>()(o, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline
|
||||||
|
void operator<< (msgpack::object& o, T const& v) {
|
||||||
|
adaptor::object<T>()(o, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline
|
||||||
|
void operator<< (msgpack::object::with_zone& o, T const& v) {
|
||||||
|
adaptor::object_with_zone<T>()(o, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
} // namespace msgpack
|
||||||
|
|
||||||
|
|
||||||
|
#endif // MSGPACK_ADAPTOR_BASE_HPP
|
@@ -19,39 +19,55 @@
|
|||||||
#define MSGPACK_TYPE_BOOL_HPP
|
#define MSGPACK_TYPE_BOOL_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, bool& v)
|
namespace adaptor {
|
||||||
{
|
|
||||||
if(o.type != msgpack::type::BOOLEAN) { throw msgpack::type_error(); }
|
|
||||||
v = o.via.boolean;
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const bool& v)
|
struct convert<bool> {
|
||||||
{
|
msgpack::object const& operator()(msgpack::object const& o, bool& v) const {
|
||||||
if(v) { o.pack_true(); }
|
if(o.type != msgpack::type::BOOLEAN) { throw msgpack::type_error(); }
|
||||||
else { o.pack_false(); }
|
v = o.via.boolean;
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, bool v)
|
template <>
|
||||||
{
|
struct pack<bool> {
|
||||||
o.type = msgpack::type::BOOLEAN;
|
template <typename Stream>
|
||||||
o.via.boolean = v;
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const bool& v) const {
|
||||||
}
|
if(v) { o.pack_true(); }
|
||||||
|
else { o.pack_false(); }
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, bool v)
|
template <>
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
struct object<bool> {
|
||||||
|
void operator()(msgpack::object& o, bool v) const {
|
||||||
|
o.type = msgpack::type::BOOLEAN;
|
||||||
|
o.via.boolean = v;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct object_with_zone<bool> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, bool v) const {
|
||||||
|
static_cast<msgpack::object&>(o) << v;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -1,39 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_BOOL_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_BOOL_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, bool& v);
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const bool& v);
|
|
||||||
void operator<< (msgpack::object& o, bool v);
|
|
||||||
void operator<< (msgpack::object::with_zone& o, bool v);
|
|
||||||
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_BOOL_FWD_HPP
|
|
@@ -26,52 +26,139 @@
|
|||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
template <typename Stream>
|
namespace adaptor {
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const char* v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(std::strlen(v));
|
|
||||||
o.pack_str(size);
|
|
||||||
o.pack_str_body(v, size);
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const char* v)
|
template <>
|
||||||
{
|
struct pack<const char*> {
|
||||||
uint32_t size = checked_get_container_size(std::strlen(v));
|
template <typename Stream>
|
||||||
o.type = msgpack::type::STR;
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const char* v) const {
|
||||||
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
uint32_t size = checked_get_container_size(std::strlen(v));
|
||||||
o.via.str.ptr = ptr;
|
o.pack_str(size);
|
||||||
o.via.str.size = size;
|
o.pack_str_body(v, size);
|
||||||
std::memcpy(ptr, v, size);
|
return o;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, const char* v)
|
template <>
|
||||||
{
|
struct object_with_zone<const char*> {
|
||||||
uint32_t size = checked_get_container_size(std::strlen(v));
|
void operator()(msgpack::object::with_zone& o, const char* v) const {
|
||||||
o.type = msgpack::type::STR;
|
uint32_t size = checked_get_container_size(std::strlen(v));
|
||||||
o.via.str.ptr = v;
|
o.type = msgpack::type::STR;
|
||||||
o.via.str.size = size;
|
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
||||||
}
|
o.via.str.ptr = ptr;
|
||||||
|
o.via.str.size = size;
|
||||||
|
std::memcpy(ptr, v, size);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline packer<Stream>& operator<< (packer<Stream>& o, char* v)
|
struct object<const char*> {
|
||||||
{
|
void operator()(msgpack::object& o, const char* v) const {
|
||||||
return msgpack::operator<<(o, static_cast<const char*>(v));
|
uint32_t size = checked_get_container_size(std::strlen(v));
|
||||||
}
|
o.type = msgpack::type::STR;
|
||||||
|
o.via.str.ptr = v;
|
||||||
|
o.via.str.size = size;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (object::with_zone& o, char* v)
|
|
||||||
{
|
|
||||||
msgpack::operator<<(o, static_cast<const char*>(v));
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void operator<< (object& o, char* v)
|
template <>
|
||||||
{
|
struct pack<char*> {
|
||||||
msgpack::operator<<(o, static_cast<const char*>(v));
|
template <typename Stream>
|
||||||
}
|
packer<Stream>& operator()(packer<Stream>& o, char* v) const {
|
||||||
|
return o << static_cast<const char*>(v);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct object_with_zone<char*> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, char* v) const {
|
||||||
|
o << static_cast<const char*>(v);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct object<char*> {
|
||||||
|
void operator()(msgpack::object& o, char* v) const {
|
||||||
|
o << static_cast<const char*>(v);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <std::size_t N>
|
||||||
|
struct pack<char[N]> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const char* v) const {
|
||||||
|
uint32_t size = checked_get_container_size(std::strlen(v));
|
||||||
|
o.pack_str(size);
|
||||||
|
o.pack_str_body(v, size);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <std::size_t N>
|
||||||
|
struct object_with_zone<char[N]> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const char* v) const {
|
||||||
|
uint32_t size = checked_get_container_size(std::strlen(v));
|
||||||
|
o.type = msgpack::type::STR;
|
||||||
|
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
||||||
|
o.via.str.ptr = ptr;
|
||||||
|
o.via.str.size = size;
|
||||||
|
std::memcpy(ptr, v, size);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <std::size_t N>
|
||||||
|
struct object<char[N]> {
|
||||||
|
void operator()(msgpack::object& o, const char* v) const {
|
||||||
|
uint32_t size = checked_get_container_size(std::strlen(v));
|
||||||
|
o.type = msgpack::type::STR;
|
||||||
|
o.via.str.ptr = v;
|
||||||
|
o.via.str.size = size;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <std::size_t N>
|
||||||
|
struct pack<const char[N]> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const char* v) const {
|
||||||
|
uint32_t size = checked_get_container_size(std::strlen(v));
|
||||||
|
o.pack_str(size);
|
||||||
|
o.pack_str_body(v, size);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <std::size_t N>
|
||||||
|
struct object_with_zone<const char[N]> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const char* v) const {
|
||||||
|
uint32_t size = checked_get_container_size(std::strlen(v));
|
||||||
|
o.type = msgpack::type::STR;
|
||||||
|
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
||||||
|
o.via.str.ptr = ptr;
|
||||||
|
o.via.str.size = size;
|
||||||
|
std::memcpy(ptr, v, size);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <std::size_t N>
|
||||||
|
struct object<const char[N]> {
|
||||||
|
void operator()(msgpack::object& o, const char* v) const {
|
||||||
|
uint32_t size = checked_get_container_size(std::strlen(v));
|
||||||
|
o.type = msgpack::type::STR;
|
||||||
|
o.via.str.ptr = v;
|
||||||
|
o.via.str.size = size;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -1,43 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2014 KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_CHAR_PTR_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_CHAR_PTR_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
#include <cstring>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const char* v);
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const char* v);
|
|
||||||
void operator<< (msgpack::object& o, const char* v);
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
packer<Stream>& operator<< (packer<Stream>& o, char* v);
|
|
||||||
void operator<< (object::with_zone& o, char* v);
|
|
||||||
void operator<< (object& o, char* v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_CHAR_PTR_FWD_HPP
|
|
@@ -23,7 +23,9 @@
|
|||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
struct container_size_overflow : public std::runtime_error {
|
struct container_size_overflow : public std::runtime_error {
|
||||||
explicit container_size_overflow(const std::string& msg)
|
explicit container_size_overflow(const std::string& msg)
|
||||||
@@ -54,7 +56,9 @@ inline uint32_t checked_get_container_size(T size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -20,56 +20,71 @@
|
|||||||
#define MSGPACK_CPP11_ARRAY_HPP
|
#define MSGPACK_CPP11_ARRAY_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/adaptor/check_container_size.hpp"
|
#include "msgpack/adaptor/check_container_size.hpp"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
template <typename T, std::size_t N>
|
template <typename T, std::size_t N>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::array<T, N>& v) {
|
struct convert<std::array<T, N>> {
|
||||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
msgpack::object const& operator()(msgpack::object const& o, std::array<T, N>& v) const {
|
||||||
if(o.via.array.size != N) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||||
if(o.via.array.size > 0) {
|
if(o.via.array.size != N) { throw msgpack::type_error(); }
|
||||||
msgpack::object* p = o.via.array.ptr;
|
if(o.via.array.size > 0) {
|
||||||
msgpack::object* const pend = o.via.array.ptr + o.via.array.size;
|
msgpack::object* p = o.via.array.ptr;
|
||||||
T* it = &v[0];
|
msgpack::object* const pend = o.via.array.ptr + o.via.array.size;
|
||||||
do {
|
T* it = &v[0];
|
||||||
p->convert(*it);
|
do {
|
||||||
++p;
|
p->convert(*it);
|
||||||
++it;
|
++p;
|
||||||
} while(p < pend);
|
++it;
|
||||||
|
} while(p < pend);
|
||||||
|
}
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
return o;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, typename T, std::size_t N>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::array<T, N>& v) {
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
o.pack_array(size);
|
|
||||||
for(auto const& e : v) o.pack(e);
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T, std::size_t N>
|
template <typename T, std::size_t N>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const std::array<T, N>& v) {
|
struct pack<std::array<T, N>> {
|
||||||
o.type = msgpack::type::ARRAY;
|
template <typename Stream>
|
||||||
if(v.empty()) {
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::array<T, N>& v) const {
|
||||||
o.via.array.ptr = nullptr;
|
|
||||||
o.via.array.size = 0;
|
|
||||||
} else {
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
o.pack_array(size);
|
||||||
o.via.array.size = size;
|
for(auto const& e : v) o.pack(e);
|
||||||
o.via.array.ptr = p;
|
return o;
|
||||||
for (auto const& e : v) *p++ = msgpack::object(e, o.zone);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
template <typename T, std::size_t N>
|
||||||
|
struct object_with_zone<std::array<T, N>> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const std::array<T, N>& v) const {
|
||||||
|
o.type = msgpack::type::ARRAY;
|
||||||
|
if(v.empty()) {
|
||||||
|
o.via.array.ptr = nullptr;
|
||||||
|
o.via.array.size = 0;
|
||||||
|
} else {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||||
|
o.via.array.size = size;
|
||||||
|
o.via.array.ptr = p;
|
||||||
|
for (auto const& e : v) *p++ = msgpack::object(e, o.zone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -19,66 +19,79 @@
|
|||||||
#define MSGPACK_TYPE_ARRAY_CHAR_HPP
|
#define MSGPACK_TYPE_ARRAY_CHAR_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/adaptor/check_container_size.hpp"
|
#include "msgpack/adaptor/check_container_size.hpp"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
template <std::size_t N>
|
template <std::size_t N>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::array<char, N>& v)
|
struct convert<std::array<char, N>> {
|
||||||
{
|
msgpack::object const& operator()(msgpack::object const& o, std::array<char, N>& v) const {
|
||||||
switch (o.type) {
|
switch (o.type) {
|
||||||
case msgpack::type::BIN:
|
case msgpack::type::BIN:
|
||||||
if(o.via.bin.size != N) { throw msgpack::type_error(); }
|
if(o.via.bin.size != N) { throw msgpack::type_error(); }
|
||||||
std::memcpy(v.data(), o.via.bin.ptr, o.via.bin.size);
|
std::memcpy(v.data(), o.via.bin.ptr, o.via.bin.size);
|
||||||
break;
|
break;
|
||||||
case msgpack::type::STR:
|
case msgpack::type::STR:
|
||||||
if(o.via.str.size != N) { throw msgpack::type_error(); }
|
if(o.via.str.size != N) { throw msgpack::type_error(); }
|
||||||
std::memcpy(v.data(), o.via.str.ptr, N);
|
std::memcpy(v.data(), o.via.str.ptr, N);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw msgpack::type_error();
|
throw msgpack::type_error();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
return o;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, std::size_t N>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::array<char, N>& v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
o.pack_bin(size);
|
|
||||||
o.pack_bin_body(v.data(), size);
|
|
||||||
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <std::size_t N>
|
template <std::size_t N>
|
||||||
inline void operator<< (msgpack::object& o, const std::array<char, N>& v)
|
struct pack<std::array<char, N>> {
|
||||||
{
|
template <typename Stream>
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::array<char, N>& v) const {
|
||||||
o.type = msgpack::type::BIN;
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
o.via.bin.ptr = v.data();
|
o.pack_bin(size);
|
||||||
o.via.bin.size = size;
|
o.pack_bin_body(v.data(), size);
|
||||||
}
|
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <std::size_t N>
|
template <std::size_t N>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const std::array<char, N>& v)
|
struct object<std::array<char, N>> {
|
||||||
{
|
void operator()(msgpack::object& o, const std::array<char, N>& v) const {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
o.type = msgpack::type::BIN;
|
o.type = msgpack::type::BIN;
|
||||||
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
o.via.bin.ptr = v.data();
|
||||||
o.via.bin.ptr = ptr;
|
o.via.bin.size = size;
|
||||||
o.via.bin.size = size;
|
}
|
||||||
std::memcpy(ptr, v.data(), size);
|
};
|
||||||
}
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
template <std::size_t N>
|
||||||
|
struct object_with_zone<std::array<char, N>> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const std::array<char, N>& v) const {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
o.type = msgpack::type::BIN;
|
||||||
|
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
||||||
|
o.via.bin.ptr = ptr;
|
||||||
|
o.via.bin.size = size;
|
||||||
|
std::memcpy(ptr, v.data(), size);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
} // namespace msgpack
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_ARRAY_CHAR_HPP
|
#endif // MSGPACK_TYPE_ARRAY_CHAR_HPP
|
||||||
|
@@ -1,45 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2014 KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_ARRAY_CHAR_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_ARRAY_CHAR_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
#include <array>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
template <std::size_t N>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, std::array<char, N>& v);
|
|
||||||
|
|
||||||
template <typename Stream, std::size_t N>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::array<char, N>& v);
|
|
||||||
|
|
||||||
template <std::size_t N>
|
|
||||||
void operator<< (msgpack::object& o, const std::array<char, N>& v);
|
|
||||||
|
|
||||||
template <std::size_t N>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const std::array<char, N>& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_ARRAY_CHAR_FWD_HPP
|
|
@@ -1,44 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2014 KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef MSGPACK_CPP11_ARRAY_FWD_HPP
|
|
||||||
#define MSGPACK_CPP11_ARRAY_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
|
|
||||||
#include <array>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
template <typename T, std::size_t N>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, std::array<T, N>& v);
|
|
||||||
|
|
||||||
template <typename Stream, typename T, std::size_t N>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::array<T, N>& v);
|
|
||||||
|
|
||||||
template <typename T, std::size_t N>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const std::array<T, N>& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_CPP11_ARRAY_FWD_HPP
|
|
@@ -20,55 +20,67 @@
|
|||||||
#define MSGPACK_CPP11_FORWARD_LIST_HPP
|
#define MSGPACK_CPP11_FORWARD_LIST_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/adaptor/check_container_size.hpp"
|
#include "msgpack/adaptor/check_container_size.hpp"
|
||||||
|
|
||||||
#include <forward_list>
|
#include <forward_list>
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::forward_list<T>& v)
|
struct convert<std::forward_list<T>> {
|
||||||
{
|
msgpack::object const& operator()(msgpack::object const& o, std::forward_list<T>& v) const {
|
||||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||||
v.resize(o.via.array.size);
|
v.resize(o.via.array.size);
|
||||||
msgpack::object* p = o.via.array.ptr;
|
msgpack::object* p = o.via.array.ptr;
|
||||||
for (auto &e : v) {
|
for (auto &e : v) {
|
||||||
p->convert(e);
|
p->convert(e);
|
||||||
++p;
|
++p;
|
||||||
|
}
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
return o;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::forward_list<T>& v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(std::distance(v.begin(), v.end()));
|
|
||||||
o.pack_array(size);
|
|
||||||
for(auto const& e : v) o.pack(e);
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const std::forward_list<T>& v)
|
struct pack<std::forward_list<T>> {
|
||||||
{
|
template <typename Stream>
|
||||||
o.type = msgpack::type::ARRAY;
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::forward_list<T>& v) const {
|
||||||
if(v.empty()) {
|
|
||||||
o.via.array.ptr = nullptr;
|
|
||||||
o.via.array.size = 0;
|
|
||||||
} else {
|
|
||||||
uint32_t size = checked_get_container_size(std::distance(v.begin(), v.end()));
|
uint32_t size = checked_get_container_size(std::distance(v.begin(), v.end()));
|
||||||
o.via.array.size = size;
|
o.pack_array(size);
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(
|
for(auto const& e : v) o.pack(e);
|
||||||
o.zone.allocate_align(sizeof(msgpack::object)*size));
|
return o;
|
||||||
o.via.array.ptr = p;
|
|
||||||
for(auto const& e : v) *p++ = msgpack::object(e, o.zone);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
template <typename T>
|
||||||
|
struct object_with_zone<std::forward_list<T>> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const std::forward_list<T>& v) const {
|
||||||
|
o.type = msgpack::type::ARRAY;
|
||||||
|
if(v.empty()) {
|
||||||
|
o.via.array.ptr = nullptr;
|
||||||
|
o.via.array.size = 0;
|
||||||
|
} else {
|
||||||
|
uint32_t size = checked_get_container_size(std::distance(v.begin(), v.end()));
|
||||||
|
o.via.array.size = size;
|
||||||
|
msgpack::object* p = static_cast<msgpack::object*>(
|
||||||
|
o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||||
|
o.via.array.ptr = p;
|
||||||
|
for(auto const& e : v) *p++ = msgpack::object(e, o.zone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -1,44 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2014 KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
|
|
||||||
#ifndef MSGPACK_CPP11_FORWARD_LIST_FWD_HPP
|
|
||||||
#define MSGPACK_CPP11_FORWARD_LIST_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
|
|
||||||
#include <forward_list>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, std::forward_list<T>& v);
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::forward_list<T>& v);
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const std::forward_list<T>& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_CPP11_FORWARD_LIST_FWD_HPP
|
|
@@ -19,14 +19,16 @@
|
|||||||
#define MSGPACK_CPP11_TUPLE_HPP
|
#define MSGPACK_CPP11_TUPLE_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/adaptor/check_container_size.hpp"
|
#include "msgpack/adaptor/check_container_size.hpp"
|
||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
// --- Pack from tuple to packer stream ---
|
// --- Pack from tuple to packer stream ---
|
||||||
template <typename Stream, typename Tuple, std::size_t N>
|
template <typename Stream, typename Tuple, std::size_t N>
|
||||||
@@ -56,16 +58,22 @@ struct StdTuplePacker<Stream, Tuple, 0> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
template <typename Stream, typename... Args>
|
template <typename... Args>
|
||||||
inline const msgpack::packer<Stream>& operator<< (
|
struct pack<std::tuple<Args...>> {
|
||||||
msgpack::packer<Stream>& o,
|
template <typename Stream>
|
||||||
const std::tuple<Args...>& v) {
|
msgpack::packer<Stream>& operator()(
|
||||||
uint32_t size = checked_get_container_size(sizeof...(Args));
|
msgpack::packer<Stream>& o,
|
||||||
o.pack_array(size);
|
const std::tuple<Args...>& v) const {
|
||||||
StdTuplePacker<Stream, decltype(v), sizeof...(Args)>::pack(o, v);
|
uint32_t size = checked_get_container_size(sizeof...(Args));
|
||||||
return o;
|
o.pack_array(size);
|
||||||
}
|
StdTuplePacker<Stream, decltype(v), sizeof...(Args)>::pack(o, v);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
// --- Convert from tuple to object ---
|
// --- Convert from tuple to object ---
|
||||||
|
|
||||||
@@ -96,15 +104,21 @@ struct StdTupleConverter<Tuple, 0> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
inline msgpack::object const& operator>> (
|
struct convert<std::tuple<Args...>> {
|
||||||
msgpack::object const& o,
|
msgpack::object const& operator()(
|
||||||
std::tuple<Args...>& v) {
|
msgpack::object const& o,
|
||||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
std::tuple<Args...>& v) const {
|
||||||
if(o.via.array.size < sizeof...(Args)) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||||
StdTupleConverter<decltype(v), sizeof...(Args)>::convert(o, v);
|
if(o.via.array.size < sizeof...(Args)) { throw msgpack::type_error(); }
|
||||||
return o;
|
StdTupleConverter<decltype(v), sizeof...(Args)>::convert(o, v);
|
||||||
}
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
// --- Convert from tuple to object with zone ---
|
// --- Convert from tuple to object with zone ---
|
||||||
template <typename Tuple, std::size_t N>
|
template <typename Tuple, std::size_t N>
|
||||||
@@ -134,18 +148,26 @@ struct StdTupleToObjectWithZone<Tuple, 0> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... Args>
|
namespace adaptor {
|
||||||
inline void operator<< (
|
|
||||||
msgpack::object::with_zone& o,
|
|
||||||
std::tuple<Args...> const& v) {
|
|
||||||
uint32_t size = checked_get_container_size(sizeof...(Args));
|
|
||||||
o.type = msgpack::type::ARRAY;
|
|
||||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
|
||||||
o.via.array.size = size;
|
|
||||||
StdTupleToObjectWithZone<decltype(v), sizeof...(Args)>::convert(o, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
template <typename... Args>
|
||||||
|
struct object_with_zone<std::tuple<Args...>> {
|
||||||
|
void operator()(
|
||||||
|
msgpack::object::with_zone& o,
|
||||||
|
std::tuple<Args...> const& v) const {
|
||||||
|
uint32_t size = checked_get_container_size(sizeof...(Args));
|
||||||
|
o.type = msgpack::type::ARRAY;
|
||||||
|
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||||
|
o.via.array.size = size;
|
||||||
|
StdTupleToObjectWithZone<decltype(v), sizeof...(Args)>::convert(o, v);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -1,62 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2014 FURUHASHI Sadayuki and KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_CPP11_TUPLE_FWD_HPP
|
|
||||||
#define MSGPACK_CPP11_TUPLE_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
|
|
||||||
#include <tuple>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
// --- Pack from tuple to packer stream ---
|
|
||||||
template <typename Stream, typename Tuple, std::size_t N>
|
|
||||||
struct StdTuplePacker;
|
|
||||||
|
|
||||||
template <typename Stream, typename... Args>
|
|
||||||
const msgpack::packer<Stream>& operator<< (
|
|
||||||
msgpack::packer<Stream>& o,
|
|
||||||
const std::tuple<Args...>& v);
|
|
||||||
|
|
||||||
// --- Convert from tuple to object ---
|
|
||||||
|
|
||||||
template <typename Tuple, std::size_t N>
|
|
||||||
struct StdTupleConverter;
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
msgpack::object const& operator>> (
|
|
||||||
msgpack::object const& o,
|
|
||||||
std::tuple<Args...>& v);
|
|
||||||
|
|
||||||
// --- Convert from tuple to object with zone ---
|
|
||||||
template <typename Tuple, std::size_t N>
|
|
||||||
struct StdTupleToObjectWithZone;
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
void operator<< (
|
|
||||||
msgpack::object::with_zone& o,
|
|
||||||
std::tuple<Args...> const& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_CPP11_TUPLE_FWD_HPP
|
|
@@ -19,124 +19,140 @@
|
|||||||
#define MSGPACK_TYPE_UNORDERED_MAP_HPP
|
#define MSGPACK_TYPE_UNORDERED_MAP_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/adaptor/check_container_size.hpp"
|
#include "msgpack/adaptor/check_container_size.hpp"
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
template <typename K, typename V>
|
template <typename K, typename V>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::unordered_map<K, V>& v)
|
struct convert<std::unordered_map<K, V>> {
|
||||||
{
|
msgpack::object const& operator()(msgpack::object const& o, std::unordered_map<K, V>& v) const {
|
||||||
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||||
msgpack::object_kv* p(o.via.map.ptr);
|
msgpack::object_kv* p(o.via.map.ptr);
|
||||||
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||||
std::unordered_map<K, V> tmp;
|
std::unordered_map<K, V> tmp;
|
||||||
for(; p != pend; ++p) {
|
for(; p != pend; ++p) {
|
||||||
K key;
|
K key;
|
||||||
p->key.convert(key);
|
p->key.convert(key);
|
||||||
p->val.convert(tmp[key]);
|
p->val.convert(tmp[key]);
|
||||||
|
}
|
||||||
|
tmp.swap(v);
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
tmp.swap(v);
|
};
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, typename K, typename V>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_map<K,V>& v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
o.pack_map(size);
|
|
||||||
for(typename std::unordered_map<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
|
||||||
it != it_end; ++it) {
|
|
||||||
o.pack(it->first);
|
|
||||||
o.pack(it->second);
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
template <typename K, typename V>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const std::unordered_map<K,V>& v)
|
struct pack<std::unordered_map<K, V>> {
|
||||||
{
|
template <typename Stream>
|
||||||
o.type = msgpack::type::MAP;
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::unordered_map<K,V>& v) const {
|
||||||
if(v.empty()) {
|
|
||||||
o.via.map.ptr = nullptr;
|
|
||||||
o.via.map.size = 0;
|
|
||||||
} else {
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
o.pack_map(size);
|
||||||
msgpack::object_kv* const pend = p + size;
|
for(typename std::unordered_map<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
||||||
o.via.map.ptr = p;
|
it != it_end; ++it) {
|
||||||
o.via.map.size = size;
|
o.pack(it->first);
|
||||||
typename std::unordered_map<K,V>::const_iterator it(v.begin());
|
o.pack(it->second);
|
||||||
do {
|
}
|
||||||
p->key = msgpack::object(it->first, o.zone);
|
return o;
|
||||||
p->val = msgpack::object(it->second, o.zone);
|
|
||||||
++p;
|
|
||||||
++it;
|
|
||||||
} while(p < pend);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
template <typename K, typename V>
|
||||||
|
struct object_with_zone<std::unordered_map<K, V>> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const std::unordered_map<K,V>& v) const {
|
||||||
|
o.type = msgpack::type::MAP;
|
||||||
|
if(v.empty()) {
|
||||||
|
o.via.map.ptr = nullptr;
|
||||||
|
o.via.map.size = 0;
|
||||||
|
} else {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||||
|
msgpack::object_kv* const pend = p + size;
|
||||||
|
o.via.map.ptr = p;
|
||||||
|
o.via.map.size = size;
|
||||||
|
typename std::unordered_map<K,V>::const_iterator it(v.begin());
|
||||||
|
do {
|
||||||
|
p->key = msgpack::object(it->first, o.zone);
|
||||||
|
p->val = msgpack::object(it->second, o.zone);
|
||||||
|
++p;
|
||||||
|
++it;
|
||||||
|
} while(p < pend);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
template <typename K, typename V>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::unordered_multimap<K, V>& v)
|
struct convert<std::unordered_multimap<K, V>> {
|
||||||
{
|
msgpack::object const& operator()(msgpack::object const& o, std::unordered_multimap<K, V>& v) const {
|
||||||
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||||
msgpack::object_kv* p(o.via.map.ptr);
|
msgpack::object_kv* p(o.via.map.ptr);
|
||||||
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||||
std::unordered_multimap<K, V> tmp;
|
std::unordered_multimap<K, V> tmp;
|
||||||
for(; p != pend; ++p) {
|
for(; p != pend; ++p) {
|
||||||
std::pair<K, V> value;
|
std::pair<K, V> value;
|
||||||
p->key.convert(value.first);
|
p->key.convert(value.first);
|
||||||
p->val.convert(value.second);
|
p->val.convert(value.second);
|
||||||
tmp.insert(value);
|
tmp.insert(value);
|
||||||
|
}
|
||||||
|
tmp.swap(v);
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
tmp.swap(v);
|
};
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, typename K, typename V>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_multimap<K,V>& v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
o.pack_map(size);
|
|
||||||
for(typename std::unordered_multimap<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
|
||||||
it != it_end; ++it) {
|
|
||||||
o.pack(it->first);
|
|
||||||
o.pack(it->second);
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
template <typename K, typename V>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const std::unordered_multimap<K,V>& v)
|
struct pack<std::unordered_multimap<K, V>> {
|
||||||
{
|
template <typename Stream>
|
||||||
o.type = msgpack::type::MAP;
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::unordered_multimap<K,V>& v) const {
|
||||||
if(v.empty()) {
|
|
||||||
o.via.map.ptr = nullptr;
|
|
||||||
o.via.map.size = 0;
|
|
||||||
} else {
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
o.pack_map(size);
|
||||||
msgpack::object_kv* const pend = p + size;
|
for(typename std::unordered_multimap<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
||||||
o.via.map.ptr = p;
|
it != it_end; ++it) {
|
||||||
o.via.map.size = size;
|
o.pack(it->first);
|
||||||
typename std::unordered_multimap<K,V>::const_iterator it(v.begin());
|
o.pack(it->second);
|
||||||
do {
|
}
|
||||||
p->key = msgpack::object(it->first, o.zone);
|
return o;
|
||||||
p->val = msgpack::object(it->second, o.zone);
|
|
||||||
++p;
|
|
||||||
++it;
|
|
||||||
} while(p < pend);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
template <typename K, typename V>
|
||||||
|
struct object_with_zone<std::unordered_multimap<K, V>> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const std::unordered_multimap<K,V>& v) const {
|
||||||
|
o.type = msgpack::type::MAP;
|
||||||
|
if(v.empty()) {
|
||||||
|
o.via.map.ptr = nullptr;
|
||||||
|
o.via.map.size = 0;
|
||||||
|
} else {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||||
|
msgpack::object_kv* const pend = p + size;
|
||||||
|
o.via.map.ptr = p;
|
||||||
|
o.via.map.size = size;
|
||||||
|
typename std::unordered_multimap<K,V>::const_iterator it(v.begin());
|
||||||
|
do {
|
||||||
|
p->key = msgpack::object(it->first, o.zone);
|
||||||
|
p->val = msgpack::object(it->second, o.zone);
|
||||||
|
++p;
|
||||||
|
++it;
|
||||||
|
} while(p < pend);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
} // namespace msgpack
|
||||||
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_UNORDERED_MAP_HPP
|
#endif // MSGPACK_TYPE_UNORDERED_MAP_HPP
|
||||||
|
@@ -1,53 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2014 KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_UNORDERED_MAP_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_UNORDERED_MAP_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, std::unordered_map<K, V>& v);
|
|
||||||
|
|
||||||
template <typename Stream, typename K, typename V>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_map<K,V>& v);
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const std::unordered_map<K,V>& v);
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, std::unordered_multimap<K, V>& v);
|
|
||||||
|
|
||||||
template <typename Stream, typename K, typename V>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_multimap<K,V>& v);
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const std::unordered_multimap<K,V>& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_UNORDERED_MAP_FWD_HPP
|
|
@@ -19,116 +19,132 @@
|
|||||||
#define MSGPACK_TYPE_UNORDERED_SET_HPP
|
#define MSGPACK_TYPE_UNORDERED_SET_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/adaptor/check_container_size.hpp"
|
#include "msgpack/adaptor/check_container_size.hpp"
|
||||||
|
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::unordered_set<T>& v)
|
struct convert<std::unordered_set<T>> {
|
||||||
{
|
msgpack::object const& operator()(msgpack::object const& o, std::unordered_set<T>& v) const {
|
||||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||||
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
||||||
msgpack::object* const pbegin = o.via.array.ptr;
|
msgpack::object* const pbegin = o.via.array.ptr;
|
||||||
std::unordered_set<T> tmp;
|
std::unordered_set<T> tmp;
|
||||||
while(p > pbegin) {
|
while(p > pbegin) {
|
||||||
--p;
|
--p;
|
||||||
tmp.insert(p->as<T>());
|
tmp.insert(p->as<T>());
|
||||||
|
}
|
||||||
|
tmp.swap(v);
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
tmp.swap(v);
|
};
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_set<T>& v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
o.pack_array(size);
|
|
||||||
for(typename std::unordered_set<T>::const_iterator it(v.begin()), it_end(v.end());
|
|
||||||
it != it_end; ++it) {
|
|
||||||
o.pack(*it);
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const std::unordered_set<T>& v)
|
struct pack<std::unordered_set<T>> {
|
||||||
{
|
template <typename Stream>
|
||||||
o.type = msgpack::type::ARRAY;
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::unordered_set<T>& v) const {
|
||||||
if(v.empty()) {
|
|
||||||
o.via.array.ptr = nullptr;
|
|
||||||
o.via.array.size = 0;
|
|
||||||
} else {
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
o.pack_array(size);
|
||||||
msgpack::object* const pend = p + size;
|
for(typename std::unordered_set<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||||
o.via.array.ptr = p;
|
|
||||||
o.via.array.size = size;
|
|
||||||
typename std::unordered_set<T>::const_iterator it(v.begin());
|
|
||||||
do {
|
|
||||||
*p = msgpack::object(*it, o.zone);
|
|
||||||
++p;
|
|
||||||
++it;
|
|
||||||
} while(p < pend);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::unordered_multiset<T>& v)
|
|
||||||
{
|
|
||||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
|
||||||
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
|
||||||
msgpack::object* const pbegin = o.via.array.ptr;
|
|
||||||
std::unordered_multiset<T> tmp;
|
|
||||||
while(p > pbegin) {
|
|
||||||
--p;
|
|
||||||
tmp.insert(p->as<T>());
|
|
||||||
}
|
|
||||||
tmp.swap(v);
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_multiset<T>& v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
o.pack_array(size);
|
|
||||||
for(typename std::unordered_multiset<T>::const_iterator it(v.begin()), it_end(v.end());
|
|
||||||
it != it_end; ++it) {
|
it != it_end; ++it) {
|
||||||
o.pack(*it);
|
o.pack(*it);
|
||||||
|
}
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
return o;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const std::unordered_multiset<T>& v)
|
struct object_with_zone<std::unordered_set<T>> {
|
||||||
{
|
void operator()(msgpack::object::with_zone& o, const std::unordered_set<T>& v) const {
|
||||||
o.type = msgpack::type::ARRAY;
|
o.type = msgpack::type::ARRAY;
|
||||||
if(v.empty()) {
|
if(v.empty()) {
|
||||||
o.via.array.ptr = nullptr;
|
o.via.array.ptr = nullptr;
|
||||||
o.via.array.size = 0;
|
o.via.array.size = 0;
|
||||||
} else {
|
} else {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||||
msgpack::object* const pend = p + size;
|
msgpack::object* const pend = p + size;
|
||||||
o.via.array.ptr = p;
|
o.via.array.ptr = p;
|
||||||
o.via.array.size = size;
|
o.via.array.size = size;
|
||||||
typename std::unordered_multiset<T>::const_iterator it(v.begin());
|
typename std::unordered_set<T>::const_iterator it(v.begin());
|
||||||
do {
|
do {
|
||||||
*p = msgpack::object(*it, o.zone);
|
*p = msgpack::object(*it, o.zone);
|
||||||
++p;
|
++p;
|
||||||
++it;
|
++it;
|
||||||
} while(p < pend);
|
} while(p < pend);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
template <typename T>
|
||||||
|
struct convert<std::unordered_multiset<T>> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, std::unordered_multiset<T>& v) const {
|
||||||
|
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||||
|
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
||||||
|
msgpack::object* const pbegin = o.via.array.ptr;
|
||||||
|
std::unordered_multiset<T> tmp;
|
||||||
|
while(p > pbegin) {
|
||||||
|
--p;
|
||||||
|
tmp.insert(p->as<T>());
|
||||||
|
}
|
||||||
|
tmp.swap(v);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct pack<std::unordered_multiset<T>> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::unordered_multiset<T>& v) const {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
o.pack_array(size);
|
||||||
|
for(typename std::unordered_multiset<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||||
|
it != it_end; ++it) {
|
||||||
|
o.pack(*it);
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct object_with_zone<std::unordered_multiset<T>> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const std::unordered_multiset<T>& v) const {
|
||||||
|
o.type = msgpack::type::ARRAY;
|
||||||
|
if(v.empty()) {
|
||||||
|
o.via.array.ptr = nullptr;
|
||||||
|
o.via.array.size = 0;
|
||||||
|
} else {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||||
|
msgpack::object* const pend = p + size;
|
||||||
|
o.via.array.ptr = p;
|
||||||
|
o.via.array.size = size;
|
||||||
|
typename std::unordered_multiset<T>::const_iterator it(v.begin());
|
||||||
|
do {
|
||||||
|
*p = msgpack::object(*it, o.zone);
|
||||||
|
++p;
|
||||||
|
++it;
|
||||||
|
} while(p < pend);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
} // namespace msgpack
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_UNORDERED_SET_HPP
|
#endif // MSGPACK_TYPE_UNORDERED_SET_HPP
|
||||||
|
@@ -1,52 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2014 KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_UNORDERED_SET_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_UNORDERED_SET_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
|
|
||||||
#include <unordered_set>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, std::unordered_set<T>& v);
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_set<T>& v);
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const std::unordered_set<T>& v);
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, std::unordered_multiset<T>& v);
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::unordered_multiset<T>& v);
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const std::unordered_multiset<T>& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_UNORDERED_SET_FWD_HPP
|
|
@@ -19,64 +19,76 @@
|
|||||||
#define MSGPACK_TYPE_DEQUE_HPP
|
#define MSGPACK_TYPE_DEQUE_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/adaptor/check_container_size.hpp"
|
#include "msgpack/adaptor/check_container_size.hpp"
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::deque<T>& v)
|
struct convert<std::deque<T> > {
|
||||||
{
|
msgpack::object const& operator()(msgpack::object const& o, std::deque<T>& v) const {
|
||||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||||
v.resize(o.via.array.size);
|
v.resize(o.via.array.size);
|
||||||
msgpack::object* p = o.via.array.ptr;
|
msgpack::object* p = o.via.array.ptr;
|
||||||
msgpack::object* const pend = o.via.array.ptr + o.via.array.size;
|
msgpack::object* const pend = o.via.array.ptr + o.via.array.size;
|
||||||
typename std::deque<T>::iterator it = v.begin();
|
typename std::deque<T>::iterator it = v.begin();
|
||||||
for(; p < pend; ++p, ++it) {
|
for(; p < pend; ++p, ++it) {
|
||||||
p->convert(*it);
|
p->convert(*it);
|
||||||
|
}
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
return o;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::deque<T>& v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
o.pack_array(size);
|
|
||||||
for(typename std::deque<T>::const_iterator it(v.begin()), it_end(v.end());
|
|
||||||
it != it_end; ++it) {
|
|
||||||
o.pack(*it);
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const std::deque<T>& v)
|
struct pack<std::deque<T> > {
|
||||||
{
|
template <typename Stream>
|
||||||
o.type = msgpack::type::ARRAY;
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::deque<T>& v) const {
|
||||||
if(v.empty()) {
|
|
||||||
o.via.array.ptr = nullptr;
|
|
||||||
o.via.array.size = 0;
|
|
||||||
} else {
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
o.pack_array(size);
|
||||||
msgpack::object* const pend = p + size;
|
for(typename std::deque<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||||
o.via.array.ptr = p;
|
it != it_end; ++it) {
|
||||||
o.via.array.size = size;
|
o.pack(*it);
|
||||||
typename std::deque<T>::const_iterator it(v.begin());
|
}
|
||||||
do {
|
return o;
|
||||||
*p = msgpack::object(*it, o.zone);
|
|
||||||
++p;
|
|
||||||
++it;
|
|
||||||
} while(p < pend);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct object_with_zone<std::deque<T> > {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const std::deque<T>& v) const {
|
||||||
|
o.type = msgpack::type::ARRAY;
|
||||||
|
if(v.empty()) {
|
||||||
|
o.via.array.ptr = nullptr;
|
||||||
|
o.via.array.size = 0;
|
||||||
|
} else {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||||
|
msgpack::object* const pend = p + size;
|
||||||
|
o.via.array.ptr = p;
|
||||||
|
o.via.array.size = size;
|
||||||
|
typename std::deque<T>::const_iterator it(v.begin());
|
||||||
|
do {
|
||||||
|
*p = msgpack::object(*it, o.zone);
|
||||||
|
++p;
|
||||||
|
++it;
|
||||||
|
} while(p < pend);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -1,40 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2014 FURUHASHI Sadayuki and KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_DEQUE_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_DEQUE_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
#include <deque>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, std::deque<T>& v);
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::deque<T>& v);
|
|
||||||
template <typename T>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const std::deque<T>& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_DEQUE_FWD_HPP
|
|
@@ -19,8 +19,8 @@
|
|||||||
#define MSGPACK_CPP03_DEFINE_HPP
|
#define MSGPACK_CPP03_DEFINE_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/adaptor/msgpack_tuple_fwd.hpp"
|
#include "msgpack/adaptor/msgpack_tuple.hpp"
|
||||||
#include "msgpack/adaptor/int_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/object_fwd.hpp"
|
||||||
|
|
||||||
#define MSGPACK_DEFINE(...) \
|
#define MSGPACK_DEFINE(...) \
|
||||||
@@ -40,44 +40,57 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MSGPACK_ADD_ENUM must be used in the global namespace.
|
// MSGPACK_ADD_ENUM must be used in the global namespace.
|
||||||
#define MSGPACK_ADD_ENUM(enum) \
|
#define MSGPACK_ADD_ENUM(enum_name) \
|
||||||
namespace msgpack { \
|
namespace msgpack { \
|
||||||
|
/** @cond */ \
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) { \
|
MSGPACK_API_VERSION_NAMESPACE(v1) { \
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, enum& v) \
|
/** @endcond */ \
|
||||||
{ \
|
namespace adaptor { \
|
||||||
int tmp; \
|
template<> \
|
||||||
o >> tmp; \
|
struct convert<enum_name> { \
|
||||||
v = static_cast<enum>(tmp); \
|
msgpack::object const& operator()(msgpack::object const& o, enum_name& v) const {\
|
||||||
return o; \
|
int tmp; \
|
||||||
} \
|
o >> tmp; \
|
||||||
inline void operator<< (msgpack::object& o, const enum& v) \
|
v = static_cast<enum_name>(tmp); \
|
||||||
{ \
|
return o; \
|
||||||
o << static_cast<int>(v); \
|
} \
|
||||||
} \
|
}; \
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const enum& v) \
|
template<> \
|
||||||
{ \
|
struct object<enum_name> { \
|
||||||
o << static_cast<int>(v); \
|
void operator()(msgpack::object& o, const enum_name& v) const {\
|
||||||
} \
|
o << static_cast<int>(v); \
|
||||||
namespace detail { \
|
} \
|
||||||
|
}; \
|
||||||
|
template<> \
|
||||||
|
struct object_with_zone<enum_name> { \
|
||||||
|
void operator()(msgpack::object::with_zone& o, const enum_name& v) const { \
|
||||||
|
o << static_cast<int>(v); \
|
||||||
|
} \
|
||||||
|
}; \
|
||||||
|
template<> \
|
||||||
|
struct pack<enum_name> { \
|
||||||
template <typename Stream> \
|
template <typename Stream> \
|
||||||
struct packer_serializer<Stream, enum> { \
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const enum_name& v) const { \
|
||||||
static msgpack::packer<Stream>& pack(msgpack::packer<Stream>& o, const enum& v) { \
|
return o << static_cast<int>(v); \
|
||||||
return o << static_cast<int>(v); \
|
} \
|
||||||
} \
|
}; \
|
||||||
}; \
|
|
||||||
} \
|
|
||||||
} \
|
} \
|
||||||
|
/** @cond */ \
|
||||||
|
} \
|
||||||
|
/** @endcond */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
|
||||||
template <typename A0 = void, typename A1 = void, typename A2 = void, typename A3 = void, typename A4 = void, typename A5 = void, typename A6 = void, typename A7 = void, typename A8 = void, typename A9 = void, typename A10 = void, typename A11 = void, typename A12 = void, typename A13 = void, typename A14 = void, typename A15 = void, typename A16 = void, typename A17 = void, typename A18 = void, typename A19 = void, typename A20 = void, typename A21 = void, typename A22 = void, typename A23 = void, typename A24 = void, typename A25 = void, typename A26 = void, typename A27 = void, typename A28 = void, typename A29 = void, typename A30 = void, typename A31 = void, typename A32 = void>
|
template <typename A0 = void, typename A1 = void, typename A2 = void, typename A3 = void, typename A4 = void, typename A5 = void, typename A6 = void, typename A7 = void, typename A8 = void, typename A9 = void, typename A10 = void, typename A11 = void, typename A12 = void, typename A13 = void, typename A14 = void, typename A15 = void, typename A16 = void, typename A17 = void, typename A18 = void, typename A19 = void, typename A20 = void, typename A21 = void, typename A22 = void, typename A23 = void, typename A24 = void, typename A25 = void, typename A26 = void, typename A27 = void, typename A28 = void, typename A29 = void, typename A30 = void, typename A31 = void, typename A32 = void>
|
||||||
struct define;
|
struct define;
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct define<> {
|
struct define<> {
|
||||||
@@ -100,6 +113,8 @@ struct define<> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
|
||||||
template <typename A0>
|
template <typename A0>
|
||||||
struct define<A0> {
|
struct define<A0> {
|
||||||
typedef define<A0> value_type;
|
typedef define<A0> value_type;
|
||||||
@@ -3268,12 +3283,15 @@ struct define<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A
|
|||||||
A31& a31;
|
A31& a31;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
inline define<> make_define()
|
inline define<> make_define()
|
||||||
{
|
{
|
||||||
return define<>();
|
return define<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
|
||||||
template <typename A0>
|
template <typename A0>
|
||||||
define<A0> make_define(A0& a0)
|
define<A0> make_define(A0& a0)
|
||||||
{
|
{
|
||||||
@@ -3466,9 +3484,12 @@ define<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16
|
|||||||
return define<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29, A30, A31>(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31);
|
return define<A0, A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16, A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29, A30, A31>(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, a31);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -19,10 +19,10 @@
|
|||||||
#define MSGPACK_CPP11_DEFINE_HPP
|
#define MSGPACK_CPP11_DEFINE_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
|
|
||||||
// for MSGPACK_ADD_ENUM
|
// for MSGPACK_ADD_ENUM
|
||||||
#include "msgpack/adaptor/int_fwd.hpp"
|
#include "msgpack/adaptor/int.hpp"
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
@@ -44,39 +44,52 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MSGPACK_ADD_ENUM must be used in the global namespace.
|
// MSGPACK_ADD_ENUM must be used in the global namespace.
|
||||||
#define MSGPACK_ADD_ENUM(enum) \
|
#define MSGPACK_ADD_ENUM(enum_name) \
|
||||||
namespace msgpack { \
|
namespace msgpack { \
|
||||||
|
/** @cond */ \
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) { \
|
MSGPACK_API_VERSION_NAMESPACE(v1) { \
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, enum& v) \
|
/** @endcond */ \
|
||||||
{ \
|
namespace adaptor { \
|
||||||
std::underlying_type<enum>::type tmp; \
|
template<> \
|
||||||
o >> tmp; \
|
struct convert<enum_name> { \
|
||||||
v = static_cast<enum>(tmp); \
|
msgpack::object const& operator()(msgpack::object const& o, enum_name& v) const { \
|
||||||
return o; \
|
std::underlying_type<enum_name>::type tmp; \
|
||||||
} \
|
o >> tmp; \
|
||||||
inline void operator<< (msgpack::object& o, const enum& v) \
|
v = static_cast<enum_name>(tmp); \
|
||||||
{ \
|
return o; \
|
||||||
auto tmp = static_cast<std::underlying_type<enum>::type>(v); \
|
} \
|
||||||
o << tmp; \
|
}; \
|
||||||
} \
|
template<> \
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const enum& v) \
|
struct object<enum_name> { \
|
||||||
{ \
|
void operator()(msgpack::object& o, const enum_name& v) const { \
|
||||||
auto tmp = static_cast<std::underlying_type<enum>::type>(v); \
|
auto tmp = static_cast<std::underlying_type<enum_name>::type>(v); \
|
||||||
o << tmp; \
|
o << tmp; \
|
||||||
} \
|
} \
|
||||||
namespace detail { \
|
}; \
|
||||||
|
template<> \
|
||||||
|
struct object_with_zone<enum_name> { \
|
||||||
|
void operator()(msgpack::object::with_zone& o, const enum_name& v) const { \
|
||||||
|
auto tmp = static_cast<std::underlying_type<enum_name>::type>(v); \
|
||||||
|
o << tmp; \
|
||||||
|
} \
|
||||||
|
}; \
|
||||||
|
template <> \
|
||||||
|
struct pack<enum_name> { \
|
||||||
template <typename Stream> \
|
template <typename Stream> \
|
||||||
struct packer_serializer<Stream, enum> { \
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const enum_name& v) const { \
|
||||||
static msgpack::packer<Stream>& pack(msgpack::packer<Stream>& o, const enum& v) { \
|
return o << static_cast<std::underlying_type<enum_name>::type>(v); \
|
||||||
return o << static_cast<std::underlying_type<enum>::type>(v); \
|
} \
|
||||||
} \
|
}; \
|
||||||
}; \
|
|
||||||
} \
|
|
||||||
} \
|
} \
|
||||||
|
/** @cond */ \
|
||||||
|
} \
|
||||||
|
/** @endcond */ \
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
template <typename Tuple, std::size_t N>
|
template <typename Tuple, std::size_t N>
|
||||||
@@ -178,7 +191,9 @@ define<Args...> make_define(Args&... args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
#endif // MSGPACK_CPP11_DEFINE_HPP
|
#endif // MSGPACK_CPP11_DEFINE_HPP
|
||||||
|
@@ -25,7 +25,9 @@
|
|||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
namespace type {
|
namespace type {
|
||||||
// tuple
|
// tuple
|
||||||
@@ -119,14 +121,21 @@ struct MsgpackTuplePacker<Stream, Tuple, 0> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Stream, typename... Args>
|
namespace adaptor {
|
||||||
const msgpack::packer<Stream>& operator<< (
|
|
||||||
msgpack::packer<Stream>& o,
|
template <typename... Args>
|
||||||
const type::tuple<Args...>& v) {
|
struct pack<type::tuple<Args...>> {
|
||||||
o.pack_array(sizeof...(Args));
|
template <typename Stream>
|
||||||
MsgpackTuplePacker<Stream, decltype(v), sizeof...(Args)>::pack(o, v);
|
msgpack::packer<Stream>& operator()(
|
||||||
return o;
|
msgpack::packer<Stream>& o,
|
||||||
}
|
const type::tuple<Args...>& v) const {
|
||||||
|
o.pack_array(sizeof...(Args));
|
||||||
|
MsgpackTuplePacker<Stream, decltype(v), sizeof...(Args)>::pack(o, v);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
// --- Convert from tuple to object ---
|
// --- Convert from tuple to object ---
|
||||||
|
|
||||||
@@ -157,15 +166,21 @@ struct MsgpackTupleConverter<Tuple, 0> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
msgpack::object const& operator>> (
|
struct convert<type::tuple<Args...>> {
|
||||||
msgpack::object const& o,
|
msgpack::object const& operator()(
|
||||||
type::tuple<Args...>& v) {
|
msgpack::object const& o,
|
||||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
type::tuple<Args...>& v) const {
|
||||||
if(o.via.array.size < sizeof...(Args)) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||||
MsgpackTupleConverter<decltype(v), sizeof...(Args)>::convert(o, v);
|
if(o.via.array.size < sizeof...(Args)) { throw msgpack::type_error(); }
|
||||||
return o;
|
MsgpackTupleConverter<decltype(v), sizeof...(Args)>::convert(o, v);
|
||||||
}
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
// --- Convert from tuple to object with zone ---
|
// --- Convert from tuple to object with zone ---
|
||||||
template <typename Tuple, std::size_t N>
|
template <typename Tuple, std::size_t N>
|
||||||
@@ -195,17 +210,25 @@ struct MsgpackTupleToObjectWithZone<Tuple, 0> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename... Args>
|
namespace adaptor {
|
||||||
inline void operator<< (
|
|
||||||
msgpack::object::with_zone& o,
|
|
||||||
type::tuple<Args...> const& v) {
|
|
||||||
o.type = msgpack::type::ARRAY;
|
|
||||||
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*sizeof...(Args)));
|
|
||||||
o.via.array.size = sizeof...(Args);
|
|
||||||
MsgpackTupleToObjectWithZone<decltype(v), sizeof...(Args)>::convert(o, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
template <typename... Args>
|
||||||
|
struct object_with_zone<type::tuple<Args...>> {
|
||||||
|
void operator()(
|
||||||
|
msgpack::object::with_zone& o,
|
||||||
|
type::tuple<Args...> const& v) const {
|
||||||
|
o.type = msgpack::type::ARRAY;
|
||||||
|
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*sizeof...(Args)));
|
||||||
|
o.via.array.size = sizeof...(Args);
|
||||||
|
MsgpackTupleToObjectWithZone<decltype(v), sizeof...(Args)>::convert(o, v);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
///@endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -1,84 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2014 FURUHASHI Sadayuki and KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_CPP11_MSGPACK_TUPLE_FWD_HPP
|
|
||||||
#define MSGPACK_CPP11_MSGPACK_TUPLE_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
|
|
||||||
#include <tuple>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
namespace type {
|
|
||||||
// tuple
|
|
||||||
using std::get;
|
|
||||||
using std::tuple_size;
|
|
||||||
using std::tuple_element;
|
|
||||||
using std::uses_allocator;
|
|
||||||
using std::ignore;
|
|
||||||
using std::make_tuple;
|
|
||||||
using std::tie;
|
|
||||||
using std::forward_as_tuple;
|
|
||||||
using std::swap;
|
|
||||||
|
|
||||||
template< class... Types >
|
|
||||||
class tuple;
|
|
||||||
|
|
||||||
template< class... Tuples >
|
|
||||||
auto tuple_cat(Tuples&&... args) ->
|
|
||||||
decltype(
|
|
||||||
std::tuple_cat(std::forward<typename std::remove_reference<Tuples>::type::base>(args)...)
|
|
||||||
);
|
|
||||||
} // namespace type
|
|
||||||
|
|
||||||
// --- Pack ( from tuple to packer stream ---
|
|
||||||
template <typename Stream, typename Tuple, std::size_t N>
|
|
||||||
struct MsgpackTuplePacker;
|
|
||||||
|
|
||||||
template <typename Stream, typename... Args>
|
|
||||||
const msgpack::packer<Stream>& operator<< (
|
|
||||||
msgpack::packer<Stream>& o,
|
|
||||||
const type::tuple<Args...>& v);
|
|
||||||
|
|
||||||
// --- Convert from tuple to object ---
|
|
||||||
|
|
||||||
template <typename Tuple, std::size_t N>
|
|
||||||
struct MsgpackTupleConverter;
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
msgpack::object const& operator>> (
|
|
||||||
msgpack::object const& o,
|
|
||||||
type::tuple<Args...>& v);
|
|
||||||
|
|
||||||
// --- Convert from tuple to object with zone ---
|
|
||||||
template <typename Tuple, std::size_t N>
|
|
||||||
struct MsgpackTupleToObjectWithZone;
|
|
||||||
|
|
||||||
template <typename... Args>
|
|
||||||
void operator<< (
|
|
||||||
msgpack::object::with_zone& o,
|
|
||||||
type::tuple<Args...> const& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_CPP11_MSGPACK_TUPLE_FWD_HPP
|
|
@@ -19,12 +19,14 @@
|
|||||||
#define MSGPACK_TYPE_FIXINT_HPP
|
#define MSGPACK_TYPE_FIXINT_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/adaptor/int.hpp"
|
#include "msgpack/adaptor/int.hpp"
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
@@ -56,156 +58,248 @@ typedef fix_int<int64_t> fix_int64;
|
|||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::fix_int8& v)
|
template <>
|
||||||
|
struct convert<type::fix_int8> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, type::fix_int8& v) const
|
||||||
{ v = type::detail::convert_integer<int8_t>(o); return o; }
|
{ v = type::detail::convert_integer<int8_t>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::fix_int16& v)
|
template <>
|
||||||
|
struct convert<type::fix_int16> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, type::fix_int16& v) const
|
||||||
{ v = type::detail::convert_integer<int16_t>(o); return o; }
|
{ v = type::detail::convert_integer<int16_t>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::fix_int32& v)
|
template <>
|
||||||
|
struct convert<type::fix_int32> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, type::fix_int32& v) const
|
||||||
{ v = type::detail::convert_integer<int32_t>(o); return o; }
|
{ v = type::detail::convert_integer<int32_t>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::fix_int64& v)
|
template <>
|
||||||
|
struct convert<type::fix_int64> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, type::fix_int64& v) const
|
||||||
{ v = type::detail::convert_integer<int64_t>(o); return o; }
|
{ v = type::detail::convert_integer<int64_t>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::fix_uint8& v)
|
template <>
|
||||||
|
struct convert<type::fix_uint8> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, type::fix_uint8& v) const
|
||||||
{ v = type::detail::convert_integer<uint8_t>(o); return o; }
|
{ v = type::detail::convert_integer<uint8_t>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::fix_uint16& v)
|
template <>
|
||||||
|
struct convert<type::fix_uint16> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, type::fix_uint16& v) const
|
||||||
{ v = type::detail::convert_integer<uint16_t>(o); return o; }
|
{ v = type::detail::convert_integer<uint16_t>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::fix_uint32& v)
|
template <>
|
||||||
|
struct convert<type::fix_uint32> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, type::fix_uint32& v) const
|
||||||
{ v = type::detail::convert_integer<uint32_t>(o); return o; }
|
{ v = type::detail::convert_integer<uint32_t>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::fix_uint64& v)
|
template <>
|
||||||
|
struct convert<type::fix_uint64> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, type::fix_uint64& v) const
|
||||||
{ v = type::detail::convert_integer<uint64_t>(o); return o; }
|
{ v = type::detail::convert_integer<uint64_t>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
template <typename Stream>
|
struct pack<type::fix_int8> {
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int8& v)
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_int8& v) const
|
||||||
{ o.pack_fix_int8(v); return o; }
|
{ o.pack_fix_int8(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int16& v)
|
struct pack<type::fix_int16> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_int16& v) const
|
||||||
{ o.pack_fix_int16(v); return o; }
|
{ o.pack_fix_int16(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int32& v)
|
struct pack<type::fix_int32> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_int32& v) const
|
||||||
{ o.pack_fix_int32(v); return o; }
|
{ o.pack_fix_int32(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int64& v)
|
struct pack<type::fix_int64> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_int64& v) const
|
||||||
{ o.pack_fix_int64(v); return o; }
|
{ o.pack_fix_int64(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint8& v)
|
struct pack<type::fix_uint8> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_uint8& v) const
|
||||||
{ o.pack_fix_uint8(v); return o; }
|
{ o.pack_fix_uint8(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint16& v)
|
struct pack<type::fix_uint16> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_uint16& v) const
|
||||||
{ o.pack_fix_uint16(v); return o; }
|
{ o.pack_fix_uint16(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint32& v)
|
struct pack<type::fix_uint32> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_uint32& v) const
|
||||||
{ o.pack_fix_uint32(v); return o; }
|
{ o.pack_fix_uint32(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint64& v)
|
struct pack<type::fix_uint64> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_uint64& v) const
|
||||||
{ o.pack_fix_uint64(v); return o; }
|
{ o.pack_fix_uint64(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct object<type::fix_int8> {
|
||||||
|
void operator()(msgpack::object& o, type::fix_int8 v) const {
|
||||||
|
if (v.get() < 0) {
|
||||||
|
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||||
|
o.via.i64 = v.get();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||||
|
o.via.u64 = v.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, type::fix_int8 v)
|
template <>
|
||||||
{
|
struct object<type::fix_int16> {
|
||||||
if (v.get() < 0) {
|
void operator()(msgpack::object& o, type::fix_int16 v) const {
|
||||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
if(v.get() < 0) {
|
||||||
o.via.i64 = v.get();
|
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||||
|
o.via.i64 = v.get();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||||
|
o.via.u64 = v.get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
};
|
||||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
|
||||||
o.via.u64 = v.get();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, type::fix_int16 v)
|
template <>
|
||||||
{
|
struct object<type::fix_int32> {
|
||||||
if(v.get() < 0) {
|
void operator()(msgpack::object& o, type::fix_int32 v) const {
|
||||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
if (v.get() < 0) {
|
||||||
o.via.i64 = v.get();
|
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||||
|
o.via.i64 = v.get();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||||
|
o.via.u64 = v.get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
};
|
||||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
|
||||||
o.via.u64 = v.get();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, type::fix_int32 v)
|
template <>
|
||||||
{
|
struct object<type::fix_int64> {
|
||||||
if (v.get() < 0) {
|
void operator()(msgpack::object& o, type::fix_int64 v) const {
|
||||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
if (v.get() < 0) {
|
||||||
o.via.i64 = v.get();
|
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||||
|
o.via.i64 = v.get();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||||
|
o.via.u64 = v.get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
};
|
||||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
|
||||||
o.via.u64 = v.get();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, type::fix_int64 v)
|
template <>
|
||||||
{
|
struct object<type::fix_uint8> {
|
||||||
if (v.get() < 0) {
|
void operator()(msgpack::object& o, type::fix_uint8 v) const
|
||||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
|
||||||
o.via.i64 = v.get();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
|
||||||
o.via.u64 = v.get();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, type::fix_uint8 v)
|
|
||||||
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
|
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, type::fix_uint16 v)
|
template <>
|
||||||
|
struct object<type::fix_uint16> {
|
||||||
|
void operator()(msgpack::object& o, type::fix_uint16 v) const
|
||||||
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
|
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, type::fix_uint32 v)
|
template <>
|
||||||
|
struct object<type::fix_uint32> {
|
||||||
|
void operator()(msgpack::object& o, type::fix_uint32 v) const
|
||||||
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
|
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, type::fix_uint64 v)
|
template <>
|
||||||
|
struct object<type::fix_uint64> {
|
||||||
|
void operator()(msgpack::object& o, type::fix_uint64 v) const
|
||||||
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
|
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v.get(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, type::fix_int8 v)
|
struct object_with_zone<type::fix_int8> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, type::fix_int8 v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, type::fix_int16 v)
|
template <>
|
||||||
|
struct object_with_zone<type::fix_int16> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, type::fix_int16 v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, type::fix_int32 v)
|
template <>
|
||||||
|
struct object_with_zone<type::fix_int32> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, type::fix_int32 v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, type::fix_int64 v)
|
template <>
|
||||||
|
struct object_with_zone<type::fix_int64> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, type::fix_int64 v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, type::fix_uint8 v)
|
template <>
|
||||||
|
struct object_with_zone<type::fix_uint8> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, type::fix_uint8 v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, type::fix_uint16 v)
|
template <>
|
||||||
|
struct object_with_zone<type::fix_uint16> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, type::fix_uint16 v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, type::fix_uint32 v)
|
template <>
|
||||||
|
struct object_with_zone<type::fix_uint32> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, type::fix_uint32 v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, type::fix_uint64 v)
|
template <>
|
||||||
|
struct object_with_zone<type::fix_uint64> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, type::fix_uint64 v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -1,100 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2014 FURUHASHI Sadayuki and KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_FIXINT_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_FIXINT_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
namespace type {
|
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct fix_int;
|
|
||||||
|
|
||||||
typedef fix_int<uint8_t> fix_uint8;
|
|
||||||
typedef fix_int<uint16_t> fix_uint16;
|
|
||||||
typedef fix_int<uint32_t> fix_uint32;
|
|
||||||
typedef fix_int<uint64_t> fix_uint64;
|
|
||||||
|
|
||||||
typedef fix_int<int8_t> fix_int8;
|
|
||||||
typedef fix_int<int16_t> fix_int16;
|
|
||||||
typedef fix_int<int32_t> fix_int32;
|
|
||||||
typedef fix_int<int64_t> fix_int64;
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace type
|
|
||||||
|
|
||||||
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, type::fix_int8& v);
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, type::fix_int16& v);
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, type::fix_int32& v);
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, type::fix_int64& v);
|
|
||||||
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, type::fix_uint8& v);
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, type::fix_uint16& v);
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, type::fix_uint32& v);
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, type::fix_uint64& v);
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int8& v);
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int16& v);
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int32& v);
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int64& v);
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint8& v);
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint16& v);
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint32& v);
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint64& v);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object& o, type::fix_int8 v);
|
|
||||||
void operator<< (msgpack::object& o, type::fix_int16 v);
|
|
||||||
void operator<< (msgpack::object& o, type::fix_int32 v);
|
|
||||||
void operator<< (msgpack::object& o, type::fix_int64 v);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object& o, type::fix_uint8 v);
|
|
||||||
void operator<< (msgpack::object& o, type::fix_uint16 v);
|
|
||||||
void operator<< (msgpack::object& o, type::fix_uint32 v);
|
|
||||||
void operator<< (msgpack::object& o, type::fix_uint64 v);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object::with_zone& o, type::fix_int8 v);
|
|
||||||
void operator<< (msgpack::object::with_zone& o, type::fix_int16 v);
|
|
||||||
void operator<< (msgpack::object::with_zone& o, type::fix_int32 v);
|
|
||||||
void operator<< (msgpack::object::with_zone& o, type::fix_int64 v);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object::with_zone& o, type::fix_uint8 v);
|
|
||||||
void operator<< (msgpack::object::with_zone& o, type::fix_uint16 v);
|
|
||||||
void operator<< (msgpack::object::with_zone& o, type::fix_uint32 v);
|
|
||||||
void operator<< (msgpack::object::with_zone& o, type::fix_uint64 v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_FIXINT_FWD_HPP
|
|
@@ -24,81 +24,107 @@
|
|||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
// FIXME check overflow, underflow
|
// FIXME check overflow, underflow
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, float& v)
|
template <>
|
||||||
{
|
struct convert<float> {
|
||||||
if(o.type == msgpack::type::FLOAT) {
|
msgpack::object const& operator()(msgpack::object const& o, float& v) const {
|
||||||
v = static_cast<float>(o.via.f64);
|
if(o.type == msgpack::type::FLOAT) {
|
||||||
|
v = static_cast<float>(o.via.f64);
|
||||||
|
}
|
||||||
|
else if (o.type == msgpack::type::POSITIVE_INTEGER) {
|
||||||
|
v = static_cast<float>(o.via.u64);
|
||||||
|
}
|
||||||
|
else if (o.type == msgpack::type::NEGATIVE_INTEGER) {
|
||||||
|
v = static_cast<float>(o.via.i64);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw msgpack::type_error();
|
||||||
|
}
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
else if (o.type == msgpack::type::POSITIVE_INTEGER) {
|
};
|
||||||
v = static_cast<float>(o.via.u64);
|
|
||||||
|
template <>
|
||||||
|
struct pack<float> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const float& v) const {
|
||||||
|
o.pack_float(v);
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
else if (o.type == msgpack::type::NEGATIVE_INTEGER) {
|
};
|
||||||
v = static_cast<float>(o.via.i64);
|
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct convert<double> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, double& v) const {
|
||||||
|
if(o.type == msgpack::type::FLOAT) {
|
||||||
|
v = o.via.f64;
|
||||||
|
}
|
||||||
|
else if (o.type == msgpack::type::POSITIVE_INTEGER) {
|
||||||
|
v = static_cast<double>(o.via.u64);
|
||||||
|
}
|
||||||
|
else if (o.type == msgpack::type::NEGATIVE_INTEGER) {
|
||||||
|
v = static_cast<double>(o.via.i64);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw msgpack::type_error();
|
||||||
|
}
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
else {
|
};
|
||||||
throw msgpack::type_error();
|
|
||||||
|
template <>
|
||||||
|
struct pack<double> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const double& v) const {
|
||||||
|
o.pack_double(v);
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
return o;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const float& v)
|
|
||||||
{
|
|
||||||
o.pack_float(v);
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, double& v)
|
template <>
|
||||||
{
|
struct object<float> {
|
||||||
if(o.type == msgpack::type::FLOAT) {
|
void operator()(msgpack::object& o, float v) const {
|
||||||
v = o.via.f64;
|
o.type = msgpack::type::FLOAT;
|
||||||
|
o.via.f64 = static_cast<double>(v);
|
||||||
}
|
}
|
||||||
else if (o.type == msgpack::type::POSITIVE_INTEGER) {
|
};
|
||||||
v = static_cast<double>(o.via.u64);
|
|
||||||
|
template <>
|
||||||
|
struct object<double> {
|
||||||
|
void operator()(msgpack::object& o, double v) const {
|
||||||
|
o.type = msgpack::type::FLOAT;
|
||||||
|
o.via.f64 = v;
|
||||||
}
|
}
|
||||||
else if (o.type == msgpack::type::NEGATIVE_INTEGER) {
|
};
|
||||||
v = static_cast<double>(o.via.i64);
|
|
||||||
|
template <>
|
||||||
|
struct object_with_zone<float> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, float v) const {
|
||||||
|
static_cast<msgpack::object&>(o) << v;
|
||||||
}
|
}
|
||||||
else {
|
};
|
||||||
throw msgpack::type_error();
|
|
||||||
|
template <>
|
||||||
|
struct object_with_zone<double> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, double v) const {
|
||||||
|
static_cast<msgpack::object&>(o) << v;
|
||||||
}
|
}
|
||||||
return o;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const double& v)
|
|
||||||
{
|
|
||||||
o.pack_double(v);
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, float v)
|
|
||||||
{
|
|
||||||
o.type = msgpack::type::FLOAT;
|
|
||||||
o.via.f64 = static_cast<double>(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, double v)
|
|
||||||
{
|
|
||||||
o.type = msgpack::type::FLOAT;
|
|
||||||
o.via.f64 = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, float v)
|
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, double v)
|
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -1,44 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2014 FURUHASHI Sadayuki and KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_FLOAT_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_FLOAT_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, float& v);
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const float& v);
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, double& v);
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const double& v);
|
|
||||||
void operator<< (msgpack::object& o, float v);
|
|
||||||
void operator<< (msgpack::object& o, double v);
|
|
||||||
void operator<< (msgpack::object::with_zone& o, float v);
|
|
||||||
void operator<< (msgpack::object::with_zone& o, double v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_FLOAT_FWD_HPP
|
|
@@ -19,12 +19,14 @@
|
|||||||
#define MSGPACK_TYPE_INT_HPP
|
#define MSGPACK_TYPE_INT_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1){
|
MSGPACK_API_VERSION_NAMESPACE(v1){
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
namespace type {
|
namespace type {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
@@ -101,207 +103,333 @@ namespace detail {
|
|||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace type
|
} // namespace type
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, char& v)
|
namespace adaptor {
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct convert<char> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, char& v) const
|
||||||
{ v = type::detail::convert_integer<char>(o); return o; }
|
{ v = type::detail::convert_integer<char>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, signed char& v)
|
struct convert<signed char> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, signed char& v) const
|
||||||
{ v = type::detail::convert_integer<signed char>(o); return o; }
|
{ v = type::detail::convert_integer<signed char>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, signed short& v)
|
template <>
|
||||||
|
struct convert<signed short> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, signed short& v) const
|
||||||
{ v = type::detail::convert_integer<signed short>(o); return o; }
|
{ v = type::detail::convert_integer<signed short>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, signed int& v)
|
template <>
|
||||||
|
struct convert<signed int> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, signed int& v) const
|
||||||
{ v = type::detail::convert_integer<signed int>(o); return o; }
|
{ v = type::detail::convert_integer<signed int>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, signed long& v)
|
template <>
|
||||||
|
struct convert<signed long> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, signed long& v) const
|
||||||
{ v = type::detail::convert_integer<signed long>(o); return o; }
|
{ v = type::detail::convert_integer<signed long>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, signed long long& v)
|
template <>
|
||||||
|
struct convert<signed long long> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, signed long long& v) const
|
||||||
{ v = type::detail::convert_integer<signed long long>(o); return o; }
|
{ v = type::detail::convert_integer<signed long long>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, unsigned char& v)
|
template <>
|
||||||
|
struct convert<unsigned char> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, unsigned char& v) const
|
||||||
{ v = type::detail::convert_integer<unsigned char>(o); return o; }
|
{ v = type::detail::convert_integer<unsigned char>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, unsigned short& v)
|
template <>
|
||||||
|
struct convert<unsigned short> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, unsigned short& v) const
|
||||||
{ v = type::detail::convert_integer<unsigned short>(o); return o; }
|
{ v = type::detail::convert_integer<unsigned short>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, unsigned int& v)
|
template <>
|
||||||
|
struct convert<unsigned int> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, unsigned int& v) const
|
||||||
{ v = type::detail::convert_integer<unsigned int>(o); return o; }
|
{ v = type::detail::convert_integer<unsigned int>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, unsigned long& v)
|
template <>
|
||||||
|
struct convert<unsigned long> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, unsigned long& v) const
|
||||||
{ v = type::detail::convert_integer<unsigned long>(o); return o; }
|
{ v = type::detail::convert_integer<unsigned long>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, unsigned long long& v)
|
template <>
|
||||||
|
struct convert<unsigned long long> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, unsigned long long& v) const
|
||||||
{ v = type::detail::convert_integer<unsigned long long>(o); return o; }
|
{ v = type::detail::convert_integer<unsigned long long>(o); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, char v)
|
struct pack<char> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, char v) const
|
||||||
{ o.pack_char(v); return o; }
|
{ o.pack_char(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
template <typename Stream>
|
struct pack<signed char> {
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed char v)
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, signed char v) const
|
||||||
{ o.pack_signed_char(v); return o; }
|
{ o.pack_signed_char(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed short v)
|
struct pack<signed short> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, signed short v) const
|
||||||
{ o.pack_short(v); return o; }
|
{ o.pack_short(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed int v)
|
struct pack<signed int> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, signed int v) const
|
||||||
{ o.pack_int(v); return o; }
|
{ o.pack_int(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed long v)
|
struct pack<signed long> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, signed long v) const
|
||||||
{ o.pack_long(v); return o; }
|
{ o.pack_long(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed long long v)
|
struct pack<signed long long> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, signed long long v) const
|
||||||
{ o.pack_long_long(v); return o; }
|
{ o.pack_long_long(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned char v)
|
struct pack<unsigned char> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, unsigned char v) const
|
||||||
{ o.pack_unsigned_char(v); return o; }
|
{ o.pack_unsigned_char(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned short v)
|
struct pack<unsigned short> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, unsigned short v) const
|
||||||
{ o.pack_unsigned_short(v); return o; }
|
{ o.pack_unsigned_short(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned int v)
|
struct pack<unsigned int> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, unsigned int v) const
|
||||||
{ o.pack_unsigned_int(v); return o; }
|
{ o.pack_unsigned_int(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned long v)
|
struct pack<unsigned long> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, unsigned long v) const
|
||||||
{ o.pack_unsigned_long(v); return o; }
|
{ o.pack_unsigned_long(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned long long v)
|
struct pack<unsigned long long> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, unsigned long long v) const
|
||||||
{ o.pack_unsigned_long_long(v); return o; }
|
{ o.pack_unsigned_long_long(v); return o; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, char v)
|
template <>
|
||||||
|
struct object<char> {
|
||||||
|
void operator()(msgpack::object& o, char v) const
|
||||||
{ type::detail::object_char(o, v); }
|
{ type::detail::object_char(o, v); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct object<signed char> {
|
||||||
|
void operator()(msgpack::object& o, signed char v) const {
|
||||||
|
if (v < 0) {
|
||||||
|
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||||
|
o.via.i64 = v;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||||
|
o.via.u64 = v;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, signed char v)
|
template <>
|
||||||
{
|
struct object<signed short> {
|
||||||
if (v < 0) {
|
void operator()(msgpack::object& o, signed short v) const {
|
||||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
if (v < 0) {
|
||||||
o.via.i64 = v;
|
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||||
|
o.via.i64 = v;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||||
|
o.via.u64 = v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
};
|
||||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
|
||||||
o.via.u64 = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, signed short v)
|
template <>
|
||||||
{
|
struct object<signed int> {
|
||||||
if (v < 0) {
|
void operator()(msgpack::object& o, signed int v) const {
|
||||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
if (v < 0) {
|
||||||
o.via.i64 = v;
|
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||||
|
o.via.i64 = v;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||||
|
o.via.u64 = v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
};
|
||||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
|
||||||
o.via.u64 = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, signed int v)
|
template <>
|
||||||
{
|
struct object<signed long> {
|
||||||
if (v < 0) {
|
void operator()(msgpack::object& o, signed long v) const {
|
||||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
if (v < 0) {
|
||||||
o.via.i64 = v;
|
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||||
|
o.via.i64 = v;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||||
|
o.via.u64 = v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
};
|
||||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
|
||||||
o.via.u64 = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, signed long v)
|
template <>
|
||||||
{
|
struct object<signed long long> {
|
||||||
if (v < 0) {
|
void operator()(msgpack::object& o, signed long long v) const {
|
||||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
if (v < 0) {
|
||||||
o.via.i64 = v;
|
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||||
|
o.via.i64 = v;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||||
|
o.via.u64 = v;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
};
|
||||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
|
||||||
o.via.u64 = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, signed long long v)
|
template <>
|
||||||
{
|
struct object<unsigned char> {
|
||||||
if (v < 0) {
|
void operator()(msgpack::object& o, unsigned char v) const
|
||||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
|
||||||
o.via.i64 = v;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
|
||||||
o.via.u64 = v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, unsigned char v)
|
|
||||||
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; }
|
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, unsigned short v)
|
template <>
|
||||||
|
struct object<unsigned short> {
|
||||||
|
void operator()(msgpack::object& o, unsigned short v) const
|
||||||
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; }
|
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, unsigned int v)
|
template <>
|
||||||
|
struct object<unsigned int> {
|
||||||
|
void operator()(msgpack::object& o, unsigned int v) const
|
||||||
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; }
|
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, unsigned long v)
|
template <>
|
||||||
|
struct object<unsigned long> {
|
||||||
|
void operator()(msgpack::object& o, unsigned long v) const
|
||||||
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; }
|
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, unsigned long long v)
|
template <>
|
||||||
|
struct object<unsigned long long> {
|
||||||
|
void operator()(msgpack::object& o, unsigned long long v) const
|
||||||
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; }
|
{ o.type = msgpack::type::POSITIVE_INTEGER, o.via.u64 = v; }
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template <>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, char v)
|
struct object_with_zone<char> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, char v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, signed char v)
|
struct object_with_zone<signed char> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, signed char v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, signed short v)
|
template <>
|
||||||
|
struct object_with_zone<signed short> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, signed short v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, signed int v)
|
template <>
|
||||||
|
struct object_with_zone<signed int> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, signed int v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, signed long v)
|
template <>
|
||||||
|
struct object_with_zone<signed long> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, signed long v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const signed long long& v)
|
template <>
|
||||||
|
struct object_with_zone<signed long long> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const signed long long& v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, unsigned char v)
|
struct object_with_zone<unsigned char> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, unsigned char v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, unsigned short v)
|
template <>
|
||||||
|
struct object_with_zone<unsigned short> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, unsigned short v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, unsigned int v)
|
template <>
|
||||||
|
struct object_with_zone<unsigned int> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, unsigned int v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, unsigned long v)
|
template <>
|
||||||
|
struct object_with_zone<unsigned long> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, unsigned long v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const unsigned long long& v)
|
template <>
|
||||||
|
struct object_with_zone<unsigned long long> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const unsigned long long& v) const
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
{ static_cast<msgpack::object&>(o) << v; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -1,100 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ forward declaration
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2014 FURUHASHI Sadayuki and KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_INT_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_INT_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1){
|
|
||||||
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, char& v);
|
|
||||||
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, signed char& v);
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, signed short& v);
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, signed int& v);
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, signed long& v);
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, signed long long& v);
|
|
||||||
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, unsigned char& v);
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, unsigned short& v);
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, unsigned int& v);
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, unsigned long& v);
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, unsigned long long& v);
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, char v);
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed char v);
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed short v);
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed int v);
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed long v);
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed long long v);
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned char v);
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned short v);
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned int v);
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned long v);
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned long long v);
|
|
||||||
|
|
||||||
|
|
||||||
void operator<< (msgpack::object& o, char v);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object& o, signed char v);
|
|
||||||
void operator<< (msgpack::object& o, signed short v);
|
|
||||||
void operator<< (msgpack::object& o, signed int v);
|
|
||||||
void operator<< (msgpack::object& o, signed long v);
|
|
||||||
void operator<< (msgpack::object& o, signed long long v);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object& o, unsigned char v);
|
|
||||||
void operator<< (msgpack::object& o, unsigned short v);
|
|
||||||
void operator<< (msgpack::object& o, unsigned int v);
|
|
||||||
void operator<< (msgpack::object& o, unsigned long v);
|
|
||||||
void operator<< (msgpack::object& o, unsigned long long v);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object::with_zone& o, char v);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object::with_zone& o, signed char v);
|
|
||||||
void operator<< (msgpack::object::with_zone& o, signed short v);
|
|
||||||
void operator<< (msgpack::object::with_zone& o, signed int v);
|
|
||||||
void operator<< (msgpack::object::with_zone& o, signed long v);
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const signed long long& v);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object::with_zone& o, unsigned char v);
|
|
||||||
void operator<< (msgpack::object::with_zone& o, unsigned short v);
|
|
||||||
void operator<< (msgpack::object::with_zone& o, unsigned int v);
|
|
||||||
void operator<< (msgpack::object::with_zone& o, unsigned long v);
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const unsigned long long& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_INT_FWD_HPP
|
|
@@ -19,64 +19,76 @@
|
|||||||
#define MSGPACK_TYPE_LIST_HPP
|
#define MSGPACK_TYPE_LIST_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/adaptor/check_container_size.hpp"
|
#include "msgpack/adaptor/check_container_size.hpp"
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::list<T>& v)
|
struct convert<std::list<T> > {
|
||||||
{
|
msgpack::object const& operator()(msgpack::object const& o, std::list<T>& v) const {
|
||||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||||
v.resize(o.via.array.size);
|
v.resize(o.via.array.size);
|
||||||
msgpack::object* p = o.via.array.ptr;
|
msgpack::object* p = o.via.array.ptr;
|
||||||
msgpack::object* const pend = o.via.array.ptr + o.via.array.size;
|
msgpack::object* const pend = o.via.array.ptr + o.via.array.size;
|
||||||
typename std::list<T>::iterator it = v.begin();
|
typename std::list<T>::iterator it = v.begin();
|
||||||
for(; p < pend; ++p, ++it) {
|
for(; p < pend; ++p, ++it) {
|
||||||
p->convert(*it);
|
p->convert(*it);
|
||||||
|
}
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
return o;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::list<T>& v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
o.pack_array(size);
|
|
||||||
for(typename std::list<T>::const_iterator it(v.begin()), it_end(v.end());
|
|
||||||
it != it_end; ++it) {
|
|
||||||
o.pack(*it);
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const std::list<T>& v)
|
struct pack<std::list<T> > {
|
||||||
{
|
template <typename Stream>
|
||||||
o.type = msgpack::type::ARRAY;
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::list<T>& v) const {
|
||||||
if(v.empty()) {
|
|
||||||
o.via.array.ptr = nullptr;
|
|
||||||
o.via.array.size = 0;
|
|
||||||
} else {
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
o.pack_array(size);
|
||||||
msgpack::object* const pend = p + size;
|
for(typename std::list<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||||
o.via.array.ptr = p;
|
it != it_end; ++it) {
|
||||||
o.via.array.size = size;
|
o.pack(*it);
|
||||||
typename std::list<T>::const_iterator it(v.begin());
|
}
|
||||||
do {
|
return o;
|
||||||
*p = msgpack::object(*it, o.zone);
|
|
||||||
++p;
|
|
||||||
++it;
|
|
||||||
} while(p < pend);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct object_with_zone<std::list<T> > {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const std::list<T>& v) const {
|
||||||
|
o.type = msgpack::type::ARRAY;
|
||||||
|
if(v.empty()) {
|
||||||
|
o.via.array.ptr = nullptr;
|
||||||
|
o.via.array.size = 0;
|
||||||
|
} else {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||||
|
msgpack::object* const pend = p + size;
|
||||||
|
o.via.array.ptr = p;
|
||||||
|
o.via.array.size = size;
|
||||||
|
typename std::list<T>::const_iterator it(v.begin());
|
||||||
|
do {
|
||||||
|
*p = msgpack::object(*it, o.zone);
|
||||||
|
++p;
|
||||||
|
++it;
|
||||||
|
} while(p < pend);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -1,40 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_LIST_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_LIST_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
#include <list>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, std::list<T>& v);
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::list<T>& v);
|
|
||||||
template <typename T>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const std::list<T>& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_LIST_FWD_HPP
|
|
@@ -28,7 +28,9 @@
|
|||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
@@ -45,174 +47,190 @@ namespace detail {
|
|||||||
|
|
||||||
} //namespace type
|
} //namespace type
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
template <typename K, typename V>
|
template <typename K, typename V>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::assoc_vector<K,V>& v)
|
struct convert<type::assoc_vector<K, V> > {
|
||||||
{
|
msgpack::object const& operator()(msgpack::object const& o, type::assoc_vector<K,V>& v) const {
|
||||||
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||||
v.resize(o.via.map.size);
|
v.resize(o.via.map.size);
|
||||||
msgpack::object_kv* p = o.via.map.ptr;
|
msgpack::object_kv* p = o.via.map.ptr;
|
||||||
msgpack::object_kv* const pend = o.via.map.ptr + o.via.map.size;
|
msgpack::object_kv* const pend = o.via.map.ptr + o.via.map.size;
|
||||||
std::pair<K, V>* it(&v.front());
|
std::pair<K, V>* it(&v.front());
|
||||||
for(; p < pend; ++p, ++it) {
|
for(; p < pend; ++p, ++it) {
|
||||||
p->key.convert(it->first);
|
p->key.convert(it->first);
|
||||||
p->val.convert(it->second);
|
|
||||||
}
|
|
||||||
std::sort(v.begin(), v.end(), type::detail::pair_first_less<K,V>());
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, typename K, typename V>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::assoc_vector<K,V>& v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
o.pack_map(size);
|
|
||||||
for(typename type::assoc_vector<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
|
||||||
it != it_end; ++it) {
|
|
||||||
o.pack(it->first);
|
|
||||||
o.pack(it->second);
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const type::assoc_vector<K,V>& v)
|
|
||||||
{
|
|
||||||
o.type = msgpack::type::MAP;
|
|
||||||
if(v.empty()) {
|
|
||||||
o.via.map.ptr = nullptr;
|
|
||||||
o.via.map.size = 0;
|
|
||||||
} else {
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
|
||||||
msgpack::object_kv* const pend = p + size;
|
|
||||||
o.via.map.ptr = p;
|
|
||||||
o.via.map.size = size;
|
|
||||||
typename type::assoc_vector<K,V>::const_iterator it(v.begin());
|
|
||||||
do {
|
|
||||||
p->key = msgpack::object(it->first, o.zone);
|
|
||||||
p->val = msgpack::object(it->second, o.zone);
|
|
||||||
++p;
|
|
||||||
++it;
|
|
||||||
} while(p < pend);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::map<K, V>& v)
|
|
||||||
{
|
|
||||||
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
|
||||||
msgpack::object_kv* p(o.via.map.ptr);
|
|
||||||
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
|
||||||
std::map<K, V> tmp;
|
|
||||||
for(; p != pend; ++p) {
|
|
||||||
K key;
|
|
||||||
p->key.convert(key);
|
|
||||||
typename std::map<K,V>::iterator it(tmp.lower_bound(key));
|
|
||||||
if(it != tmp.end() && !(key < it->first)) {
|
|
||||||
p->val.convert(it->second);
|
p->val.convert(it->second);
|
||||||
|
}
|
||||||
|
std::sort(v.begin(), v.end(), type::detail::pair_first_less<K,V>());
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename K, typename V>
|
||||||
|
struct pack<type::assoc_vector<K, V> > {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::assoc_vector<K,V>& v) const {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
o.pack_map(size);
|
||||||
|
for(typename type::assoc_vector<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
||||||
|
it != it_end; ++it) {
|
||||||
|
o.pack(it->first);
|
||||||
|
o.pack(it->second);
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename K, typename V>
|
||||||
|
struct object_with_zone<type::assoc_vector<K, V> > {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const type::assoc_vector<K,V>& v) const {
|
||||||
|
o.type = msgpack::type::MAP;
|
||||||
|
if(v.empty()) {
|
||||||
|
o.via.map.ptr = nullptr;
|
||||||
|
o.via.map.size = 0;
|
||||||
} else {
|
} else {
|
||||||
V val;
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
p->val.convert(val);
|
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||||
tmp.insert(it, std::pair<K,V>(key, val));
|
msgpack::object_kv* const pend = p + size;
|
||||||
|
o.via.map.ptr = p;
|
||||||
|
o.via.map.size = size;
|
||||||
|
typename type::assoc_vector<K,V>::const_iterator it(v.begin());
|
||||||
|
do {
|
||||||
|
p->key = msgpack::object(it->first, o.zone);
|
||||||
|
p->val = msgpack::object(it->second, o.zone);
|
||||||
|
++p;
|
||||||
|
++it;
|
||||||
|
} while(p < pend);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tmp.swap(v);
|
};
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, typename K, typename V>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::map<K,V>& v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
o.pack_map(size);
|
|
||||||
for(typename std::map<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
|
||||||
it != it_end; ++it) {
|
|
||||||
o.pack(it->first);
|
|
||||||
o.pack(it->second);
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
template <typename K, typename V>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const std::map<K,V>& v)
|
struct convert<std::map<K, V> > {
|
||||||
{
|
msgpack::object const& operator()(msgpack::object const& o, std::map<K, V>& v) const {
|
||||||
o.type = msgpack::type::MAP;
|
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||||
if(v.empty()) {
|
msgpack::object_kv* p(o.via.map.ptr);
|
||||||
o.via.map.ptr = nullptr;
|
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||||
o.via.map.size = 0;
|
std::map<K, V> tmp;
|
||||||
} else {
|
for(; p != pend; ++p) {
|
||||||
|
K key;
|
||||||
|
p->key.convert(key);
|
||||||
|
typename std::map<K,V>::iterator it(tmp.lower_bound(key));
|
||||||
|
if(it != tmp.end() && !(key < it->first)) {
|
||||||
|
p->val.convert(it->second);
|
||||||
|
} else {
|
||||||
|
V val;
|
||||||
|
p->val.convert(val);
|
||||||
|
tmp.insert(it, std::pair<K,V>(key, val));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tmp.swap(v);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename K, typename V>
|
||||||
|
struct pack<std::map<K, V> > {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::map<K,V>& v) const {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
o.pack_map(size);
|
||||||
msgpack::object_kv* const pend = p + size;
|
for(typename std::map<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
||||||
o.via.map.ptr = p;
|
it != it_end; ++it) {
|
||||||
o.via.map.size = size;
|
o.pack(it->first);
|
||||||
typename std::map<K,V>::const_iterator it(v.begin());
|
o.pack(it->second);
|
||||||
do {
|
}
|
||||||
p->key = msgpack::object(it->first, o.zone);
|
return o;
|
||||||
p->val = msgpack::object(it->second, o.zone);
|
|
||||||
++p;
|
|
||||||
++it;
|
|
||||||
} while(p < pend);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
template <typename K, typename V>
|
||||||
|
struct object_with_zone<std::map<K, V> > {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const std::map<K,V>& v) const {
|
||||||
|
o.type = msgpack::type::MAP;
|
||||||
|
if(v.empty()) {
|
||||||
|
o.via.map.ptr = nullptr;
|
||||||
|
o.via.map.size = 0;
|
||||||
|
} else {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||||
|
msgpack::object_kv* const pend = p + size;
|
||||||
|
o.via.map.ptr = p;
|
||||||
|
o.via.map.size = size;
|
||||||
|
typename std::map<K,V>::const_iterator it(v.begin());
|
||||||
|
do {
|
||||||
|
p->key = msgpack::object(it->first, o.zone);
|
||||||
|
p->val = msgpack::object(it->second, o.zone);
|
||||||
|
++p;
|
||||||
|
++it;
|
||||||
|
} while(p < pend);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
template <typename K, typename V>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::multimap<K, V>& v)
|
struct convert<std::multimap<K, V> > {
|
||||||
{
|
msgpack::object const& operator()(msgpack::object const& o, std::multimap<K, V>& v) const {
|
||||||
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||||
msgpack::object_kv* p(o.via.map.ptr);
|
msgpack::object_kv* p(o.via.map.ptr);
|
||||||
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||||
std::multimap<K, V> tmp;
|
std::multimap<K, V> tmp;
|
||||||
for(; p != pend; ++p) {
|
for(; p != pend; ++p) {
|
||||||
std::pair<K, V> value;
|
std::pair<K, V> value;
|
||||||
p->key.convert(value.first);
|
p->key.convert(value.first);
|
||||||
p->val.convert(value.second);
|
p->val.convert(value.second);
|
||||||
tmp.insert(value);
|
tmp.insert(value);
|
||||||
|
}
|
||||||
|
tmp.swap(v);
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
tmp.swap(v);
|
};
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, typename K, typename V>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::multimap<K,V>& v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
o.pack_map(size);
|
|
||||||
for(typename std::multimap<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
|
||||||
it != it_end; ++it) {
|
|
||||||
o.pack(it->first);
|
|
||||||
o.pack(it->second);
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
template <typename K, typename V>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const std::multimap<K,V>& v)
|
struct pack<std::multimap<K, V> > {
|
||||||
{
|
template <typename Stream>
|
||||||
o.type = msgpack::type::MAP;
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::multimap<K,V>& v) const {
|
||||||
if(v.empty()) {
|
|
||||||
o.via.map.ptr = nullptr;
|
|
||||||
o.via.map.size = 0;
|
|
||||||
} else {
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
o.pack_map(size);
|
||||||
msgpack::object_kv* const pend = p + size;
|
for(typename std::multimap<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
||||||
o.via.map.ptr = p;
|
it != it_end; ++it) {
|
||||||
o.via.map.size = size;
|
o.pack(it->first);
|
||||||
typename std::multimap<K,V>::const_iterator it(v.begin());
|
o.pack(it->second);
|
||||||
do {
|
}
|
||||||
p->key = msgpack::object(it->first, o.zone);
|
return o;
|
||||||
p->val = msgpack::object(it->second, o.zone);
|
|
||||||
++p;
|
|
||||||
++it;
|
|
||||||
} while(p < pend);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
template <typename K, typename V>
|
||||||
|
struct object_with_zone<std::multimap<K, V> > {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const std::multimap<K,V>& v) const {
|
||||||
|
o.type = msgpack::type::MAP;
|
||||||
|
if(v.empty()) {
|
||||||
|
o.via.map.ptr = nullptr;
|
||||||
|
o.via.map.size = 0;
|
||||||
|
} else {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||||
|
msgpack::object_kv* const pend = p + size;
|
||||||
|
o.via.map.ptr = p;
|
||||||
|
o.via.map.size = size;
|
||||||
|
typename std::multimap<K,V>::const_iterator it(v.begin());
|
||||||
|
do {
|
||||||
|
p->key = msgpack::object(it->first, o.zone);
|
||||||
|
p->val = msgpack::object(it->second, o.zone);
|
||||||
|
++p;
|
||||||
|
++it;
|
||||||
|
} while(p < pend);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -1,69 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2014 FURUHASHI Sadayuki and KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_MAP_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_MAP_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
#include <map>
|
|
||||||
#include <vector>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
namespace type {
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
|
||||||
class assoc_vector;
|
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
template <typename K, typename V>
|
|
||||||
struct pair_first_less;
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
} // namespace type
|
|
||||||
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, type::assoc_vector<K,V>& v);
|
|
||||||
template <typename Stream, typename K, typename V>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::assoc_vector<K,V>& v);
|
|
||||||
template <typename K, typename V>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const type::assoc_vector<K,V>& v);
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, std::map<K, V>& v);
|
|
||||||
template <typename Stream, typename K, typename V>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::map<K,V>& v);
|
|
||||||
template <typename K, typename V>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const std::map<K,V>& v);
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, std::multimap<K, V>& v);
|
|
||||||
template <typename Stream, typename K, typename V>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::multimap<K,V>& v);
|
|
||||||
template <typename K, typename V>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const std::multimap<K,V>& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_MAP_HPP
|
|
@@ -1,29 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2014 FURUHASHI Sadayuki and KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_MSGPACK_TUPLE_FWD_HPP
|
|
||||||
#define MSGPACK_MSGPACK_TUPLE_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/cpp_config.hpp"
|
|
||||||
|
|
||||||
#if defined(MSGPACK_USE_CPP03)
|
|
||||||
#include "detail/cpp03_msgpack_tuple_fwd.hpp"
|
|
||||||
#else // MSGPACK_USE_CPP03
|
|
||||||
#include "detail/cpp11_msgpack_tuple_fwd.hpp"
|
|
||||||
#endif // MSGPACK_USE_CPP03
|
|
||||||
|
|
||||||
#endif // MSGPACK_MSGPACK_TUPLE_FWD_HPP
|
|
@@ -19,11 +19,13 @@
|
|||||||
#define MSGPACK_TYPE_NIL_HPP
|
#define MSGPACK_TYPE_NIL_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
@@ -31,28 +33,40 @@ struct nil { };
|
|||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::nil&)
|
template <>
|
||||||
{
|
struct convert<type::nil> {
|
||||||
if(o.type != msgpack::type::NIL) { throw msgpack::type_error(); }
|
msgpack::object const& operator()(msgpack::object const& o, type::nil&) const {
|
||||||
return o;
|
if(o.type != msgpack::type::NIL) { throw msgpack::type_error(); }
|
||||||
}
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::nil&)
|
struct pack<type::nil> {
|
||||||
{
|
template <typename Stream>
|
||||||
o.pack_nil();
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::nil&) const {
|
||||||
return o;
|
o.pack_nil();
|
||||||
}
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, type::nil)
|
template <>
|
||||||
{
|
struct object<type::nil> {
|
||||||
o.type = msgpack::type::NIL;
|
void operator()(msgpack::object& o, type::nil) const {
|
||||||
}
|
o.type = msgpack::type::NIL;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, type::nil v)
|
template <>
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
struct object_with_zone<type::nil> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, type::nil v) const {
|
||||||
|
static_cast<msgpack::object&>(o) << v;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptror
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline void msgpack::object::as<void>() const
|
inline void msgpack::object::as<void>() const
|
||||||
@@ -61,7 +75,9 @@ inline void msgpack::object::as<void>() const
|
|||||||
convert(v);
|
convert(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -1,51 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2014 FURUHASHI Sadayuki and KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_NIL_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_NIL_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
namespace type {
|
|
||||||
|
|
||||||
struct nil;
|
|
||||||
|
|
||||||
} // namespace type
|
|
||||||
|
|
||||||
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, type::nil&);
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::nil&);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object& o, type::nil);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object::with_zone& o, type::nil v);
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline void msgpack::object::as<void>() const;
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_NIL_FWD_HPP
|
|
@@ -19,44 +19,56 @@
|
|||||||
#define MSGPACK_TYPE_PAIR_HPP
|
#define MSGPACK_TYPE_PAIR_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
template <typename T1, typename T2>
|
template <typename T1, typename T2>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::pair<T1, T2>& v)
|
struct convert<std::pair<T1, T2> > {
|
||||||
{
|
msgpack::object const& operator()(msgpack::object const& o, std::pair<T1, T2>& v) const {
|
||||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||||
if(o.via.array.size != 2) { throw msgpack::type_error(); }
|
if(o.via.array.size != 2) { throw msgpack::type_error(); }
|
||||||
o.via.array.ptr[0].convert(v.first);
|
o.via.array.ptr[0].convert(v.first);
|
||||||
o.via.array.ptr[1].convert(v.second);
|
o.via.array.ptr[1].convert(v.second);
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
template <typename Stream, typename T1, typename T2>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::pair<T1, T2>& v)
|
|
||||||
{
|
|
||||||
o.pack_array(2);
|
|
||||||
o.pack(v.first);
|
|
||||||
o.pack(v.second);
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T1, typename T2>
|
template <typename T1, typename T2>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const std::pair<T1, T2>& v)
|
struct pack<std::pair<T1, T2> > {
|
||||||
{
|
template <typename Stream>
|
||||||
o.type = msgpack::type::ARRAY;
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::pair<T1, T2>& v) const {
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*2));
|
o.pack_array(2);
|
||||||
o.via.array.ptr = p;
|
o.pack(v.first);
|
||||||
o.via.array.size = 2;
|
o.pack(v.second);
|
||||||
p[0] = msgpack::object(v.first, o.zone);
|
return o;
|
||||||
p[1] = msgpack::object(v.second, o.zone);
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
template <typename T1, typename T2>
|
||||||
|
struct object_with_zone<std::pair<T1, T2> > {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const std::pair<T1, T2>& v) const {
|
||||||
|
o.type = msgpack::type::ARRAY;
|
||||||
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*2));
|
||||||
|
o.via.array.ptr = p;
|
||||||
|
o.via.array.size = 2;
|
||||||
|
p[0] = msgpack::object(v.first, o.zone);
|
||||||
|
p[1] = msgpack::object(v.second, o.zone);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -1,42 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_PAIR_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_PAIR_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
template <typename T1, typename T2>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, std::pair<T1, T2>& v);
|
|
||||||
|
|
||||||
template <typename Stream, typename T1, typename T2>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::pair<T1, T2>& v);
|
|
||||||
|
|
||||||
template <typename T1, typename T2>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const std::pair<T1, T2>& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_PAIR_FWD_HPP
|
|
@@ -19,13 +19,15 @@
|
|||||||
#define MSGPACK_TYPE_RAW_HPP
|
#define MSGPACK_TYPE_RAW_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
@@ -61,38 +63,52 @@ struct raw_ref {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, msgpack::type::raw_ref& v)
|
template <>
|
||||||
{
|
struct convert<msgpack::type::raw_ref> {
|
||||||
if(o.type != msgpack::type::BIN) { throw msgpack::type_error(); }
|
msgpack::object const& operator()(msgpack::object const& o, msgpack::type::raw_ref& v) const {
|
||||||
v.ptr = o.via.bin.ptr;
|
if(o.type != msgpack::type::BIN) { throw msgpack::type_error(); }
|
||||||
v.size = o.via.bin.size;
|
v.ptr = o.via.bin.ptr;
|
||||||
return o;
|
v.size = o.via.bin.size;
|
||||||
}
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const msgpack::type::raw_ref& v)
|
struct pack<msgpack::type::raw_ref> {
|
||||||
{
|
template <typename Stream>
|
||||||
o.pack_bin(v.size);
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const msgpack::type::raw_ref& v) const {
|
||||||
o.pack_bin_body(v.ptr, v.size);
|
o.pack_bin(v.size);
|
||||||
return o;
|
o.pack_bin_body(v.ptr, v.size);
|
||||||
}
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, const msgpack::type::raw_ref& v)
|
template <>
|
||||||
{
|
struct object<msgpack::type::raw_ref> {
|
||||||
o.type = msgpack::type::BIN;
|
void operator()(msgpack::object& o, const msgpack::type::raw_ref& v) const {
|
||||||
o.via.bin.ptr = v.ptr;
|
o.type = msgpack::type::BIN;
|
||||||
o.via.bin.size = v.size;
|
o.via.bin.ptr = v.ptr;
|
||||||
}
|
o.via.bin.size = v.size;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const msgpack::type::raw_ref& v)
|
template <>
|
||||||
{ static_cast<msgpack::object&>(o) << v; }
|
struct object_with_zone<msgpack::type::raw_ref> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const msgpack::type::raw_ref& v) const {
|
||||||
|
static_cast<msgpack::object&>(o) << v;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
/// @cond
|
||||||
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_RAW_HPP
|
#endif // MSGPACK_TYPE_RAW_HPP
|
||||||
|
@@ -1,50 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_RAW_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_RAW_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
#include <string.h>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
namespace type {
|
|
||||||
|
|
||||||
struct raw_ref;
|
|
||||||
|
|
||||||
} // namespace type
|
|
||||||
|
|
||||||
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, type::raw_ref& v);
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::raw_ref& v);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object& o, const type::raw_ref& v);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const type::raw_ref& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_RAW_FWD_HPP
|
|
@@ -19,115 +19,130 @@
|
|||||||
#define MSGPACK_TYPE_SET_HPP
|
#define MSGPACK_TYPE_SET_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/adaptor/check_container_size.hpp"
|
#include "msgpack/adaptor/check_container_size.hpp"
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::set<T>& v)
|
struct convert<std::set<T> > {
|
||||||
{
|
msgpack::object const& operator()(msgpack::object const& o, std::set<T>& v) const {
|
||||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||||
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
||||||
msgpack::object* const pbegin = o.via.array.ptr;
|
msgpack::object* const pbegin = o.via.array.ptr;
|
||||||
std::set<T> tmp;
|
std::set<T> tmp;
|
||||||
while(p > pbegin) {
|
while(p > pbegin) {
|
||||||
--p;
|
--p;
|
||||||
tmp.insert(p->as<T>());
|
tmp.insert(p->as<T>());
|
||||||
|
}
|
||||||
|
tmp.swap(v);
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
tmp.swap(v);
|
};
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::set<T>& v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
o.pack_array(size);
|
|
||||||
for(typename std::set<T>::const_iterator it(v.begin()), it_end(v.end());
|
|
||||||
it != it_end; ++it) {
|
|
||||||
o.pack(*it);
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const std::set<T>& v)
|
struct pack<std::set<T> > {
|
||||||
{
|
template <typename Stream>
|
||||||
o.type = msgpack::type::ARRAY;
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::set<T>& v) const {
|
||||||
if(v.empty()) {
|
|
||||||
o.via.array.ptr = nullptr;
|
|
||||||
o.via.array.size = 0;
|
|
||||||
} else {
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
o.pack_array(size);
|
||||||
msgpack::object* const pend = p + size;
|
for(typename std::set<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||||
o.via.array.ptr = p;
|
it != it_end; ++it) {
|
||||||
o.via.array.size = size;
|
o.pack(*it);
|
||||||
typename std::set<T>::const_iterator it(v.begin());
|
}
|
||||||
do {
|
return o;
|
||||||
*p = msgpack::object(*it, o.zone);
|
|
||||||
++p;
|
|
||||||
++it;
|
|
||||||
} while(p < pend);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::multiset<T>& v)
|
struct object_with_zone<std::set<T> > {
|
||||||
{
|
void operator()(msgpack::object::with_zone& o, const std::set<T>& v) const {
|
||||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
o.type = msgpack::type::ARRAY;
|
||||||
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
if(v.empty()) {
|
||||||
msgpack::object* const pbegin = o.via.array.ptr;
|
o.via.array.ptr = nullptr;
|
||||||
std::multiset<T> tmp;
|
o.via.array.size = 0;
|
||||||
while(p > pbegin) {
|
} else {
|
||||||
--p;
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
tmp.insert(p->as<T>());
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||||
|
msgpack::object* const pend = p + size;
|
||||||
|
o.via.array.ptr = p;
|
||||||
|
o.via.array.size = size;
|
||||||
|
typename std::set<T>::const_iterator it(v.begin());
|
||||||
|
do {
|
||||||
|
*p = msgpack::object(*it, o.zone);
|
||||||
|
++p;
|
||||||
|
++it;
|
||||||
|
} while(p < pend);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tmp.swap(v);
|
};
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::multiset<T>& v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
o.pack_array(size);
|
|
||||||
for(typename std::multiset<T>::const_iterator it(v.begin()), it_end(v.end());
|
|
||||||
it != it_end; ++it) {
|
|
||||||
o.pack(*it);
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const std::multiset<T>& v)
|
struct convert<std::multiset<T> > {
|
||||||
{
|
msgpack::object const& operator()(msgpack::object const& o, std::multiset<T>& v) const {
|
||||||
o.type = msgpack::type::ARRAY;
|
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||||
if(v.empty()) {
|
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
||||||
o.via.array.ptr = nullptr;
|
msgpack::object* const pbegin = o.via.array.ptr;
|
||||||
o.via.array.size = 0;
|
std::multiset<T> tmp;
|
||||||
} else {
|
while(p > pbegin) {
|
||||||
|
--p;
|
||||||
|
tmp.insert(p->as<T>());
|
||||||
|
}
|
||||||
|
tmp.swap(v);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct pack<std::multiset<T> > {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::multiset<T>& v) const {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
o.pack_array(size);
|
||||||
msgpack::object* const pend = p + size;
|
for(typename std::multiset<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||||
o.via.array.ptr = p;
|
it != it_end; ++it) {
|
||||||
o.via.array.size = size;
|
o.pack(*it);
|
||||||
typename std::multiset<T>::const_iterator it(v.begin());
|
}
|
||||||
do {
|
return o;
|
||||||
*p = msgpack::object(*it, o.zone);
|
|
||||||
++p;
|
|
||||||
++it;
|
|
||||||
} while(p < pend);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct object_with_zone<std::multiset<T> > {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const std::multiset<T>& v) const {
|
||||||
|
o.type = msgpack::type::ARRAY;
|
||||||
|
if(v.empty()) {
|
||||||
|
o.via.array.ptr = nullptr;
|
||||||
|
o.via.array.size = 0;
|
||||||
|
} else {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||||
|
msgpack::object* const pend = p + size;
|
||||||
|
o.via.array.ptr = p;
|
||||||
|
o.via.array.size = size;
|
||||||
|
typename std::multiset<T>::const_iterator it(v.begin());
|
||||||
|
do {
|
||||||
|
*p = msgpack::object(*it, o.zone);
|
||||||
|
++p;
|
||||||
|
++it;
|
||||||
|
} while(p < pend);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -1,52 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2014 FURUHASHI Sadayuki and KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_SET_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_SET_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
|
|
||||||
#include <set>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, std::set<T>& v);
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::set<T>& v);
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const std::set<T>& v);
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, std::multiset<T>& v);
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::multiset<T>& v);
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const std::multiset<T>& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_SET_FWD_HPP
|
|
@@ -19,59 +19,75 @@
|
|||||||
#define MSGPACK_TYPE_STRING_HPP
|
#define MSGPACK_TYPE_STRING_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/adaptor/check_container_size.hpp"
|
#include "msgpack/adaptor/check_container_size.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::string& v)
|
namespace adaptor {
|
||||||
{
|
|
||||||
switch (o.type) {
|
template <>
|
||||||
case msgpack::type::BIN:
|
struct convert<std::string> {
|
||||||
v.assign(o.via.bin.ptr, o.via.bin.size);
|
msgpack::object const& operator()(msgpack::object const& o, std::string& v) const {
|
||||||
break;
|
switch (o.type) {
|
||||||
case msgpack::type::STR:
|
case msgpack::type::BIN:
|
||||||
v.assign(o.via.str.ptr, o.via.str.size);
|
v.assign(o.via.bin.ptr, o.via.bin.size);
|
||||||
break;
|
break;
|
||||||
default:
|
case msgpack::type::STR:
|
||||||
throw msgpack::type_error();
|
v.assign(o.via.str.ptr, o.via.str.size);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
throw msgpack::type_error();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
return o;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::string& v)
|
struct pack<std::string> {
|
||||||
{
|
template <typename Stream>
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::string& v) const {
|
||||||
o.pack_str(size);
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
o.pack_str_body(v.data(), size);
|
o.pack_str(size);
|
||||||
return o;
|
o.pack_str_body(v.data(), size);
|
||||||
}
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const std::string& v)
|
template <>
|
||||||
{
|
struct object<std::string> {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
void operator()(msgpack::object& o, const std::string& v) const {
|
||||||
o.type = msgpack::type::STR;
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
o.type = msgpack::type::STR;
|
||||||
o.via.str.ptr = ptr;
|
o.via.str.ptr = v.data();
|
||||||
o.via.str.size = size;
|
o.via.str.size = size;
|
||||||
std::memcpy(ptr, v.data(), v.size());
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, const std::string& v)
|
template <>
|
||||||
{
|
struct object_with_zone<std::string> {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
void operator()(msgpack::object::with_zone& o, const std::string& v) const {
|
||||||
o.type = msgpack::type::STR;
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
o.via.str.ptr = v.data();
|
o.type = msgpack::type::STR;
|
||||||
o.via.str.size = size;
|
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
||||||
}
|
o.via.str.ptr = ptr;
|
||||||
|
o.via.str.size = size;
|
||||||
|
std::memcpy(ptr, v.data(), v.size());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -1,42 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2014 FURUHASHI Sadayuki and KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_STRING_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_STRING_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, std::string& v);
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::string& v);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const std::string& v);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object& o, const std::string& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_STRING_FWD_HPP
|
|
@@ -19,7 +19,7 @@
|
|||||||
#define MSGPACK_TYPE_TR1_UNORDERED_MAP_HPP
|
#define MSGPACK_TYPE_TR1_UNORDERED_MAP_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/adaptor/check_container_size.hpp"
|
#include "msgpack/adaptor/check_container_size.hpp"
|
||||||
|
|
||||||
#if defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
#if defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
||||||
@@ -45,117 +45,132 @@
|
|||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
template <typename K, typename V>
|
template <typename K, typename V>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_TR1::unordered_map<K, V>& v)
|
struct convert<MSGPACK_STD_TR1::unordered_map<K, V> > {
|
||||||
{
|
msgpack::object const& operator()(msgpack::object const& o, MSGPACK_STD_TR1::unordered_map<K, V>& v) const {
|
||||||
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||||
msgpack::object_kv* p(o.via.map.ptr);
|
msgpack::object_kv* p(o.via.map.ptr);
|
||||||
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||||
MSGPACK_STD_TR1::unordered_map<K, V> tmp;
|
MSGPACK_STD_TR1::unordered_map<K, V> tmp;
|
||||||
for(; p != pend; ++p) {
|
for(; p != pend; ++p) {
|
||||||
K key;
|
K key;
|
||||||
p->key.convert(key);
|
p->key.convert(key);
|
||||||
p->val.convert(tmp[key]);
|
p->val.convert(tmp[key]);
|
||||||
|
}
|
||||||
|
tmp.swap(v);
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
tmp.swap(v);
|
};
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, typename K, typename V>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_map<K,V>& v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
o.pack_map(size);
|
|
||||||
for(typename MSGPACK_STD_TR1::unordered_map<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
|
||||||
it != it_end; ++it) {
|
|
||||||
o.pack(it->first);
|
|
||||||
o.pack(it->second);
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
template <typename K, typename V>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_map<K,V>& v)
|
struct pack<MSGPACK_STD_TR1::unordered_map<K, V> > {
|
||||||
{
|
template <typename Stream>
|
||||||
o.type = msgpack::type::MAP;
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_map<K,V>& v) const {
|
||||||
if(v.empty()) {
|
|
||||||
o.via.map.ptr = nullptr;
|
|
||||||
o.via.map.size = 0;
|
|
||||||
} else {
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
o.pack_map(size);
|
||||||
msgpack::object_kv* const pend = p + size;
|
for(typename MSGPACK_STD_TR1::unordered_map<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
||||||
o.via.map.ptr = p;
|
it != it_end; ++it) {
|
||||||
o.via.map.size = size;
|
o.pack(it->first);
|
||||||
typename MSGPACK_STD_TR1::unordered_map<K,V>::const_iterator it(v.begin());
|
o.pack(it->second);
|
||||||
do {
|
}
|
||||||
p->key = msgpack::object(it->first, o.zone);
|
return o;
|
||||||
p->val = msgpack::object(it->second, o.zone);
|
|
||||||
++p;
|
|
||||||
++it;
|
|
||||||
} while(p < pend);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
template <typename K, typename V>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_TR1::unordered_multimap<K, V>& v)
|
struct object_with_zone<MSGPACK_STD_TR1::unordered_map<K, V> > {
|
||||||
{
|
void operator()(msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_map<K,V>& v) const {
|
||||||
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
o.type = msgpack::type::MAP;
|
||||||
msgpack::object_kv* p(o.via.map.ptr);
|
if(v.empty()) {
|
||||||
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
o.via.map.ptr = nullptr;
|
||||||
MSGPACK_STD_TR1::unordered_multimap<K, V> tmp;
|
o.via.map.size = 0;
|
||||||
for(; p != pend; ++p) {
|
} else {
|
||||||
std::pair<K, V> value;
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
p->key.convert(value.first);
|
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||||
p->val.convert(value.second);
|
msgpack::object_kv* const pend = p + size;
|
||||||
tmp.insert(value);
|
o.via.map.ptr = p;
|
||||||
|
o.via.map.size = size;
|
||||||
|
typename MSGPACK_STD_TR1::unordered_map<K,V>::const_iterator it(v.begin());
|
||||||
|
do {
|
||||||
|
p->key = msgpack::object(it->first, o.zone);
|
||||||
|
p->val = msgpack::object(it->second, o.zone);
|
||||||
|
++p;
|
||||||
|
++it;
|
||||||
|
} while(p < pend);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tmp.swap(v);
|
};
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, typename K, typename V>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_multimap<K,V>& v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
o.pack_map(size);
|
|
||||||
for(typename MSGPACK_STD_TR1::unordered_multimap<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
|
||||||
it != it_end; ++it) {
|
|
||||||
o.pack(it->first);
|
|
||||||
o.pack(it->second);
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
template <typename K, typename V>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_multimap<K,V>& v)
|
struct convert<MSGPACK_STD_TR1::unordered_multimap<K, V> > {
|
||||||
{
|
msgpack::object const& operator()(msgpack::object const& o, MSGPACK_STD_TR1::unordered_multimap<K, V>& v) const {
|
||||||
o.type = msgpack::type::MAP;
|
if(o.type != msgpack::type::MAP) { throw msgpack::type_error(); }
|
||||||
if(v.empty()) {
|
msgpack::object_kv* p(o.via.map.ptr);
|
||||||
o.via.map.ptr = nullptr;
|
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||||
o.via.map.size = 0;
|
MSGPACK_STD_TR1::unordered_multimap<K, V> tmp;
|
||||||
} else {
|
for(; p != pend; ++p) {
|
||||||
|
std::pair<K, V> value;
|
||||||
|
p->key.convert(value.first);
|
||||||
|
p->val.convert(value.second);
|
||||||
|
tmp.insert(value);
|
||||||
|
}
|
||||||
|
tmp.swap(v);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename K, typename V>
|
||||||
|
struct pack<MSGPACK_STD_TR1::unordered_multimap<K, V> > {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_multimap<K,V>& v) const {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
o.pack_map(size);
|
||||||
msgpack::object_kv* const pend = p + size;
|
for(typename MSGPACK_STD_TR1::unordered_multimap<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
||||||
o.via.map.ptr = p;
|
it != it_end; ++it) {
|
||||||
o.via.map.size = size;
|
o.pack(it->first);
|
||||||
typename MSGPACK_STD_TR1::unordered_multimap<K,V>::const_iterator it(v.begin());
|
o.pack(it->second);
|
||||||
do {
|
}
|
||||||
p->key = msgpack::object(it->first, o.zone);
|
return o;
|
||||||
p->val = msgpack::object(it->second, o.zone);
|
|
||||||
++p;
|
|
||||||
++it;
|
|
||||||
} while(p < pend);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
template <typename K, typename V>
|
||||||
|
struct object_with_zone<MSGPACK_STD_TR1::unordered_multimap<K, V> > {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_multimap<K,V>& v) const {
|
||||||
|
o.type = msgpack::type::MAP;
|
||||||
|
if(v.empty()) {
|
||||||
|
o.via.map.ptr = nullptr;
|
||||||
|
o.via.map.size = 0;
|
||||||
|
} else {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
msgpack::object_kv* p = static_cast<msgpack::object_kv*>(o.zone.allocate_align(sizeof(msgpack::object_kv)*size));
|
||||||
|
msgpack::object_kv* const pend = p + size;
|
||||||
|
o.via.map.ptr = p;
|
||||||
|
o.via.map.size = size;
|
||||||
|
typename MSGPACK_STD_TR1::unordered_multimap<K,V>::const_iterator it(v.begin());
|
||||||
|
do {
|
||||||
|
p->key = msgpack::object(it->first, o.zone);
|
||||||
|
p->val = msgpack::object(it->second, o.zone);
|
||||||
|
++p;
|
||||||
|
++it;
|
||||||
|
} while(p < pend);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
} // namespace msgpack
|
||||||
|
|
||||||
#undef MSGPACK_STD_TR1
|
#undef MSGPACK_STD_TR1
|
||||||
|
|
||||||
|
@@ -1,75 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2014 FURUHASHI Sadayuki and KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_TR1_UNORDERED_MAP_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_TR1_UNORDERED_MAP_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
|
|
||||||
#if defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
|
||||||
|
|
||||||
#define MSGPACK_HAS_STD_UNORDERED_MAP
|
|
||||||
#include <unordered_map>
|
|
||||||
#define MSGPACK_STD_TR1 std
|
|
||||||
|
|
||||||
#else // defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
|
||||||
|
|
||||||
#if __GNUC__ >= 4
|
|
||||||
|
|
||||||
#define MSGPACK_HAS_STD_TR1_UNORDERED_MAP
|
|
||||||
|
|
||||||
#include <tr1/unordered_map>
|
|
||||||
#define MSGPACK_STD_TR1 std::tr1
|
|
||||||
|
|
||||||
#endif // __GNUC__ >= 4
|
|
||||||
|
|
||||||
#endif // defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
|
||||||
|
|
||||||
#if defined(MSGPACK_STD_TR1)
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_TR1::unordered_map<K, V>& v);
|
|
||||||
|
|
||||||
template <typename Stream, typename K, typename V>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_map<K,V>& v);
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_map<K,V>& v);
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_TR1::unordered_multimap<K, V>& v);
|
|
||||||
|
|
||||||
template <typename Stream, typename K, typename V>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_multimap<K,V>& v);
|
|
||||||
|
|
||||||
template <typename K, typename V>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_multimap<K,V>& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#undef MSGPACK_STD_TR1
|
|
||||||
|
|
||||||
#endif // MSGPACK_STD_TR1
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_TR1_UNORDERED_MAP_FWD_HPP
|
|
@@ -19,7 +19,7 @@
|
|||||||
#define MSGPACK_TYPE_TR1_UNORDERED_SET_HPP
|
#define MSGPACK_TYPE_TR1_UNORDERED_SET_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/adaptor/check_container_size.hpp"
|
#include "msgpack/adaptor/check_container_size.hpp"
|
||||||
|
|
||||||
#if defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
#if defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
||||||
@@ -45,110 +45,126 @@
|
|||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_TR1::unordered_set<T>& v)
|
struct convert<MSGPACK_STD_TR1::unordered_set<T> > {
|
||||||
{
|
msgpack::object const& operator()(msgpack::object const& o, MSGPACK_STD_TR1::unordered_set<T>& v) const {
|
||||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||||
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
||||||
msgpack::object* const pbegin = o.via.array.ptr;
|
msgpack::object* const pbegin = o.via.array.ptr;
|
||||||
MSGPACK_STD_TR1::unordered_set<T> tmp;
|
MSGPACK_STD_TR1::unordered_set<T> tmp;
|
||||||
while(p > pbegin) {
|
while(p > pbegin) {
|
||||||
--p;
|
--p;
|
||||||
tmp.insert(p->as<T>());
|
tmp.insert(p->as<T>());
|
||||||
|
}
|
||||||
|
tmp.swap(v);
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
tmp.swap(v);
|
};
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_set<T>& v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
o.pack_array(size);
|
|
||||||
for(typename MSGPACK_STD_TR1::unordered_set<T>::const_iterator it(v.begin()), it_end(v.end());
|
|
||||||
it != it_end; ++it) {
|
|
||||||
o.pack(*it);
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_set<T>& v)
|
struct pack<MSGPACK_STD_TR1::unordered_set<T> > {
|
||||||
{
|
template <typename Stream>
|
||||||
o.type = msgpack::type::ARRAY;
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_set<T>& v) const {
|
||||||
if(v.empty()) {
|
|
||||||
o.via.array.ptr = nullptr;
|
|
||||||
o.via.array.size = 0;
|
|
||||||
} else {
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
o.pack_array(size);
|
||||||
msgpack::object* const pend = p + size;
|
for(typename MSGPACK_STD_TR1::unordered_set<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||||
o.via.array.ptr = p;
|
|
||||||
o.via.array.size = size;
|
|
||||||
typename MSGPACK_STD_TR1::unordered_set<T>::const_iterator it(v.begin());
|
|
||||||
do {
|
|
||||||
*p = msgpack::object(*it, o.zone);
|
|
||||||
++p;
|
|
||||||
++it;
|
|
||||||
} while(p < pend);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_TR1::unordered_multiset<T>& v)
|
|
||||||
{
|
|
||||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
|
||||||
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
|
||||||
msgpack::object* const pbegin = o.via.array.ptr;
|
|
||||||
MSGPACK_STD_TR1::unordered_multiset<T> tmp;
|
|
||||||
while(p > pbegin) {
|
|
||||||
--p;
|
|
||||||
tmp.insert(p->as<T>());
|
|
||||||
}
|
|
||||||
tmp.swap(v);
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_multiset<T>& v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
o.pack_array(size);
|
|
||||||
for(typename MSGPACK_STD_TR1::unordered_multiset<T>::const_iterator it(v.begin()), it_end(v.end());
|
|
||||||
it != it_end; ++it) {
|
it != it_end; ++it) {
|
||||||
o.pack(*it);
|
o.pack(*it);
|
||||||
|
}
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
return o;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_multiset<T>& v)
|
struct object_with_zone<MSGPACK_STD_TR1::unordered_set<T> > {
|
||||||
{
|
void operator()(msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_set<T>& v) const {
|
||||||
o.type = msgpack::type::ARRAY;
|
o.type = msgpack::type::ARRAY;
|
||||||
if(v.empty()) {
|
if(v.empty()) {
|
||||||
o.via.array.ptr = nullptr;
|
o.via.array.ptr = nullptr;
|
||||||
o.via.array.size = 0;
|
o.via.array.size = 0;
|
||||||
} else {
|
} else {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||||
msgpack::object* const pend = p + size;
|
msgpack::object* const pend = p + size;
|
||||||
o.via.array.ptr = p;
|
o.via.array.ptr = p;
|
||||||
o.via.array.size = size;
|
o.via.array.size = size;
|
||||||
typename MSGPACK_STD_TR1::unordered_multiset<T>::const_iterator it(v.begin());
|
typename MSGPACK_STD_TR1::unordered_set<T>::const_iterator it(v.begin());
|
||||||
do {
|
do {
|
||||||
*p = msgpack::object(*it, o.zone);
|
*p = msgpack::object(*it, o.zone);
|
||||||
++p;
|
++p;
|
||||||
++it;
|
++it;
|
||||||
} while(p < pend);
|
} while(p < pend);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
template <typename T>
|
||||||
|
struct convert<MSGPACK_STD_TR1::unordered_multiset<T> > {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, MSGPACK_STD_TR1::unordered_multiset<T>& v) const {
|
||||||
|
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||||
|
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
||||||
|
msgpack::object* const pbegin = o.via.array.ptr;
|
||||||
|
MSGPACK_STD_TR1::unordered_multiset<T> tmp;
|
||||||
|
while(p > pbegin) {
|
||||||
|
--p;
|
||||||
|
tmp.insert(p->as<T>());
|
||||||
|
}
|
||||||
|
tmp.swap(v);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct pack<MSGPACK_STD_TR1::unordered_multiset<T> > {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_multiset<T>& v) const {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
o.pack_array(size);
|
||||||
|
for(typename MSGPACK_STD_TR1::unordered_multiset<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||||
|
it != it_end; ++it) {
|
||||||
|
o.pack(*it);
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct object_with_zone<MSGPACK_STD_TR1::unordered_multiset<T> > {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_multiset<T>& v) const {
|
||||||
|
o.type = msgpack::type::ARRAY;
|
||||||
|
if(v.empty()) {
|
||||||
|
o.via.array.ptr = nullptr;
|
||||||
|
o.via.array.size = 0;
|
||||||
|
} else {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||||
|
msgpack::object* const pend = p + size;
|
||||||
|
o.via.array.ptr = p;
|
||||||
|
o.via.array.size = size;
|
||||||
|
typename MSGPACK_STD_TR1::unordered_multiset<T>::const_iterator it(v.begin());
|
||||||
|
do {
|
||||||
|
*p = msgpack::object(*it, o.zone);
|
||||||
|
++p;
|
||||||
|
++it;
|
||||||
|
} while(p < pend);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
} // namespace msgpack
|
||||||
|
|
||||||
#undef MSGPACK_STD_TR1
|
#undef MSGPACK_STD_TR1
|
||||||
|
|
||||||
|
@@ -1,75 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_TR1_UNORDERED_SET_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_TR1_UNORDERED_SET_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
|
|
||||||
#if defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
|
||||||
|
|
||||||
#define MSGPACK_HAS_STD_UNORDERED_SET
|
|
||||||
#include <unordered_set>
|
|
||||||
#define MSGPACK_STD_TR1 std
|
|
||||||
|
|
||||||
#else // defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
|
||||||
|
|
||||||
#if __GNUC__ >= 4
|
|
||||||
|
|
||||||
#define MSGPACK_HAS_STD_TR1_UNORDERED_SET
|
|
||||||
|
|
||||||
#include <tr1/unordered_set>
|
|
||||||
#define MSGPACK_STD_TR1 std::tr1
|
|
||||||
|
|
||||||
#endif // __GNUC__ >= 4
|
|
||||||
|
|
||||||
#endif // defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
|
||||||
|
|
||||||
#if defined(MSGPACK_STD_TR1)
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_TR1::unordered_set<T>& v);
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_set<T>& v);
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_set<T>& v);
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_TR1::unordered_multiset<T>& v);
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_multiset<T>& v);
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_multiset<T>& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#undef MSGPACK_STD_TR1
|
|
||||||
|
|
||||||
#endif // MSGPACK_STD_TR1
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_TR1_UNORDERED_SET_FWD_HPP
|
|
@@ -19,69 +19,81 @@
|
|||||||
#define MSGPACK_TYPE_VECTOR_HPP
|
#define MSGPACK_TYPE_VECTOR_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/adaptor/check_container_size.hpp"
|
#include "msgpack/adaptor/check_container_size.hpp"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::vector<T>& v)
|
struct convert<std::vector<T> > {
|
||||||
{
|
msgpack::object const& operator()(msgpack::object const& o, std::vector<T>& v) const {
|
||||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||||
v.resize(o.via.array.size);
|
v.resize(o.via.array.size);
|
||||||
if(o.via.array.size > 0) {
|
if(o.via.array.size > 0) {
|
||||||
msgpack::object* p = o.via.array.ptr;
|
msgpack::object* p = o.via.array.ptr;
|
||||||
msgpack::object* const pend = o.via.array.ptr + o.via.array.size;
|
msgpack::object* const pend = o.via.array.ptr + o.via.array.size;
|
||||||
T* it = &v[0];
|
typename std::vector<T>::iterator it = v.begin();
|
||||||
do {
|
do {
|
||||||
p->convert(*it);
|
p->convert(*it);
|
||||||
++p;
|
++p;
|
||||||
++it;
|
++it;
|
||||||
} while(p < pend);
|
} while(p < pend);
|
||||||
|
}
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
return o;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::vector<T>& v)
|
|
||||||
{
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
|
||||||
o.pack_array(size);
|
|
||||||
for(typename std::vector<T>::const_iterator it(v.begin()), it_end(v.end());
|
|
||||||
it != it_end; ++it) {
|
|
||||||
o.pack(*it);
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const std::vector<T>& v)
|
struct pack<std::vector<T> > {
|
||||||
{
|
template <typename Stream>
|
||||||
o.type = msgpack::type::ARRAY;
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::vector<T>& v) const {
|
||||||
if(v.empty()) {
|
|
||||||
o.via.array.ptr = nullptr;
|
|
||||||
o.via.array.size = 0;
|
|
||||||
} else {
|
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
o.pack_array(size);
|
||||||
msgpack::object* const pend = p + size;
|
for(typename std::vector<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||||
o.via.array.ptr = p;
|
it != it_end; ++it) {
|
||||||
o.via.array.size = size;
|
o.pack(*it);
|
||||||
typename std::vector<T>::const_iterator it(v.begin());
|
}
|
||||||
do {
|
return o;
|
||||||
*p = msgpack::object(*it, o.zone);
|
|
||||||
++p;
|
|
||||||
++it;
|
|
||||||
} while(p < pend);
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
template <typename T>
|
||||||
|
struct object_with_zone<std::vector<T> > {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const std::vector<T>& v) const {
|
||||||
|
o.type = msgpack::type::ARRAY;
|
||||||
|
if(v.empty()) {
|
||||||
|
o.via.array.ptr = nullptr;
|
||||||
|
o.via.array.size = 0;
|
||||||
|
} else {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||||
|
msgpack::object* const pend = p + size;
|
||||||
|
o.via.array.ptr = p;
|
||||||
|
o.via.array.size = size;
|
||||||
|
typename std::vector<T>::const_iterator it(v.begin());
|
||||||
|
do {
|
||||||
|
*p = msgpack::object(*it, o.zone);
|
||||||
|
++p;
|
||||||
|
++it;
|
||||||
|
} while(p < pend);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace adaptor
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
} // namespace msgpack
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_VECTOR_HPP
|
#endif // MSGPACK_TYPE_VECTOR_HPP
|
||||||
|
@@ -24,56 +24,72 @@
|
|||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::vector<bool>& v)
|
namespace adaptor {
|
||||||
{
|
|
||||||
if (o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
template <>
|
||||||
if (o.via.array.size > 0) {
|
struct convert<std::vector<bool> > {
|
||||||
v.resize(o.via.array.size);
|
msgpack::object const& operator()(msgpack::object const& o, std::vector<bool>& v) const {
|
||||||
msgpack::object* p = o.via.array.ptr;
|
if (o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||||
for (std::vector<bool>::iterator it = v.begin(), end = v.end();
|
if (o.via.array.size > 0) {
|
||||||
it != end;
|
v.resize(o.via.array.size);
|
||||||
++it) {
|
msgpack::object* p = o.via.array.ptr;
|
||||||
*it = p->as<bool>();
|
for (std::vector<bool>::iterator it = v.begin(), end = v.end();
|
||||||
++p;
|
it != end;
|
||||||
|
++it) {
|
||||||
|
*it = p->as<bool>();
|
||||||
|
++p;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct pack<std::vector<bool> > {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::vector<bool>& v) const {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
o.pack_array(size);
|
||||||
|
for(std::vector<bool>::const_iterator it(v.begin()), it_end(v.end());
|
||||||
|
it != it_end; ++it) {
|
||||||
|
o.pack(static_cast<bool>(*it));
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct object_with_zone<std::vector<bool> > {
|
||||||
|
void operator()(msgpack::object::with_zone& o, const std::vector<bool>& v) const {
|
||||||
|
o.type = msgpack::type::ARRAY;
|
||||||
|
if(v.empty()) {
|
||||||
|
o.via.array.ptr = nullptr;
|
||||||
|
o.via.array.size = 0;
|
||||||
|
} else {
|
||||||
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
|
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*size));
|
||||||
|
msgpack::object* const pend = p + size;
|
||||||
|
o.via.array.ptr = p;
|
||||||
|
o.via.array.size = size;
|
||||||
|
std::vector<bool>::const_iterator it(v.begin());
|
||||||
|
do {
|
||||||
|
*p = msgpack::object(static_cast<bool>(*it), o.zone);
|
||||||
|
++p;
|
||||||
|
++it;
|
||||||
|
} while(p < pend);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return o;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream>
|
} // namespace adaptor
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::vector<bool>& v)
|
|
||||||
{
|
|
||||||
o.pack_array(v.size());
|
|
||||||
for(std::vector<bool>::const_iterator it(v.begin()), it_end(v.end());
|
|
||||||
it != it_end; ++it) {
|
|
||||||
o.pack(static_cast<bool>(*it));
|
|
||||||
}
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const std::vector<bool>& v)
|
|
||||||
{
|
|
||||||
o.type = msgpack::type::ARRAY;
|
|
||||||
if(v.empty()) {
|
|
||||||
o.via.array.ptr = nullptr;
|
|
||||||
o.via.array.size = 0;
|
|
||||||
} else {
|
|
||||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*v.size()));
|
|
||||||
msgpack::object* const pend = p + v.size();
|
|
||||||
o.via.array.ptr = p;
|
|
||||||
o.via.array.size = v.size();
|
|
||||||
std::vector<bool>::const_iterator it(v.begin());
|
|
||||||
do {
|
|
||||||
*p = object(static_cast<bool>(*it), o.zone);
|
|
||||||
++p;
|
|
||||||
++it;
|
|
||||||
} while(p < pend);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -1,40 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2015 KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_VECTOR_BOOL_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_VECTOR_BOOL_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
object const& operator>> (object const& o, std::vector<bool>& v);
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
packer<Stream>& operator<< (packer<Stream>& o, const std::vector<bool>& v);
|
|
||||||
|
|
||||||
void operator<< (object::with_zone& o, const std::vector<bool>& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_VECTOR_BOOL_FWD_HPP
|
|
@@ -19,63 +19,79 @@
|
|||||||
#define MSGPACK_TYPE_VECTOR_CHAR_HPP
|
#define MSGPACK_TYPE_VECTOR_CHAR_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/adaptor/check_container_size.hpp"
|
#include "msgpack/adaptor/check_container_size.hpp"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::vector<char>& v)
|
namespace adaptor {
|
||||||
{
|
|
||||||
switch (o.type) {
|
template <>
|
||||||
case msgpack::type::BIN:
|
struct convert<std::vector<char> > {
|
||||||
v.resize(o.via.bin.size);
|
msgpack::object const& operator()(msgpack::object const& o, std::vector<char>& v) const {
|
||||||
std::memcpy(&v.front(), o.via.bin.ptr, o.via.bin.size);
|
switch (o.type) {
|
||||||
break;
|
case msgpack::type::BIN:
|
||||||
case msgpack::type::STR:
|
v.resize(o.via.bin.size);
|
||||||
v.resize(o.via.str.size);
|
std::memcpy(&v.front(), o.via.bin.ptr, o.via.bin.size);
|
||||||
std::memcpy(&v.front(), o.via.str.ptr, o.via.str.size);
|
break;
|
||||||
break;
|
case msgpack::type::STR:
|
||||||
default:
|
v.resize(o.via.str.size);
|
||||||
throw msgpack::type_error();
|
std::memcpy(&v.front(), o.via.str.ptr, o.via.str.size);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
throw msgpack::type_error();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return o;
|
||||||
}
|
}
|
||||||
return o;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream>
|
template <>
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::vector<char>& v)
|
struct pack<std::vector<char> > {
|
||||||
{
|
template <typename Stream>
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::vector<char>& v) const {
|
||||||
o.pack_bin(size);
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
o.pack_bin_body(&v.front(), size);
|
o.pack_bin(size);
|
||||||
|
o.pack_bin_body(&v.front(), size);
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object& o, const std::vector<char>& v)
|
template <>
|
||||||
{
|
struct object<std::vector<char> > {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
void operator()(msgpack::object& o, const std::vector<char>& v) const {
|
||||||
o.type = msgpack::type::BIN;
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
o.via.bin.ptr = &v.front();
|
o.type = msgpack::type::BIN;
|
||||||
o.via.bin.size = size;
|
o.via.bin.ptr = &v.front();
|
||||||
}
|
o.via.bin.size = size;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const std::vector<char>& v)
|
template <>
|
||||||
{
|
struct object_with_zone<std::vector<char> > {
|
||||||
uint32_t size = checked_get_container_size(v.size());
|
void operator()(msgpack::object::with_zone& o, const std::vector<char>& v) const {
|
||||||
o.type = msgpack::type::BIN;
|
uint32_t size = checked_get_container_size(v.size());
|
||||||
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
o.type = msgpack::type::BIN;
|
||||||
o.via.bin.ptr = ptr;
|
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
||||||
o.via.bin.size = size;
|
o.via.bin.ptr = ptr;
|
||||||
std::memcpy(ptr, &v.front(), size);
|
o.via.bin.size = size;
|
||||||
}
|
std::memcpy(ptr, &v.front(), size);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // namespace adaptor
|
||||||
|
|
||||||
} // namespace msgpack
|
/// @cond
|
||||||
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
} // namespace msgpack
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_VECTOR_CHAR_HPP
|
#endif // MSGPACK_TYPE_VECTOR_CHAR_HPP
|
||||||
|
@@ -1,42 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2014 KONDO Takatoshi
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_VECTOR_CHAR_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_VECTOR_CHAR_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, std::vector<char>& v);
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::vector<char>& v);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object& o, const std::vector<char>& v);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const std::vector<char>& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_VECTOR_CHAR_FWD_HPP
|
|
@@ -1,42 +0,0 @@
|
|||||||
//
|
|
||||||
// MessagePack for C++ static resolution routine
|
|
||||||
//
|
|
||||||
// Copyright (C) 2008-2009 FURUHASHI Sadayuki
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
//
|
|
||||||
#ifndef MSGPACK_TYPE_VECTOR_FWD_HPP
|
|
||||||
#define MSGPACK_TYPE_VECTOR_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace msgpack {
|
|
||||||
|
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, std::vector<T>& v);
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::vector<T>& v);
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const std::vector<T>& v);
|
|
||||||
|
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
|
||||||
|
|
||||||
} // namespace msgpack
|
|
||||||
|
|
||||||
#endif // MSGPACK_TYPE_VECTOR_FWD_HPP
|
|
@@ -44,7 +44,9 @@
|
|||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct unique_ptr : std::auto_ptr<T> {
|
struct unique_ptr : std::auto_ptr<T> {
|
||||||
@@ -75,7 +77,9 @@ template <typename T>
|
|||||||
struct enable_if<false, T> {
|
struct enable_if<false, T> {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
@@ -86,7 +90,9 @@ struct enable_if<false, T> {
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
// unique_ptr
|
// unique_ptr
|
||||||
using std::unique_ptr;
|
using std::unique_ptr;
|
||||||
@@ -98,7 +104,9 @@ MSGPACK_API_VERSION_NAMESPACE(v1) {
|
|||||||
using std::swap;
|
using std::swap;
|
||||||
using std::enable_if;
|
using std::enable_if;
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
|
||||||
|
@@ -35,7 +35,9 @@
|
|||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
class zone {
|
class zone {
|
||||||
struct finalizer {
|
struct finalizer {
|
||||||
@@ -179,6 +181,7 @@ public:
|
|||||||
{
|
{
|
||||||
::operator delete(p, place);
|
::operator delete(p, place);
|
||||||
}
|
}
|
||||||
|
/// @cond
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T* allocate();
|
T* allocate();
|
||||||
@@ -228,6 +231,7 @@ public:
|
|||||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15>
|
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15>
|
||||||
T* allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12, A13 a13, A14 a14, A15 a15);
|
T* allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12, A13 a13, A14 a14, A15 a15);
|
||||||
|
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void undo_allocate(size_t size);
|
void undo_allocate(size_t size);
|
||||||
@@ -349,6 +353,7 @@ inline void zone::undo_allocate(size_t size)
|
|||||||
m_chunk_list.m_free += size;
|
m_chunk_list.m_free += size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @cond
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T* zone::allocate()
|
T* zone::allocate()
|
||||||
@@ -654,8 +659,11 @@ T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -36,7 +36,9 @@
|
|||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
class zone {
|
class zone {
|
||||||
private:
|
private:
|
||||||
@@ -361,7 +363,9 @@ T* zone::allocate(Args... args)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -25,7 +25,9 @@
|
|||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
class fbuffer {
|
class fbuffer {
|
||||||
public:
|
public:
|
||||||
@@ -57,7 +59,9 @@ private:
|
|||||||
FILE* m_file;
|
FILE* m_file;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -20,12 +20,14 @@
|
|||||||
#define MSGPACK_ITERATOR_HPP
|
#define MSGPACK_ITERATOR_HPP
|
||||||
#if !defined(MSGPACK_USE_CPP03)
|
#if !defined(MSGPACK_USE_CPP03)
|
||||||
|
|
||||||
#include <msgpack_fwd.hpp>
|
#include <msgpack/object_fwd.hpp>
|
||||||
|
|
||||||
namespace msgpack
|
namespace msgpack
|
||||||
{
|
{
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
||||||
{
|
{
|
||||||
|
/// @endcond
|
||||||
inline object_kv* begin(object_map &map) { return map.ptr; }
|
inline object_kv* begin(object_map &map) { return map.ptr; }
|
||||||
inline const object_kv* begin(const object_map &map) { return map.ptr; }
|
inline const object_kv* begin(const object_map &map) { return map.ptr; }
|
||||||
inline object_kv* end(object_map &map) { return map.ptr + map.size; }
|
inline object_kv* end(object_map &map) { return map.ptr + map.size; }
|
||||||
@@ -35,7 +37,9 @@ namespace msgpack
|
|||||||
inline const object* begin(const object_array &array) { return array.ptr; }
|
inline const object* begin(const object_array &array) { return array.ptr; }
|
||||||
inline object* end(object_array &array) { return array.ptr + array.size; }
|
inline object* end(object_array &array) { return array.ptr + array.size; }
|
||||||
inline const object* end(const object_array &array) { return array.ptr + array.size; }
|
inline const object* end(const object_array &array) { return array.ptr + array.size; }
|
||||||
|
/// @cond
|
||||||
}
|
}
|
||||||
|
/// @endcond
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !defined(MSGPACK_USE_CPP03)
|
#endif // !defined(MSGPACK_USE_CPP03)
|
||||||
|
@@ -19,60 +19,22 @@
|
|||||||
#define MSGPACK_OBJECT_HPP
|
#define MSGPACK_OBJECT_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
#include "msgpack/pack.hpp"
|
#include "msgpack/pack.hpp"
|
||||||
#include "msgpack/zone.hpp"
|
#include "msgpack/zone.hpp"
|
||||||
#include "msgpack/adaptor/int_fwd.hpp"
|
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||||
#include "msgpack/adaptor/bool_fwd.hpp"
|
|
||||||
#include "msgpack/adaptor/char_ptr_fwd.hpp"
|
|
||||||
#include "msgpack/adaptor/deque_fwd.hpp"
|
|
||||||
#include "msgpack/adaptor/fixint_fwd.hpp"
|
|
||||||
#include "msgpack/adaptor/float_fwd.hpp"
|
|
||||||
#include "msgpack/adaptor/int_fwd.hpp"
|
|
||||||
#include "msgpack/adaptor/list_fwd.hpp"
|
|
||||||
#include "msgpack/adaptor/map_fwd.hpp"
|
|
||||||
#include "msgpack/adaptor/msgpack_tuple_fwd.hpp"
|
|
||||||
#include "msgpack/adaptor/nil_fwd.hpp"
|
|
||||||
#include "msgpack/adaptor/pair_fwd.hpp"
|
|
||||||
#include "msgpack/adaptor/raw_fwd.hpp"
|
|
||||||
#include "msgpack/adaptor/set_fwd.hpp"
|
|
||||||
#include "msgpack/adaptor/string_fwd.hpp"
|
|
||||||
#include "msgpack/adaptor/vector_fwd.hpp"
|
|
||||||
#include "msgpack/adaptor/vector_bool_fwd.hpp"
|
|
||||||
#include "msgpack/adaptor/vector_char_fwd.hpp"
|
|
||||||
|
|
||||||
#if defined(MSGPACK_USE_CPP03)
|
#include <cstring>
|
||||||
|
|
||||||
#include "msgpack/adaptor/tr1/unordered_map_fwd.hpp"
|
|
||||||
#include "msgpack/adaptor/tr1/unordered_set_fwd.hpp"
|
|
||||||
|
|
||||||
#else // defined(MSGPACK_USE_CPP03)
|
|
||||||
|
|
||||||
#include "adaptor/cpp11/array_fwd.hpp"
|
|
||||||
#include "adaptor/cpp11/array_char_fwd.hpp"
|
|
||||||
#include "adaptor/cpp11/forward_list_fwd.hpp"
|
|
||||||
#include "adaptor/cpp11/tuple_fwd.hpp"
|
|
||||||
#include "adaptor/cpp11/unordered_map_fwd.hpp"
|
|
||||||
#include "adaptor/cpp11/unordered_set_fwd.hpp"
|
|
||||||
|
|
||||||
#endif // defined(MSGPACK_USE_CPP03)
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
#include <typeinfo>
|
||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
struct object::with_zone : object {
|
|
||||||
with_zone(msgpack::zone& zone) : zone(zone) { }
|
|
||||||
msgpack::zone& zone;
|
|
||||||
private:
|
|
||||||
with_zone();
|
|
||||||
};
|
|
||||||
|
|
||||||
struct object::implicit_type {
|
struct object::implicit_type {
|
||||||
implicit_type(object const& o) : obj(o) { }
|
implicit_type(object const& o) : obj(o) { }
|
||||||
@@ -85,49 +47,208 @@ private:
|
|||||||
msgpack::object const& obj;
|
msgpack::object const& obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, msgpack::object& v)
|
namespace detail {
|
||||||
{
|
template <typename Stream, typename T>
|
||||||
v = o;
|
struct packer_serializer {
|
||||||
|
static msgpack::packer<Stream>& pack(msgpack::packer<Stream>& o, const T& v) {
|
||||||
|
v.msgpack_pack(o);
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
// Adaptor functors' member functions definitions.
|
||||||
|
template <typename T>
|
||||||
|
inline
|
||||||
|
msgpack::object const&
|
||||||
|
msgpack::adaptor::convert<T>::operator()(msgpack::object const& o, T& v) const {
|
||||||
|
v.msgpack_unpack(o.convert());
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline msgpack::object const& operator>> (msgpack::object const& o, T& v)
|
template <typename Stream>
|
||||||
{
|
inline
|
||||||
// If you get a error 'class your_class has no member named 'msgpack_unpack',
|
msgpack::packer<Stream>&
|
||||||
// check the following:
|
msgpack::adaptor::pack<T>::operator()(msgpack::packer<Stream>& o, T const& v) const {
|
||||||
// 1. The class your_class should have MSGPACK_DEFINE macro or
|
return detail::packer_serializer<Stream, T>::pack(o, v);
|
||||||
//
|
|
||||||
// 2. The class your_class should have the following operator declaration and
|
|
||||||
// definition:
|
|
||||||
// inline object const& operator>> (object const& o, std::string& v)
|
|
||||||
//
|
|
||||||
// See 3.
|
|
||||||
//
|
|
||||||
// 3. #include "msgpack.hpp" too early.
|
|
||||||
// Replace msgpack.hpp with msgpack_fwd.hpp, then,
|
|
||||||
// place operator declarations as follows:
|
|
||||||
//
|
|
||||||
// namespace msgpack {
|
|
||||||
// MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
|
||||||
// object const& operator>> (object const& o, std::string& v);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// then, #include "msgpack.hpp", finally place the operator definitions as follows:
|
|
||||||
//
|
|
||||||
// namespace msgpack {
|
|
||||||
// MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
|
||||||
// object const& operator>> (object const& o, std::string& v) {
|
|
||||||
// // converting operations here
|
|
||||||
// }
|
|
||||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
|
||||||
// } // namespace msgpack
|
|
||||||
//
|
|
||||||
v.msgpack_unpack(o.convert());
|
|
||||||
return o;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline
|
||||||
|
void
|
||||||
|
msgpack::adaptor::object_with_zone<T>::operator()(msgpack::object::with_zone& o, T const& v) const {
|
||||||
|
v.msgpack_object(static_cast<msgpack::object*>(&o), o.zone);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adaptor functor specialization to object
|
||||||
|
namespace adaptor {
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct convert<msgpack::object> {
|
||||||
|
msgpack::object const& operator()(msgpack::object const& o, msgpack::object& v) const {
|
||||||
|
v = o;
|
||||||
|
return o;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct pack<msgpack::object> {
|
||||||
|
template <typename Stream>
|
||||||
|
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, msgpack::object const& v) const {
|
||||||
|
switch(v.type) {
|
||||||
|
case msgpack::type::NIL:
|
||||||
|
o.pack_nil();
|
||||||
|
return o;
|
||||||
|
|
||||||
|
case msgpack::type::BOOLEAN:
|
||||||
|
if(v.via.boolean) {
|
||||||
|
o.pack_true();
|
||||||
|
} else {
|
||||||
|
o.pack_false();
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
|
||||||
|
case msgpack::type::POSITIVE_INTEGER:
|
||||||
|
o.pack_uint64(v.via.u64);
|
||||||
|
return o;
|
||||||
|
|
||||||
|
case msgpack::type::NEGATIVE_INTEGER:
|
||||||
|
o.pack_int64(v.via.i64);
|
||||||
|
return o;
|
||||||
|
|
||||||
|
case msgpack::type::FLOAT:
|
||||||
|
o.pack_double(v.via.f64);
|
||||||
|
return o;
|
||||||
|
|
||||||
|
case msgpack::type::STR:
|
||||||
|
o.pack_str(v.via.str.size);
|
||||||
|
o.pack_str_body(v.via.str.ptr, v.via.str.size);
|
||||||
|
return o;
|
||||||
|
|
||||||
|
case msgpack::type::BIN:
|
||||||
|
o.pack_bin(v.via.bin.size);
|
||||||
|
o.pack_bin_body(v.via.bin.ptr, v.via.bin.size);
|
||||||
|
return o;
|
||||||
|
|
||||||
|
case msgpack::type::EXT:
|
||||||
|
o.pack_ext(v.via.ext.size, v.via.ext.type());
|
||||||
|
o.pack_ext_body(v.via.ext.data(), v.via.ext.size);
|
||||||
|
return o;
|
||||||
|
|
||||||
|
case msgpack::type::ARRAY:
|
||||||
|
o.pack_array(v.via.array.size);
|
||||||
|
for(msgpack::object* p(v.via.array.ptr),
|
||||||
|
* const pend(v.via.array.ptr + v.via.array.size);
|
||||||
|
p < pend; ++p) {
|
||||||
|
msgpack::operator<<(o, *p);
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
|
||||||
|
case msgpack::type::MAP:
|
||||||
|
o.pack_map(v.via.map.size);
|
||||||
|
for(msgpack::object_kv* p(v.via.map.ptr),
|
||||||
|
* const pend(v.via.map.ptr + v.via.map.size);
|
||||||
|
p < pend; ++p) {
|
||||||
|
msgpack::operator<<(o, p->key);
|
||||||
|
msgpack::operator<<(o, p->val);
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw msgpack::type_error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct object_with_zone<msgpack::object> {
|
||||||
|
void operator()(msgpack::object::with_zone& o, msgpack::object const& v) const {
|
||||||
|
o.type = v.type;
|
||||||
|
|
||||||
|
switch(v.type) {
|
||||||
|
case msgpack::type::NIL:
|
||||||
|
case msgpack::type::BOOLEAN:
|
||||||
|
case msgpack::type::POSITIVE_INTEGER:
|
||||||
|
case msgpack::type::NEGATIVE_INTEGER:
|
||||||
|
case msgpack::type::FLOAT:
|
||||||
|
std::memcpy(&o.via, &v.via, sizeof(v.via));
|
||||||
|
return;
|
||||||
|
|
||||||
|
case msgpack::type::STR: {
|
||||||
|
char* ptr = static_cast<char*>(o.zone.allocate_align(v.via.str.size));
|
||||||
|
o.via.str.ptr = ptr;
|
||||||
|
o.via.str.size = v.via.str.size;
|
||||||
|
std::memcpy(ptr, v.via.str.ptr, v.via.str.size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
case msgpack::type::BIN: {
|
||||||
|
char* ptr = static_cast<char*>(o.zone.allocate_align(v.via.bin.size));
|
||||||
|
o.via.bin.ptr = ptr;
|
||||||
|
o.via.bin.size = v.via.bin.size;
|
||||||
|
std::memcpy(ptr, v.via.bin.ptr, v.via.bin.size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
case msgpack::type::EXT: {
|
||||||
|
char* ptr = static_cast<char*>(o.zone.allocate_align(v.via.ext.size + 1));
|
||||||
|
o.via.ext.ptr = ptr;
|
||||||
|
o.via.ext.size = v.via.ext.size;
|
||||||
|
std::memcpy(ptr, v.via.ext.ptr, v.via.ext.size + 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
case msgpack::type::ARRAY:
|
||||||
|
o.via.array.ptr = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object) * v.via.array.size));
|
||||||
|
o.via.array.size = v.via.array.size;
|
||||||
|
for (msgpack::object
|
||||||
|
* po(o.via.array.ptr),
|
||||||
|
* pv(v.via.array.ptr),
|
||||||
|
* const pvend(v.via.array.ptr + v.via.array.size);
|
||||||
|
pv < pvend;
|
||||||
|
++po, ++pv) {
|
||||||
|
new (po) msgpack::object(*pv, o.zone);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
|
||||||
|
case msgpack::type::MAP:
|
||||||
|
o.via.map.ptr = (msgpack::object_kv*)o.zone.allocate_align(sizeof(msgpack::object_kv) * v.via.map.size);
|
||||||
|
o.via.map.size = v.via.map.size;
|
||||||
|
for(msgpack::object_kv
|
||||||
|
* po(o.via.map.ptr),
|
||||||
|
* pv(v.via.map.ptr),
|
||||||
|
* const pvend(v.via.map.ptr + v.via.map.size);
|
||||||
|
pv < pvend;
|
||||||
|
++po, ++pv) {
|
||||||
|
msgpack::object_kv* kv = new (po) msgpack::object_kv;
|
||||||
|
new (&kv->key) msgpack::object(pv->key, o.zone);
|
||||||
|
new (&kv->val) msgpack::object(pv->val, o.zone);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw msgpack::type_error();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Adaptor functor specialization to object::with_zone
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct object_with_zone<msgpack::object::with_zone> {
|
||||||
|
void operator()(
|
||||||
|
msgpack::object::with_zone& o,
|
||||||
|
msgpack::object::with_zone const& v) const {
|
||||||
|
o << static_cast<msgpack::object const&>(v);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace adaptor
|
||||||
|
|
||||||
|
|
||||||
// obsolete
|
// obsolete
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
class define : public Type {
|
class define : public Type {
|
||||||
@@ -150,166 +271,7 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace detail {
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
struct packer_serializer {
|
|
||||||
static msgpack::packer<Stream>& pack(msgpack::packer<Stream>& o, const T& v) {
|
|
||||||
// If you get a error 'const class your_class has no member named 'msgpack_pack',
|
|
||||||
// check the following:
|
|
||||||
// 1. The class your_class should have MSGPACK_DEFINE macro or
|
|
||||||
//
|
|
||||||
// 2. The class your_class should have the following operator declaration and
|
|
||||||
// definition:
|
|
||||||
//
|
|
||||||
// namespace msgpack {
|
|
||||||
// MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
|
||||||
// template <typename Stream>
|
|
||||||
// inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const your_class& v)
|
|
||||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
|
||||||
// } // namespace msgpack
|
|
||||||
//
|
|
||||||
// See 3.
|
|
||||||
//
|
|
||||||
// 3. #include "msgpack.hpp" too early.
|
|
||||||
// Replace msgpack.hpp with msgpack_fwd.hpp, then,
|
|
||||||
// place operator declarations as follows:
|
|
||||||
//
|
|
||||||
// namespace msgpack {
|
|
||||||
// MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
|
||||||
// template <typename Stream>
|
|
||||||
// msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const your_class& v);
|
|
||||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
|
||||||
// } // namespace msgpack
|
|
||||||
//
|
|
||||||
// then, #include "msgpack.hpp", finally place the operator definitions as follows:
|
|
||||||
//
|
|
||||||
// template <typename Stream>
|
|
||||||
// inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const your_class& v) {
|
|
||||||
// // packing operation
|
|
||||||
// }
|
|
||||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
|
||||||
// } // namespace msgpack
|
|
||||||
//
|
|
||||||
v.msgpack_pack(o);
|
|
||||||
return o;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const msgpack::object& v)
|
|
||||||
{
|
|
||||||
o.type = v.type;
|
|
||||||
|
|
||||||
switch(v.type) {
|
|
||||||
case msgpack::type::NIL:
|
|
||||||
case msgpack::type::BOOLEAN:
|
|
||||||
case msgpack::type::POSITIVE_INTEGER:
|
|
||||||
case msgpack::type::NEGATIVE_INTEGER:
|
|
||||||
case msgpack::type::FLOAT:
|
|
||||||
std::memcpy(&o.via, &v.via, sizeof(v.via));
|
|
||||||
return;
|
|
||||||
|
|
||||||
case msgpack::type::STR: {
|
|
||||||
char* ptr = static_cast<char*>(o.zone.allocate_align(v.via.str.size));
|
|
||||||
o.via.str.ptr = ptr;
|
|
||||||
o.via.str.size = v.via.str.size;
|
|
||||||
std::memcpy(ptr, v.via.str.ptr, v.via.str.size);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case msgpack::type::BIN: {
|
|
||||||
char* ptr = static_cast<char*>(o.zone.allocate_align(v.via.bin.size));
|
|
||||||
o.via.bin.ptr = ptr;
|
|
||||||
o.via.bin.size = v.via.bin.size;
|
|
||||||
std::memcpy(ptr, v.via.bin.ptr, v.via.bin.size);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case msgpack::type::EXT: {
|
|
||||||
char* ptr = static_cast<char*>(o.zone.allocate_align(v.via.ext.size + 1));
|
|
||||||
o.via.ext.ptr = ptr;
|
|
||||||
o.via.ext.size = v.via.ext.size;
|
|
||||||
std::memcpy(ptr, v.via.ext.ptr, v.via.ext.size + 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
case msgpack::type::ARRAY:
|
|
||||||
o.via.array.ptr = static_cast<object*>(o.zone.allocate_align(sizeof(object) * v.via.array.size));
|
|
||||||
o.via.array.size = v.via.array.size;
|
|
||||||
for (msgpack::object
|
|
||||||
* po(o.via.array.ptr),
|
|
||||||
* pv(v.via.array.ptr),
|
|
||||||
* const pvend(v.via.array.ptr + v.via.array.size);
|
|
||||||
pv < pvend;
|
|
||||||
++po, ++pv) {
|
|
||||||
new (po) msgpack::object(*pv, o.zone);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case msgpack::type::MAP:
|
|
||||||
o.via.map.ptr = (object_kv*)o.zone.allocate_align(sizeof(object_kv) * v.via.map.size);
|
|
||||||
o.via.map.size = v.via.map.size;
|
|
||||||
for(msgpack::object_kv
|
|
||||||
* po(o.via.map.ptr),
|
|
||||||
* pv(v.via.map.ptr),
|
|
||||||
* const pvend(v.via.map.ptr + v.via.map.size);
|
|
||||||
pv < pvend;
|
|
||||||
++po, ++pv) {
|
|
||||||
object_kv* kv = new (po) object_kv;
|
|
||||||
new (&kv->key) msgpack::object(pv->key, o.zone);
|
|
||||||
new (&kv->val) msgpack::object(pv->val, o.zone);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw msgpack::type_error();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const msgpack::object::with_zone& v)
|
|
||||||
{
|
|
||||||
return o << static_cast<msgpack::object const&>(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
// deconvert operator
|
// deconvert operator
|
||||||
template <typename T>
|
|
||||||
inline void operator<< (msgpack::object::with_zone& o, const T& v)
|
|
||||||
{
|
|
||||||
// If you get a error 'const class your_class has no member named 'msgpack_object',
|
|
||||||
// check the following:
|
|
||||||
// 1. The class your_class should have MSGPACK_DEFINE macro or
|
|
||||||
//
|
|
||||||
// 2. The class your_class should have the following operator declaration and
|
|
||||||
// definition:
|
|
||||||
//
|
|
||||||
// namespace msgpack {
|
|
||||||
// MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
|
||||||
// void operator<< (object::with_zone& o, const your_class& v);
|
|
||||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
|
||||||
// } // namespace msgpack
|
|
||||||
//
|
|
||||||
// See 3.
|
|
||||||
//
|
|
||||||
// 3. #include "msgpack.hpp" too early.
|
|
||||||
// Replace msgpack.hpp with msgpack_fwd.hpp, then,
|
|
||||||
// place operator declarations as follows:
|
|
||||||
//
|
|
||||||
// namespace msgpack {
|
|
||||||
// MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
|
||||||
// void operator<< (object::with_zone& o, const your_class& v);
|
|
||||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
|
||||||
// } // namespace msgpack
|
|
||||||
//
|
|
||||||
// then, #include "msgpack.hpp", finally place the operator definitions as follows:
|
|
||||||
//
|
|
||||||
// void operator<< (object::with_zone& o, const your_class& v) {
|
|
||||||
// // set object attributes using v.
|
|
||||||
// }
|
|
||||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
|
||||||
// } // namespace msgpack
|
|
||||||
//
|
|
||||||
v.msgpack_object(static_cast<object*>(&o), o.zone);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@@ -452,42 +414,6 @@ inline object::object()
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
inline object::object(const T& v)
|
inline object::object(const T& v)
|
||||||
{
|
{
|
||||||
// If you get a error 'no matching function call to
|
|
||||||
// operator<<(msgpack::v?::object::object(const T&)
|
|
||||||
// [with T = your_class]'
|
|
||||||
//
|
|
||||||
// check the following:
|
|
||||||
// 1. The class your_class should have MSGPACK_DEFINE macro or
|
|
||||||
//
|
|
||||||
// 2. The class your_class should have the following operator declaration and
|
|
||||||
// definition:
|
|
||||||
//
|
|
||||||
// namespace msgpack {
|
|
||||||
// MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
|
||||||
// void operator<< (object& o, const your_class& v);
|
|
||||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
|
||||||
// } // namespace msgpack
|
|
||||||
//
|
|
||||||
// See 3.
|
|
||||||
//
|
|
||||||
// 3. #include "msgpack.hpp" too early.
|
|
||||||
// Replace msgpack.hpp with msgpack_fwd.hpp, then,
|
|
||||||
// place operator declarations as follows:
|
|
||||||
//
|
|
||||||
// namespace msgpack {
|
|
||||||
// MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
|
||||||
// void operator<< (object& o, const your_class& v);
|
|
||||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
|
||||||
// } // namespace msgpack
|
|
||||||
//
|
|
||||||
// then, #include "msgpack.hpp", finally place the operator definitions as follows:
|
|
||||||
//
|
|
||||||
// void operator<< (object& o, const your_class& v) {
|
|
||||||
// // set object attributes using v.
|
|
||||||
// }
|
|
||||||
// } // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
|
||||||
// } // namespace msgpack
|
|
||||||
//
|
|
||||||
msgpack::operator<<(*this, v);
|
msgpack::operator<<(*this, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -703,7 +629,9 @@ inline std::ostream& operator<< (std::ostream& s, const msgpack::object& o)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -27,7 +27,9 @@
|
|||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
|
|
||||||
namespace type {
|
namespace type {
|
||||||
@@ -143,39 +145,16 @@ struct object_kv {
|
|||||||
msgpack::object val;
|
msgpack::object val;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace detail {
|
struct object::with_zone : object {
|
||||||
template <typename Stream, typename T>
|
with_zone(msgpack::zone& zone) : zone(zone) { }
|
||||||
struct packer_serializer;
|
msgpack::zone& zone;
|
||||||
} // namespace detail
|
private:
|
||||||
|
with_zone();
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, msgpack::object& v);
|
};
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
msgpack::object const& operator>> (msgpack::object const& o, T& v);
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const T& v);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const msgpack::object& v);
|
|
||||||
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const msgpack::object::with_zone& v);
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
class packer;
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const msgpack::object& v);
|
|
||||||
|
|
||||||
template <typename Stream>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const msgpack::object::with_zone& v);
|
|
||||||
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const T& v);
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
void operator<< (msgpack::object::with_zone& o, const T& v);
|
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
#define MSGPACK_PACK_HPP
|
#define MSGPACK_PACK_HPP
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
#include "msgpack/versioning.hpp"
|
||||||
|
#include "msgpack/cpp_config.hpp"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
@@ -29,7 +30,9 @@
|
|||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
class packer {
|
class packer {
|
||||||
@@ -80,16 +83,16 @@ public:
|
|||||||
|
|
||||||
packer<Stream>& pack_array(uint32_t n);
|
packer<Stream>& pack_array(uint32_t n);
|
||||||
|
|
||||||
packer<Stream>& pack_map(uint32_t n);
|
packer<Stream>& pack_map(uint32_t n);
|
||||||
|
|
||||||
packer<Stream>& pack_str(uint32_t l);
|
packer<Stream>& pack_str(uint32_t l);
|
||||||
packer<Stream>& pack_str_body(const char* b, uint32_t l);
|
packer<Stream>& pack_str_body(const char* b, uint32_t l);
|
||||||
|
|
||||||
packer<Stream>& pack_bin(uint32_t l);
|
packer<Stream>& pack_bin(uint32_t l);
|
||||||
packer<Stream>& pack_bin_body(const char* b, uint32_t l);
|
packer<Stream>& pack_bin_body(const char* b, uint32_t l);
|
||||||
|
|
||||||
packer<Stream>& pack_ext(size_t l, int8_t type);
|
packer<Stream>& pack_ext(size_t l, int8_t type);
|
||||||
packer<Stream>& pack_ext_body(const char* b, uint32_t l);
|
packer<Stream>& pack_ext_body(const char* b, uint32_t l);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@@ -119,11 +122,13 @@ private:
|
|||||||
private:
|
private:
|
||||||
packer(const packer&);
|
packer(const packer&);
|
||||||
packer& operator=(const packer&);
|
packer& operator=(const packer&);
|
||||||
|
packer();
|
||||||
#else // defined(MSGPACK_USE_CPP03)
|
#else // defined(MSGPACK_USE_CPP03)
|
||||||
|
public:
|
||||||
packer(const packer&) = delete;
|
packer(const packer&) = delete;
|
||||||
packer& operator=(const packer&) = delete;
|
packer& operator=(const packer&) = delete;
|
||||||
|
packer() = delete;
|
||||||
#endif // defined(MSGPACK_USE_CPP03)
|
#endif // defined(MSGPACK_USE_CPP03)
|
||||||
packer();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -139,14 +144,6 @@ inline void pack(Stream& s, const T& v)
|
|||||||
packer<Stream>(s).pack(v);
|
packer<Stream>(s).pack(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
// serialize operator
|
|
||||||
template <typename Stream, typename T>
|
|
||||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const T& v)
|
|
||||||
{
|
|
||||||
return detail::packer_serializer<Stream, T>::pack(o, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__LITTLE_ENDIAN__)
|
#if defined(__LITTLE_ENDIAN__)
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@@ -1055,7 +1052,9 @@ inline void packer<Stream>::pack_imp_int64(T d)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -28,7 +28,9 @@
|
|||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
class sbuffer {
|
class sbuffer {
|
||||||
public:
|
public:
|
||||||
@@ -127,7 +129,9 @@ private:
|
|||||||
size_t m_alloc;
|
size_t m_alloc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -64,7 +64,9 @@ const size_t COUNTER_SIZE = sizeof(_msgpack_atomic_counter_t);
|
|||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
typedef bool (*unpack_reference_func)(msgpack::type::object_type, std::size_t, void*);
|
typedef bool (*unpack_reference_func)(msgpack::type::object_type, std::size_t, void*);
|
||||||
|
|
||||||
@@ -1727,7 +1729,9 @@ inline bool unpacker::default_reference_func(msgpack::type::object_type /*type*/
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -97,78 +97,78 @@ msgpack_unpack_func(msgpack_unpack_object, _data)(msgpack_unpack_struct(_context
|
|||||||
msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const char* data, size_t len, size_t* off)
|
msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const char* data, size_t len, size_t* off)
|
||||||
{
|
{
|
||||||
assert(len >= *off);
|
assert(len >= *off);
|
||||||
|
{
|
||||||
|
const unsigned char* p = (unsigned char*)data + *off;
|
||||||
|
const unsigned char* const pe = (unsigned char*)data + len;
|
||||||
|
const void* n = NULL;
|
||||||
|
|
||||||
const unsigned char* p = (unsigned char*)data + *off;
|
unsigned int trail = ctx->trail;
|
||||||
const unsigned char* const pe = (unsigned char*)data + len;
|
unsigned int cs = ctx->cs;
|
||||||
const void* n = NULL;
|
unsigned int top = ctx->top;
|
||||||
|
msgpack_unpack_struct(_stack)* stack = ctx->stack;
|
||||||
|
/*
|
||||||
|
unsigned int stack_size = ctx->stack_size;
|
||||||
|
*/
|
||||||
|
msgpack_unpack_user* user = &ctx->user;
|
||||||
|
|
||||||
unsigned int trail = ctx->trail;
|
msgpack_unpack_object obj;
|
||||||
unsigned int cs = ctx->cs;
|
msgpack_unpack_struct(_stack)* c = NULL;
|
||||||
unsigned int top = ctx->top;
|
|
||||||
msgpack_unpack_struct(_stack)* stack = ctx->stack;
|
|
||||||
/*
|
|
||||||
unsigned int stack_size = ctx->stack_size;
|
|
||||||
*/
|
|
||||||
msgpack_unpack_user* user = &ctx->user;
|
|
||||||
|
|
||||||
msgpack_unpack_object obj;
|
int ret;
|
||||||
msgpack_unpack_struct(_stack)* c = NULL;
|
|
||||||
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
#define push_simple_value(func) \
|
#define push_simple_value(func) \
|
||||||
if(msgpack_unpack_callback(func)(user, &obj) < 0) { goto _failed; } \
|
if(msgpack_unpack_callback(func)(user, &obj) < 0) { goto _failed; } \
|
||||||
goto _push
|
goto _push
|
||||||
#define push_fixed_value(func, arg) \
|
#define push_fixed_value(func, arg) \
|
||||||
if(msgpack_unpack_callback(func)(user, arg, &obj) < 0) { goto _failed; } \
|
if(msgpack_unpack_callback(func)(user, arg, &obj) < 0) { goto _failed; } \
|
||||||
goto _push
|
goto _push
|
||||||
#define push_variable_value(func, base, pos, len) \
|
#define push_variable_value(func, base, pos, len) \
|
||||||
if(msgpack_unpack_callback(func)(user, \
|
if(msgpack_unpack_callback(func)(user, \
|
||||||
(const char*)base, (const char*)pos, len, &obj) < 0) { goto _failed; } \
|
(const char*)base, (const char*)pos, len, &obj) < 0) { goto _failed; } \
|
||||||
goto _push
|
goto _push
|
||||||
|
|
||||||
#define again_fixed_trail(_cs, trail_len) \
|
#define again_fixed_trail(_cs, trail_len) \
|
||||||
trail = trail_len; \
|
trail = trail_len; \
|
||||||
cs = _cs; \
|
cs = _cs; \
|
||||||
goto _fixed_trail_again
|
goto _fixed_trail_again
|
||||||
#define again_fixed_trail_if_zero(_cs, trail_len, ifzero) \
|
#define again_fixed_trail_if_zero(_cs, trail_len, ifzero) \
|
||||||
trail = trail_len; \
|
trail = trail_len; \
|
||||||
if(trail == 0) { goto ifzero; } \
|
if(trail == 0) { goto ifzero; } \
|
||||||
cs = _cs; \
|
cs = _cs; \
|
||||||
goto _fixed_trail_again
|
goto _fixed_trail_again
|
||||||
|
|
||||||
#define start_container(func, count_, ct_) \
|
#define start_container(func, count_, ct_) \
|
||||||
if(top >= MSGPACK_EMBED_STACK_SIZE) { goto _failed; } /* FIXME */ \
|
if(top >= MSGPACK_EMBED_STACK_SIZE) { goto _failed; } /* FIXME */ \
|
||||||
if(msgpack_unpack_callback(func)(user, count_, &stack[top].obj) < 0) { goto _failed; } \
|
if(msgpack_unpack_callback(func)(user, count_, &stack[top].obj) < 0) { goto _failed; } \
|
||||||
if((count_) == 0) { obj = stack[top].obj; goto _push; } \
|
if((count_) == 0) { obj = stack[top].obj; goto _push; } \
|
||||||
stack[top].ct = ct_; \
|
stack[top].ct = ct_; \
|
||||||
stack[top].count = count_; \
|
stack[top].count = count_; \
|
||||||
++top; \
|
++top; \
|
||||||
/*printf("container %d count %d stack %d\n",stack[top].obj,count_,top);*/ \
|
/*printf("container %d count %d stack %d\n",stack[top].obj,count_,top);*/ \
|
||||||
/*printf("stack push %d\n", top);*/ \
|
/*printf("stack push %d\n", top);*/ \
|
||||||
/* FIXME \
|
/* FIXME \
|
||||||
if(top >= stack_size) { \
|
if(top >= stack_size) { \
|
||||||
if(stack_size == MSGPACK_EMBED_STACK_SIZE) { \
|
if(stack_size == MSGPACK_EMBED_STACK_SIZE) { \
|
||||||
size_t csize = sizeof(msgpack_unpack_struct(_stack)) * MSGPACK_EMBED_STACK_SIZE; \
|
size_t csize = sizeof(msgpack_unpack_struct(_stack)) * MSGPACK_EMBED_STACK_SIZE; \
|
||||||
size_t nsize = csize * 2; \
|
size_t nsize = csize * 2; \
|
||||||
msgpack_unpack_struct(_stack)* tmp = (msgpack_unpack_struct(_stack)*)malloc(nsize); \
|
msgpack_unpack_struct(_stack)* tmp = (msgpack_unpack_struct(_stack)*)malloc(nsize); \
|
||||||
if(tmp == NULL) { goto _failed; } \
|
if(tmp == NULL) { goto _failed; } \
|
||||||
memcpy(tmp, ctx->stack, csize); \
|
memcpy(tmp, ctx->stack, csize); \
|
||||||
ctx->stack = stack = tmp; \
|
ctx->stack = stack = tmp; \
|
||||||
ctx->stack_size = stack_size = MSGPACK_EMBED_STACK_SIZE * 2; \
|
ctx->stack_size = stack_size = MSGPACK_EMBED_STACK_SIZE * 2; \
|
||||||
} else { \
|
} else { \
|
||||||
size_t nsize = sizeof(msgpack_unpack_struct(_stack)) * ctx->stack_size * 2; \
|
size_t nsize = sizeof(msgpack_unpack_struct(_stack)) * ctx->stack_size * 2; \
|
||||||
msgpack_unpack_struct(_stack)* tmp = (msgpack_unpack_struct(_stack)*)realloc(ctx->stack, nsize); \
|
msgpack_unpack_struct(_stack)* tmp = (msgpack_unpack_struct(_stack)*)realloc(ctx->stack, nsize); \
|
||||||
if(tmp == NULL) { goto _failed; } \
|
if(tmp == NULL) { goto _failed; } \
|
||||||
ctx->stack = stack = tmp; \
|
ctx->stack = stack = tmp; \
|
||||||
ctx->stack_size = stack_size = stack_size * 2; \
|
ctx->stack_size = stack_size = stack_size * 2; \
|
||||||
|
} \
|
||||||
} \
|
} \
|
||||||
} \
|
*/ \
|
||||||
*/ \
|
goto _header_again
|
||||||
goto _header_again
|
|
||||||
|
|
||||||
#define NEXT_CS(p) \
|
#define NEXT_CS(p) \
|
||||||
((unsigned int)*p & 0x1f)
|
((unsigned int)*p & 0x1f)
|
||||||
|
|
||||||
#ifdef USE_CASE_RANGE
|
#ifdef USE_CASE_RANGE
|
||||||
#define SWITCH_RANGE_BEGIN switch(*p) {
|
#define SWITCH_RANGE_BEGIN switch(*p) {
|
||||||
@@ -182,283 +182,283 @@ msgpack_unpack_func(int, _execute)(msgpack_unpack_struct(_context)* ctx, const c
|
|||||||
#define SWITCH_RANGE_END } }
|
#define SWITCH_RANGE_END } }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(p == pe) { goto _out; }
|
if(p == pe) { goto _out; }
|
||||||
do {
|
do {
|
||||||
switch(cs) {
|
switch(cs) {
|
||||||
case MSGPACK_CS_HEADER:
|
case MSGPACK_CS_HEADER:
|
||||||
SWITCH_RANGE_BEGIN
|
SWITCH_RANGE_BEGIN
|
||||||
SWITCH_RANGE(0x00, 0x7f) // Positive Fixnum
|
SWITCH_RANGE(0x00, 0x7f) // Positive Fixnum
|
||||||
push_fixed_value(_uint8, *(uint8_t*)p);
|
push_fixed_value(_uint8, *(uint8_t*)p);
|
||||||
SWITCH_RANGE(0xe0, 0xff) // Negative Fixnum
|
SWITCH_RANGE(0xe0, 0xff) // Negative Fixnum
|
||||||
push_fixed_value(_int8, *(int8_t*)p);
|
push_fixed_value(_int8, *(int8_t*)p);
|
||||||
SWITCH_RANGE(0xc0, 0xdf) // Variable
|
SWITCH_RANGE(0xc0, 0xdf) // Variable
|
||||||
switch(*p) {
|
switch(*p) {
|
||||||
case 0xc0: // nil
|
case 0xc0: // nil
|
||||||
push_simple_value(_nil);
|
push_simple_value(_nil);
|
||||||
//case 0xc1: // string
|
//case 0xc1: // string
|
||||||
// again_terminal_trail(NEXT_CS(p), p+1);
|
// again_terminal_trail(NEXT_CS(p), p+1);
|
||||||
case 0xc2: // false
|
case 0xc2: // false
|
||||||
push_simple_value(_false);
|
push_simple_value(_false);
|
||||||
case 0xc3: // true
|
case 0xc3: // true
|
||||||
push_simple_value(_true);
|
push_simple_value(_true);
|
||||||
case 0xc4: // bin 8
|
case 0xc4: // bin 8
|
||||||
case 0xc5: // bin 16
|
case 0xc5: // bin 16
|
||||||
case 0xc6: // bin 32
|
case 0xc6: // bin 32
|
||||||
again_fixed_trail(NEXT_CS(p), 1 << (((unsigned int)*p) & 0x03));
|
again_fixed_trail(NEXT_CS(p), 1 << (((unsigned int)*p) & 0x03));
|
||||||
case 0xc7: // ext 8
|
case 0xc7: // ext 8
|
||||||
case 0xc8: // ext 16
|
case 0xc8: // ext 16
|
||||||
case 0xc9: // ext 32
|
case 0xc9: // ext 32
|
||||||
again_fixed_trail(NEXT_CS(p), 1 << ((((unsigned int)*p) + 1) & 0x03));
|
again_fixed_trail(NEXT_CS(p), 1 << ((((unsigned int)*p) + 1) & 0x03));
|
||||||
case 0xca: // float
|
case 0xca: // float
|
||||||
case 0xcb: // double
|
case 0xcb: // double
|
||||||
case 0xcc: // unsigned int 8
|
case 0xcc: // unsigned int 8
|
||||||
case 0xcd: // unsigned int 16
|
case 0xcd: // unsigned int 16
|
||||||
case 0xce: // unsigned int 32
|
case 0xce: // unsigned int 32
|
||||||
case 0xcf: // unsigned int 64
|
case 0xcf: // unsigned int 64
|
||||||
case 0xd0: // signed int 8
|
case 0xd0: // signed int 8
|
||||||
case 0xd1: // signed int 16
|
case 0xd1: // signed int 16
|
||||||
case 0xd2: // signed int 32
|
case 0xd2: // signed int 32
|
||||||
case 0xd3: // signed int 64
|
case 0xd3: // signed int 64
|
||||||
again_fixed_trail(NEXT_CS(p), 1 << (((unsigned int)*p) & 0x03));
|
again_fixed_trail(NEXT_CS(p), 1 << (((unsigned int)*p) & 0x03));
|
||||||
case 0xd4: // fixext 1
|
case 0xd4: // fixext 1
|
||||||
case 0xd5: // fixext 2
|
case 0xd5: // fixext 2
|
||||||
case 0xd6: // fixext 4
|
case 0xd6: // fixext 4
|
||||||
case 0xd7: // fixext 8
|
case 0xd7: // fixext 8
|
||||||
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE,
|
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE,
|
||||||
(1 << (((unsigned int)*p) & 0x03)) + 1, _ext_zero);
|
(1 << (((unsigned int)*p) & 0x03)) + 1, _ext_zero);
|
||||||
case 0xd8: // fixext 16
|
case 0xd8: // fixext 16
|
||||||
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, 16+1, _ext_zero);
|
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, 16+1, _ext_zero);
|
||||||
|
|
||||||
|
case 0xd9: // str 8
|
||||||
|
case 0xda: // str 16
|
||||||
|
case 0xdb: // str 32
|
||||||
|
again_fixed_trail(NEXT_CS(p), 1 << ((((unsigned int)*p) & 0x03) - 1));
|
||||||
|
case 0xdc: // array 16
|
||||||
|
case 0xdd: // array 32
|
||||||
|
case 0xde: // map 16
|
||||||
|
case 0xdf: // map 32
|
||||||
|
again_fixed_trail(NEXT_CS(p), 2u << (((unsigned int)*p) & 0x01));
|
||||||
|
default:
|
||||||
|
goto _failed;
|
||||||
|
}
|
||||||
|
SWITCH_RANGE(0xa0, 0xbf) // FixStr
|
||||||
|
again_fixed_trail_if_zero(MSGPACK_ACS_STR_VALUE, ((unsigned int)*p & 0x1f), _str_zero);
|
||||||
|
SWITCH_RANGE(0x90, 0x9f) // FixArray
|
||||||
|
start_container(_array, ((unsigned int)*p) & 0x0f, MSGPACK_CT_ARRAY_ITEM);
|
||||||
|
SWITCH_RANGE(0x80, 0x8f) // FixMap
|
||||||
|
start_container(_map, ((unsigned int)*p) & 0x0f, MSGPACK_CT_MAP_KEY);
|
||||||
|
|
||||||
|
SWITCH_RANGE_DEFAULT
|
||||||
|
goto _failed;
|
||||||
|
SWITCH_RANGE_END
|
||||||
|
// end MSGPACK_CS_HEADER
|
||||||
|
|
||||||
|
|
||||||
|
_fixed_trail_again:
|
||||||
|
++p;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if((size_t)(pe - p) < trail) { goto _out; }
|
||||||
|
n = p; p += trail - 1;
|
||||||
|
switch(cs) {
|
||||||
|
//case MSGPACK_CS_
|
||||||
|
//case MSGPACK_CS_
|
||||||
|
case MSGPACK_CS_FLOAT: {
|
||||||
|
union { uint32_t i; float f; } mem;
|
||||||
|
_msgpack_load32(uint32_t, n, &mem.i);
|
||||||
|
push_fixed_value(_float, mem.f); }
|
||||||
|
case MSGPACK_CS_DOUBLE: {
|
||||||
|
union { uint64_t i; double f; } mem;
|
||||||
|
_msgpack_load64(uint64_t, n, &mem.i);
|
||||||
|
#if defined(__arm__) && !(__ARM_EABI__) // arm-oabi
|
||||||
|
// https://github.com/msgpack/msgpack-perl/pull/1
|
||||||
|
mem.i = (mem.i & 0xFFFFFFFFUL) << 32UL | (mem.i >> 32UL);
|
||||||
|
#endif
|
||||||
|
push_fixed_value(_double, mem.f); }
|
||||||
|
case MSGPACK_CS_UINT_8:
|
||||||
|
push_fixed_value(_uint8, *(uint8_t*)n);
|
||||||
|
case MSGPACK_CS_UINT_16:{
|
||||||
|
uint16_t tmp;
|
||||||
|
_msgpack_load16(uint16_t,n,&tmp);
|
||||||
|
push_fixed_value(_uint16, tmp);
|
||||||
|
}
|
||||||
|
case MSGPACK_CS_UINT_32:{
|
||||||
|
uint32_t tmp;
|
||||||
|
_msgpack_load32(uint32_t,n,&tmp);
|
||||||
|
push_fixed_value(_uint32, tmp);
|
||||||
|
}
|
||||||
|
case MSGPACK_CS_UINT_64:{
|
||||||
|
uint64_t tmp;
|
||||||
|
_msgpack_load64(uint64_t,n,&tmp);
|
||||||
|
push_fixed_value(_uint64, tmp);
|
||||||
|
}
|
||||||
|
case MSGPACK_CS_INT_8:
|
||||||
|
push_fixed_value(_int8, *(int8_t*)n);
|
||||||
|
case MSGPACK_CS_INT_16:{
|
||||||
|
int16_t tmp;
|
||||||
|
_msgpack_load16(int16_t,n,&tmp);
|
||||||
|
push_fixed_value(_int16, tmp);
|
||||||
|
}
|
||||||
|
case MSGPACK_CS_INT_32:{
|
||||||
|
int32_t tmp;
|
||||||
|
_msgpack_load32(int32_t,n,&tmp);
|
||||||
|
push_fixed_value(_int32, tmp);
|
||||||
|
}
|
||||||
|
case MSGPACK_CS_INT_64:{
|
||||||
|
int64_t tmp;
|
||||||
|
_msgpack_load64(int64_t,n,&tmp);
|
||||||
|
push_fixed_value(_int64, tmp);
|
||||||
|
}
|
||||||
|
case MSGPACK_CS_FIXEXT_1:
|
||||||
|
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, 1+1, _ext_zero);
|
||||||
|
case MSGPACK_CS_FIXEXT_2:
|
||||||
|
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, 2+1, _ext_zero);
|
||||||
|
case MSGPACK_CS_FIXEXT_4:
|
||||||
|
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, 4+1, _ext_zero);
|
||||||
|
case MSGPACK_CS_FIXEXT_8:
|
||||||
|
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, 8+1, _ext_zero);
|
||||||
|
case MSGPACK_CS_FIXEXT_16:
|
||||||
|
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, 16+1, _ext_zero);
|
||||||
|
case MSGPACK_CS_STR_8:
|
||||||
|
again_fixed_trail_if_zero(MSGPACK_ACS_STR_VALUE, *(uint8_t*)n, _str_zero);
|
||||||
|
case MSGPACK_CS_BIN_8:
|
||||||
|
again_fixed_trail_if_zero(MSGPACK_ACS_BIN_VALUE, *(uint8_t*)n, _bin_zero);
|
||||||
|
case MSGPACK_CS_EXT_8:
|
||||||
|
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, (*(uint8_t*)n) + 1, _ext_zero);
|
||||||
|
case MSGPACK_CS_STR_16:{
|
||||||
|
uint16_t tmp;
|
||||||
|
_msgpack_load16(uint16_t,n,&tmp);
|
||||||
|
again_fixed_trail_if_zero(MSGPACK_ACS_STR_VALUE, tmp, _str_zero);
|
||||||
|
}
|
||||||
|
case MSGPACK_CS_BIN_16:{
|
||||||
|
uint16_t tmp;
|
||||||
|
_msgpack_load16(uint16_t,n,&tmp);
|
||||||
|
again_fixed_trail_if_zero(MSGPACK_ACS_BIN_VALUE, tmp, _bin_zero);
|
||||||
|
}
|
||||||
|
case MSGPACK_CS_EXT_16:{
|
||||||
|
uint16_t tmp;
|
||||||
|
_msgpack_load16(uint16_t,n,&tmp);
|
||||||
|
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, tmp + 1, _ext_zero);
|
||||||
|
}
|
||||||
|
case MSGPACK_CS_STR_32:{
|
||||||
|
uint32_t tmp;
|
||||||
|
_msgpack_load32(uint32_t,n,&tmp);
|
||||||
|
again_fixed_trail_if_zero(MSGPACK_ACS_STR_VALUE, tmp, _str_zero);
|
||||||
|
}
|
||||||
|
case MSGPACK_CS_BIN_32:{
|
||||||
|
uint32_t tmp;
|
||||||
|
_msgpack_load32(uint32_t,n,&tmp);
|
||||||
|
again_fixed_trail_if_zero(MSGPACK_ACS_BIN_VALUE, tmp, _bin_zero);
|
||||||
|
}
|
||||||
|
case MSGPACK_CS_EXT_32:{
|
||||||
|
uint32_t tmp;
|
||||||
|
_msgpack_load32(uint32_t,n,&tmp);
|
||||||
|
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, tmp + 1, _ext_zero);
|
||||||
|
}
|
||||||
|
case MSGPACK_ACS_STR_VALUE:
|
||||||
|
_str_zero:
|
||||||
|
push_variable_value(_str, data, n, trail);
|
||||||
|
case MSGPACK_ACS_BIN_VALUE:
|
||||||
|
_bin_zero:
|
||||||
|
push_variable_value(_bin, data, n, trail);
|
||||||
|
case MSGPACK_ACS_EXT_VALUE:
|
||||||
|
_ext_zero:
|
||||||
|
push_variable_value(_ext, data, n, trail);
|
||||||
|
|
||||||
|
case MSGPACK_CS_ARRAY_16:{
|
||||||
|
uint16_t tmp;
|
||||||
|
_msgpack_load16(uint16_t,n,&tmp);
|
||||||
|
start_container(_array, tmp, MSGPACK_CT_ARRAY_ITEM);
|
||||||
|
}
|
||||||
|
case MSGPACK_CS_ARRAY_32:{
|
||||||
|
/* FIXME security guard */
|
||||||
|
uint32_t tmp;
|
||||||
|
_msgpack_load32(uint32_t,n,&tmp);
|
||||||
|
start_container(_array, tmp, MSGPACK_CT_ARRAY_ITEM);
|
||||||
|
}
|
||||||
|
|
||||||
|
case MSGPACK_CS_MAP_16:{
|
||||||
|
uint16_t tmp;
|
||||||
|
_msgpack_load16(uint16_t,n,&tmp);
|
||||||
|
start_container(_map, tmp, MSGPACK_CT_MAP_KEY);
|
||||||
|
}
|
||||||
|
case MSGPACK_CS_MAP_32:{
|
||||||
|
/* FIXME security guard */
|
||||||
|
uint32_t tmp;
|
||||||
|
_msgpack_load32(uint32_t,n,&tmp);
|
||||||
|
start_container(_map, tmp, MSGPACK_CT_MAP_KEY);
|
||||||
|
}
|
||||||
|
|
||||||
case 0xd9: // str 8
|
|
||||||
case 0xda: // str 16
|
|
||||||
case 0xdb: // str 32
|
|
||||||
again_fixed_trail(NEXT_CS(p), 1 << ((((unsigned int)*p) & 0x03) - 1));
|
|
||||||
case 0xdc: // array 16
|
|
||||||
case 0xdd: // array 32
|
|
||||||
case 0xde: // map 16
|
|
||||||
case 0xdf: // map 32
|
|
||||||
again_fixed_trail(NEXT_CS(p), 2u << (((unsigned int)*p) & 0x01));
|
|
||||||
default:
|
default:
|
||||||
goto _failed;
|
goto _failed;
|
||||||
}
|
}
|
||||||
SWITCH_RANGE(0xa0, 0xbf) // FixStr
|
}
|
||||||
again_fixed_trail_if_zero(MSGPACK_ACS_STR_VALUE, ((unsigned int)*p & 0x1f), _str_zero);
|
|
||||||
SWITCH_RANGE(0x90, 0x9f) // FixArray
|
|
||||||
start_container(_array, ((unsigned int)*p) & 0x0f, MSGPACK_CT_ARRAY_ITEM);
|
|
||||||
SWITCH_RANGE(0x80, 0x8f) // FixMap
|
|
||||||
start_container(_map, ((unsigned int)*p) & 0x0f, MSGPACK_CT_MAP_KEY);
|
|
||||||
|
|
||||||
SWITCH_RANGE_DEFAULT
|
_push:
|
||||||
goto _failed;
|
if(top == 0) { goto _finish; }
|
||||||
SWITCH_RANGE_END
|
c = &stack[top-1];
|
||||||
// end MSGPACK_CS_HEADER
|
switch(c->ct) {
|
||||||
|
case MSGPACK_CT_ARRAY_ITEM:
|
||||||
|
if(msgpack_unpack_callback(_array_item)(user, &c->obj, obj) < 0) { goto _failed; }
|
||||||
_fixed_trail_again:
|
if(--c->count == 0) {
|
||||||
++p;
|
obj = c->obj;
|
||||||
|
--top;
|
||||||
|
/*printf("stack pop %d\n", top);*/
|
||||||
|
goto _push;
|
||||||
|
}
|
||||||
|
goto _header_again;
|
||||||
|
case MSGPACK_CT_MAP_KEY:
|
||||||
|
c->map_key = obj;
|
||||||
|
c->ct = MSGPACK_CT_MAP_VALUE;
|
||||||
|
goto _header_again;
|
||||||
|
case MSGPACK_CT_MAP_VALUE:
|
||||||
|
if(msgpack_unpack_callback(_map_item)(user, &c->obj, c->map_key, obj) < 0) { goto _failed; }
|
||||||
|
if(--c->count == 0) {
|
||||||
|
obj = c->obj;
|
||||||
|
--top;
|
||||||
|
/*printf("stack pop %d\n", top);*/
|
||||||
|
goto _push;
|
||||||
|
}
|
||||||
|
c->ct = MSGPACK_CT_MAP_KEY;
|
||||||
|
goto _header_again;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if((size_t)(pe - p) < trail) { goto _out; }
|
goto _failed;
|
||||||
n = p; p += trail - 1;
|
|
||||||
switch(cs) {
|
|
||||||
//case MSGPACK_CS_
|
|
||||||
//case MSGPACK_CS_
|
|
||||||
case MSGPACK_CS_FLOAT: {
|
|
||||||
union { uint32_t i; float f; } mem;
|
|
||||||
_msgpack_load32(uint32_t, n, &mem.i);
|
|
||||||
push_fixed_value(_float, mem.f); }
|
|
||||||
case MSGPACK_CS_DOUBLE: {
|
|
||||||
union { uint64_t i; double f; } mem;
|
|
||||||
_msgpack_load64(uint64_t, n, &mem.i);
|
|
||||||
#if defined(__arm__) && !(__ARM_EABI__) // arm-oabi
|
|
||||||
// https://github.com/msgpack/msgpack-perl/pull/1
|
|
||||||
mem.i = (mem.i & 0xFFFFFFFFUL) << 32UL | (mem.i >> 32UL);
|
|
||||||
#endif
|
|
||||||
push_fixed_value(_double, mem.f); }
|
|
||||||
case MSGPACK_CS_UINT_8:
|
|
||||||
push_fixed_value(_uint8, *(uint8_t*)n);
|
|
||||||
case MSGPACK_CS_UINT_16:{
|
|
||||||
uint16_t tmp;
|
|
||||||
_msgpack_load16(uint16_t,n,&tmp);
|
|
||||||
push_fixed_value(_uint16, tmp);
|
|
||||||
}
|
|
||||||
case MSGPACK_CS_UINT_32:{
|
|
||||||
uint32_t tmp;
|
|
||||||
_msgpack_load32(uint32_t,n,&tmp);
|
|
||||||
push_fixed_value(_uint32, tmp);
|
|
||||||
}
|
|
||||||
case MSGPACK_CS_UINT_64:{
|
|
||||||
uint64_t tmp;
|
|
||||||
_msgpack_load64(uint64_t,n,&tmp);
|
|
||||||
push_fixed_value(_uint64, tmp);
|
|
||||||
}
|
|
||||||
case MSGPACK_CS_INT_8:
|
|
||||||
push_fixed_value(_int8, *(int8_t*)n);
|
|
||||||
case MSGPACK_CS_INT_16:{
|
|
||||||
int16_t tmp;
|
|
||||||
_msgpack_load16(int16_t,n,&tmp);
|
|
||||||
push_fixed_value(_int16, tmp);
|
|
||||||
}
|
|
||||||
case MSGPACK_CS_INT_32:{
|
|
||||||
int32_t tmp;
|
|
||||||
_msgpack_load32(int32_t,n,&tmp);
|
|
||||||
push_fixed_value(_int32, tmp);
|
|
||||||
}
|
|
||||||
case MSGPACK_CS_INT_64:{
|
|
||||||
int64_t tmp;
|
|
||||||
_msgpack_load64(int64_t,n,&tmp);
|
|
||||||
push_fixed_value(_int64, tmp);
|
|
||||||
}
|
|
||||||
case MSGPACK_CS_FIXEXT_1:
|
|
||||||
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, 1+1, _ext_zero);
|
|
||||||
case MSGPACK_CS_FIXEXT_2:
|
|
||||||
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, 2+1, _ext_zero);
|
|
||||||
case MSGPACK_CS_FIXEXT_4:
|
|
||||||
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, 4+1, _ext_zero);
|
|
||||||
case MSGPACK_CS_FIXEXT_8:
|
|
||||||
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, 8+1, _ext_zero);
|
|
||||||
case MSGPACK_CS_FIXEXT_16:
|
|
||||||
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, 16+1, _ext_zero);
|
|
||||||
case MSGPACK_CS_STR_8:
|
|
||||||
again_fixed_trail_if_zero(MSGPACK_ACS_STR_VALUE, *(uint8_t*)n, _str_zero);
|
|
||||||
case MSGPACK_CS_BIN_8:
|
|
||||||
again_fixed_trail_if_zero(MSGPACK_ACS_BIN_VALUE, *(uint8_t*)n, _bin_zero);
|
|
||||||
case MSGPACK_CS_EXT_8:
|
|
||||||
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, (*(uint8_t*)n) + 1, _ext_zero);
|
|
||||||
case MSGPACK_CS_STR_16:{
|
|
||||||
uint16_t tmp;
|
|
||||||
_msgpack_load16(uint16_t,n,&tmp);
|
|
||||||
again_fixed_trail_if_zero(MSGPACK_ACS_STR_VALUE, tmp, _str_zero);
|
|
||||||
}
|
|
||||||
case MSGPACK_CS_BIN_16:{
|
|
||||||
uint16_t tmp;
|
|
||||||
_msgpack_load16(uint16_t,n,&tmp);
|
|
||||||
again_fixed_trail_if_zero(MSGPACK_ACS_BIN_VALUE, tmp, _bin_zero);
|
|
||||||
}
|
|
||||||
case MSGPACK_CS_EXT_16:{
|
|
||||||
uint16_t tmp;
|
|
||||||
_msgpack_load16(uint16_t,n,&tmp);
|
|
||||||
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, tmp + 1, _ext_zero);
|
|
||||||
}
|
|
||||||
case MSGPACK_CS_STR_32:{
|
|
||||||
uint32_t tmp;
|
|
||||||
_msgpack_load32(uint32_t,n,&tmp);
|
|
||||||
again_fixed_trail_if_zero(MSGPACK_ACS_STR_VALUE, tmp, _str_zero);
|
|
||||||
}
|
|
||||||
case MSGPACK_CS_BIN_32:{
|
|
||||||
uint32_t tmp;
|
|
||||||
_msgpack_load32(uint32_t,n,&tmp);
|
|
||||||
again_fixed_trail_if_zero(MSGPACK_ACS_BIN_VALUE, tmp, _bin_zero);
|
|
||||||
}
|
|
||||||
case MSGPACK_CS_EXT_32:{
|
|
||||||
uint32_t tmp;
|
|
||||||
_msgpack_load32(uint32_t,n,&tmp);
|
|
||||||
again_fixed_trail_if_zero(MSGPACK_ACS_EXT_VALUE, tmp + 1, _ext_zero);
|
|
||||||
}
|
|
||||||
case MSGPACK_ACS_STR_VALUE:
|
|
||||||
_str_zero:
|
|
||||||
push_variable_value(_str, data, n, trail);
|
|
||||||
case MSGPACK_ACS_BIN_VALUE:
|
|
||||||
_bin_zero:
|
|
||||||
push_variable_value(_bin, data, n, trail);
|
|
||||||
case MSGPACK_ACS_EXT_VALUE:
|
|
||||||
_ext_zero:
|
|
||||||
push_variable_value(_ext, data, n, trail);
|
|
||||||
|
|
||||||
case MSGPACK_CS_ARRAY_16:{
|
|
||||||
uint16_t tmp;
|
|
||||||
_msgpack_load16(uint16_t,n,&tmp);
|
|
||||||
start_container(_array, tmp, MSGPACK_CT_ARRAY_ITEM);
|
|
||||||
}
|
|
||||||
case MSGPACK_CS_ARRAY_32:{
|
|
||||||
/* FIXME security guard */
|
|
||||||
uint32_t tmp;
|
|
||||||
_msgpack_load32(uint32_t,n,&tmp);
|
|
||||||
start_container(_array, tmp, MSGPACK_CT_ARRAY_ITEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
case MSGPACK_CS_MAP_16:{
|
|
||||||
uint16_t tmp;
|
|
||||||
_msgpack_load16(uint16_t,n,&tmp);
|
|
||||||
start_container(_map, tmp, MSGPACK_CT_MAP_KEY);
|
|
||||||
}
|
|
||||||
case MSGPACK_CS_MAP_32:{
|
|
||||||
/* FIXME security guard */
|
|
||||||
uint32_t tmp;
|
|
||||||
_msgpack_load32(uint32_t,n,&tmp);
|
|
||||||
start_container(_map, tmp, MSGPACK_CT_MAP_KEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
goto _failed;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_push:
|
_header_again:
|
||||||
if(top == 0) { goto _finish; }
|
cs = MSGPACK_CS_HEADER;
|
||||||
c = &stack[top-1];
|
++p;
|
||||||
switch(c->ct) {
|
} while(p != pe);
|
||||||
case MSGPACK_CT_ARRAY_ITEM:
|
goto _out;
|
||||||
if(msgpack_unpack_callback(_array_item)(user, &c->obj, obj) < 0) { goto _failed; }
|
|
||||||
if(--c->count == 0) {
|
|
||||||
obj = c->obj;
|
|
||||||
--top;
|
|
||||||
/*printf("stack pop %d\n", top);*/
|
|
||||||
goto _push;
|
|
||||||
}
|
|
||||||
goto _header_again;
|
|
||||||
case MSGPACK_CT_MAP_KEY:
|
|
||||||
c->map_key = obj;
|
|
||||||
c->ct = MSGPACK_CT_MAP_VALUE;
|
|
||||||
goto _header_again;
|
|
||||||
case MSGPACK_CT_MAP_VALUE:
|
|
||||||
if(msgpack_unpack_callback(_map_item)(user, &c->obj, c->map_key, obj) < 0) { goto _failed; }
|
|
||||||
if(--c->count == 0) {
|
|
||||||
obj = c->obj;
|
|
||||||
--top;
|
|
||||||
/*printf("stack pop %d\n", top);*/
|
|
||||||
goto _push;
|
|
||||||
}
|
|
||||||
c->ct = MSGPACK_CT_MAP_KEY;
|
|
||||||
goto _header_again;
|
|
||||||
|
|
||||||
default:
|
|
||||||
goto _failed;
|
|
||||||
}
|
|
||||||
|
|
||||||
_header_again:
|
_finish:
|
||||||
cs = MSGPACK_CS_HEADER;
|
stack[0].obj = obj;
|
||||||
++p;
|
++p;
|
||||||
} while(p != pe);
|
ret = 1;
|
||||||
goto _out;
|
/*printf("-- finish --\n"); */
|
||||||
|
goto _end;
|
||||||
|
|
||||||
|
_failed:
|
||||||
|
/*printf("** FAILED **\n"); */
|
||||||
|
ret = -1;
|
||||||
|
goto _end;
|
||||||
|
|
||||||
_finish:
|
_out:
|
||||||
stack[0].obj = obj;
|
ret = 0;
|
||||||
++p;
|
goto _end;
|
||||||
ret = 1;
|
|
||||||
/*printf("-- finish --\n"); */
|
|
||||||
goto _end;
|
|
||||||
|
|
||||||
_failed:
|
_end:
|
||||||
/*printf("** FAILED **\n"); */
|
ctx->cs = cs;
|
||||||
ret = -1;
|
ctx->trail = trail;
|
||||||
goto _end;
|
ctx->top = top;
|
||||||
|
*off = (size_t)(p - (const unsigned char*)data);
|
||||||
|
|
||||||
_out:
|
return ret;
|
||||||
ret = 0;
|
}
|
||||||
goto _end;
|
|
||||||
|
|
||||||
_end:
|
|
||||||
ctx->cs = cs;
|
|
||||||
ctx->trail = trail;
|
|
||||||
ctx->top = top;
|
|
||||||
*off = (size_t)(p - (const unsigned char*)data);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#undef msgpack_unpack_func
|
#undef msgpack_unpack_func
|
||||||
#undef msgpack_unpack_callback
|
#undef msgpack_unpack_callback
|
||||||
#undef msgpack_unpack_struct
|
#undef msgpack_unpack_struct
|
||||||
|
@@ -1,3 +1,3 @@
|
|||||||
#define MSGPACK_VERSION_MAJOR 1
|
#define MSGPACK_VERSION_MAJOR 1
|
||||||
#define MSGPACK_VERSION_MINOR 0
|
#define MSGPACK_VERSION_MINOR 1
|
||||||
#define MSGPACK_VERSION_REVISION 1
|
#define MSGPACK_VERSION_REVISION 0
|
||||||
|
@@ -41,7 +41,9 @@ struct iovec {
|
|||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
// int64, uint64, double
|
// int64, uint64, double
|
||||||
@@ -289,7 +291,9 @@ private:
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -33,7 +33,9 @@
|
|||||||
|
|
||||||
namespace msgpack {
|
namespace msgpack {
|
||||||
|
|
||||||
|
/// @cond
|
||||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
class zbuffer {
|
class zbuffer {
|
||||||
public:
|
public:
|
||||||
@@ -164,7 +166,9 @@ private:
|
|||||||
size_t m_init_size;
|
size_t m_init_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @cond
|
||||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||||
|
/// @endcond
|
||||||
|
|
||||||
} // namespace msgpack
|
} // namespace msgpack
|
||||||
|
|
||||||
|
@@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* MessagePack for C++ version switcher
|
|
||||||
*
|
|
||||||
* Copyright (C) 2014 KONDO Takatoshi
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
#ifndef MSGPACK_FWD_HPP
|
|
||||||
#define MSGPACK_FWD_HPP
|
|
||||||
|
|
||||||
#include "msgpack/versioning.hpp"
|
|
||||||
#include "msgpack/zone.hpp"
|
|
||||||
#include "msgpack/object_fwd.hpp"
|
|
||||||
#include "msgpack/iterator.hpp"
|
|
||||||
#include "msgpack/adaptor/define.hpp"
|
|
||||||
#include "msgpack/pack.hpp"
|
|
||||||
|
|
||||||
#endif // MSGPACK_FWD_HPP
|
|
@@ -13,6 +13,5 @@ preprocess() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
preprocess erb/cpp03_msgpack_tuple.hpp include/msgpack/adaptor/detail/cpp03_msgpack_tuple.hpp
|
preprocess erb/cpp03_msgpack_tuple.hpp include/msgpack/adaptor/detail/cpp03_msgpack_tuple.hpp
|
||||||
preprocess erb/cpp03_msgpack_tuple_fwd.hpp include/msgpack/adaptor/detail/cpp03_msgpack_tuple_fwd.hpp
|
|
||||||
preprocess erb/cpp03_define.hpp include/msgpack/adaptor/detail/cpp03_define.hpp
|
preprocess erb/cpp03_define.hpp include/msgpack/adaptor/detail/cpp03_define.hpp
|
||||||
preprocess erb/cpp03_zone.hpp include/msgpack/detail/cpp03_zone.hpp
|
preprocess erb/cpp03_zone.hpp include/msgpack/detail/cpp03_zone.hpp
|
||||||
|
@@ -54,65 +54,38 @@ nobase_include_HEADERS = \
|
|||||||
if ENABLE_CXX
|
if ENABLE_CXX
|
||||||
nobase_include_HEADERS += \
|
nobase_include_HEADERS += \
|
||||||
../include/msgpack.hpp \
|
../include/msgpack.hpp \
|
||||||
../include/msgpack_fwd.hpp \
|
../include/msgpack/adaptor/adaptor_base.hpp \
|
||||||
../include/msgpack/adaptor/bool.hpp \
|
../include/msgpack/adaptor/bool.hpp \
|
||||||
../include/msgpack/adaptor/bool_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/char_ptr.hpp \
|
../include/msgpack/adaptor/char_ptr.hpp \
|
||||||
../include/msgpack/adaptor/char_ptr_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/check_container_size.hpp \
|
../include/msgpack/adaptor/check_container_size.hpp \
|
||||||
../include/msgpack/adaptor/cpp11/array.hpp \
|
../include/msgpack/adaptor/cpp11/array.hpp \
|
||||||
../include/msgpack/adaptor/cpp11/array_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/cpp11/array_char.hpp \
|
../include/msgpack/adaptor/cpp11/array_char.hpp \
|
||||||
../include/msgpack/adaptor/cpp11/array_char_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/cpp11/forward_list.hpp \
|
../include/msgpack/adaptor/cpp11/forward_list.hpp \
|
||||||
../include/msgpack/adaptor/cpp11/forward_list_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/cpp11/tuple.hpp \
|
../include/msgpack/adaptor/cpp11/tuple.hpp \
|
||||||
../include/msgpack/adaptor/cpp11/tuple_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/cpp11/unordered_map.hpp \
|
../include/msgpack/adaptor/cpp11/unordered_map.hpp \
|
||||||
../include/msgpack/adaptor/cpp11/unordered_map_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/cpp11/unordered_set.hpp \
|
../include/msgpack/adaptor/cpp11/unordered_set.hpp \
|
||||||
../include/msgpack/adaptor/cpp11/unordered_set_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/define.hpp \
|
../include/msgpack/adaptor/define.hpp \
|
||||||
../include/msgpack/adaptor/deque.hpp \
|
../include/msgpack/adaptor/deque.hpp \
|
||||||
../include/msgpack/adaptor/deque_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/detail/cpp03_define.hpp \
|
../include/msgpack/adaptor/detail/cpp03_define.hpp \
|
||||||
../include/msgpack/adaptor/detail/cpp03_msgpack_tuple.hpp \
|
../include/msgpack/adaptor/detail/cpp03_msgpack_tuple.hpp \
|
||||||
../include/msgpack/adaptor/detail/cpp03_msgpack_tuple_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/detail/cpp11_define.hpp \
|
../include/msgpack/adaptor/detail/cpp11_define.hpp \
|
||||||
../include/msgpack/adaptor/detail/cpp11_msgpack_tuple.hpp \
|
../include/msgpack/adaptor/detail/cpp11_msgpack_tuple.hpp \
|
||||||
../include/msgpack/adaptor/detail/cpp11_msgpack_tuple_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/fixint.hpp \
|
../include/msgpack/adaptor/fixint.hpp \
|
||||||
../include/msgpack/adaptor/fixint_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/float.hpp \
|
../include/msgpack/adaptor/float.hpp \
|
||||||
../include/msgpack/adaptor/float_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/int.hpp \
|
../include/msgpack/adaptor/int.hpp \
|
||||||
../include/msgpack/adaptor/int_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/list.hpp \
|
../include/msgpack/adaptor/list.hpp \
|
||||||
../include/msgpack/adaptor/list_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/map.hpp \
|
../include/msgpack/adaptor/map.hpp \
|
||||||
../include/msgpack/adaptor/map_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/msgpack_tuple.hpp \
|
../include/msgpack/adaptor/msgpack_tuple.hpp \
|
||||||
../include/msgpack/adaptor/msgpack_tuple_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/nil.hpp \
|
../include/msgpack/adaptor/nil.hpp \
|
||||||
../include/msgpack/adaptor/nil_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/pair.hpp \
|
../include/msgpack/adaptor/pair.hpp \
|
||||||
../include/msgpack/adaptor/pair_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/raw.hpp \
|
../include/msgpack/adaptor/raw.hpp \
|
||||||
../include/msgpack/adaptor/raw_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/set.hpp \
|
../include/msgpack/adaptor/set.hpp \
|
||||||
../include/msgpack/adaptor/set_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/string.hpp \
|
../include/msgpack/adaptor/string.hpp \
|
||||||
../include/msgpack/adaptor/string_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/tr1/unordered_map.hpp \
|
../include/msgpack/adaptor/tr1/unordered_map.hpp \
|
||||||
../include/msgpack/adaptor/tr1/unordered_map_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/tr1/unordered_set.hpp \
|
../include/msgpack/adaptor/tr1/unordered_set.hpp \
|
||||||
../include/msgpack/adaptor/tr1/unordered_set_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/vector.hpp \
|
../include/msgpack/adaptor/vector.hpp \
|
||||||
../include/msgpack/adaptor/vector_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/vector_bool.hpp \
|
../include/msgpack/adaptor/vector_bool.hpp \
|
||||||
../include/msgpack/adaptor/vector_bool_fwd.hpp \
|
|
||||||
../include/msgpack/adaptor/vector_char.hpp \
|
../include/msgpack/adaptor/vector_char.hpp \
|
||||||
../include/msgpack/adaptor/vector_char_fwd.hpp \
|
|
||||||
../include/msgpack/cpp_config.hpp \
|
../include/msgpack/cpp_config.hpp \
|
||||||
../include/msgpack/detail/cpp03_zone.hpp \
|
../include/msgpack/detail/cpp03_zone.hpp \
|
||||||
../include/msgpack/detail/cpp11_zone.hpp \
|
../include/msgpack/detail/cpp11_zone.hpp \
|
||||||
@@ -141,6 +114,8 @@ doxygen_c:
|
|||||||
cat ../Doxyfile > Doxyfile_c
|
cat ../Doxyfile > Doxyfile_c
|
||||||
echo "FILE_PATTERNS = *.h" >> Doxyfile_c
|
echo "FILE_PATTERNS = *.h" >> Doxyfile_c
|
||||||
echo "OUTPUT_DIRECTORY = doc_c" >> Doxyfile_c
|
echo "OUTPUT_DIRECTORY = doc_c" >> Doxyfile_c
|
||||||
|
echo "INPUT = ../include" >> Doxyfile_c
|
||||||
|
echo "EXTRACT_ALL = YES" >> Doxyfile_c
|
||||||
echo "PROJECT_NAME = \"MessagePack for C\"" >> Doxyfile_c
|
echo "PROJECT_NAME = \"MessagePack for C\"" >> Doxyfile_c
|
||||||
doxygen Doxyfile_c
|
doxygen Doxyfile_c
|
||||||
|
|
||||||
@@ -148,6 +123,8 @@ doxygen_cpp:
|
|||||||
cat ../Doxyfile > Doxyfile_cpp
|
cat ../Doxyfile > Doxyfile_cpp
|
||||||
echo "FILE_PATTERNS = *.hpp" >> Doxyfile_cpp
|
echo "FILE_PATTERNS = *.hpp" >> Doxyfile_cpp
|
||||||
echo "OUTPUT_DIRECTORY = doc_cpp" >> Doxyfile_cpp
|
echo "OUTPUT_DIRECTORY = doc_cpp" >> Doxyfile_cpp
|
||||||
|
echo "INPUT = ../include" >> Doxyfile_cpp
|
||||||
|
echo "EXTRACT_ALL = YES" >> Doxyfile_cpp
|
||||||
echo "PROJECT_NAME = \"MessagePack for C++\"" >> Doxyfile_cpp
|
echo "PROJECT_NAME = \"MessagePack for C++\"" >> Doxyfile_cpp
|
||||||
doxygen Doxyfile_cpp
|
doxygen Doxyfile_cpp
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if !defined(_MSC_VER) || _MSC_VER >= 1700
|
#if !defined(_MSC_VER) || _MSC_VER >= 1800
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -71,33 +71,39 @@ int msgpack_pack_object(msgpack_packer* pk, msgpack_object d)
|
|||||||
case MSGPACK_OBJECT_ARRAY:
|
case MSGPACK_OBJECT_ARRAY:
|
||||||
{
|
{
|
||||||
int ret = msgpack_pack_array(pk, d.via.array.size);
|
int ret = msgpack_pack_array(pk, d.via.array.size);
|
||||||
if(ret < 0) { return ret; }
|
if(ret < 0) {
|
||||||
|
return ret;
|
||||||
msgpack_object* o = d.via.array.ptr;
|
|
||||||
msgpack_object* const oend = d.via.array.ptr + d.via.array.size;
|
|
||||||
for(; o != oend; ++o) {
|
|
||||||
ret = msgpack_pack_object(pk, *o);
|
|
||||||
if(ret < 0) { return ret; }
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
msgpack_object* o = d.via.array.ptr;
|
||||||
|
msgpack_object* const oend = d.via.array.ptr + d.via.array.size;
|
||||||
|
for(; o != oend; ++o) {
|
||||||
|
ret = msgpack_pack_object(pk, *o);
|
||||||
|
if(ret < 0) { return ret; }
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case MSGPACK_OBJECT_MAP:
|
case MSGPACK_OBJECT_MAP:
|
||||||
{
|
{
|
||||||
int ret = msgpack_pack_map(pk, d.via.map.size);
|
int ret = msgpack_pack_map(pk, d.via.map.size);
|
||||||
if(ret < 0) { return ret; }
|
if(ret < 0) {
|
||||||
|
return ret;
|
||||||
msgpack_object_kv* kv = d.via.map.ptr;
|
|
||||||
msgpack_object_kv* const kvend = d.via.map.ptr + d.via.map.size;
|
|
||||||
for(; kv != kvend; ++kv) {
|
|
||||||
ret = msgpack_pack_object(pk, kv->key);
|
|
||||||
if(ret < 0) { return ret; }
|
|
||||||
ret = msgpack_pack_object(pk, kv->val);
|
|
||||||
if(ret < 0) { return ret; }
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
msgpack_object_kv* kv = d.via.map.ptr;
|
||||||
|
msgpack_object_kv* const kvend = d.via.map.ptr + d.via.map.size;
|
||||||
|
for(; kv != kvend; ++kv) {
|
||||||
|
ret = msgpack_pack_object(pk, kv->key);
|
||||||
|
if(ret < 0) { return ret; }
|
||||||
|
ret = msgpack_pack_object(pk, kv->val);
|
||||||
|
if(ret < 0) { return ret; }
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -172,9 +178,9 @@ void msgpack_object_print(FILE* out, msgpack_object o)
|
|||||||
fprintf(out, "[");
|
fprintf(out, "[");
|
||||||
if(o.via.array.size != 0) {
|
if(o.via.array.size != 0) {
|
||||||
msgpack_object* p = o.via.array.ptr;
|
msgpack_object* p = o.via.array.ptr;
|
||||||
|
msgpack_object* const pend = o.via.array.ptr + o.via.array.size;
|
||||||
msgpack_object_print(out, *p);
|
msgpack_object_print(out, *p);
|
||||||
++p;
|
++p;
|
||||||
msgpack_object* const pend = o.via.array.ptr + o.via.array.size;
|
|
||||||
for(; p < pend; ++p) {
|
for(; p < pend; ++p) {
|
||||||
fprintf(out, ", ");
|
fprintf(out, ", ");
|
||||||
msgpack_object_print(out, *p);
|
msgpack_object_print(out, *p);
|
||||||
@@ -187,11 +193,11 @@ void msgpack_object_print(FILE* out, msgpack_object o)
|
|||||||
fprintf(out, "{");
|
fprintf(out, "{");
|
||||||
if(o.via.map.size != 0) {
|
if(o.via.map.size != 0) {
|
||||||
msgpack_object_kv* p = o.via.map.ptr;
|
msgpack_object_kv* p = o.via.map.ptr;
|
||||||
|
msgpack_object_kv* const pend = o.via.map.ptr + o.via.map.size;
|
||||||
msgpack_object_print(out, p->key);
|
msgpack_object_print(out, p->key);
|
||||||
fprintf(out, "=>");
|
fprintf(out, "=>");
|
||||||
msgpack_object_print(out, p->val);
|
msgpack_object_print(out, p->val);
|
||||||
++p;
|
++p;
|
||||||
msgpack_object_kv* const pend = o.via.map.ptr + o.via.map.size;
|
|
||||||
for(; p < pend; ++p) {
|
for(; p < pend; ++p) {
|
||||||
fprintf(out, ", ");
|
fprintf(out, ", ");
|
||||||
msgpack_object_print(out, p->key);
|
msgpack_object_print(out, p->key);
|
||||||
|
118
src/unpack.c
118
src/unpack.c
@@ -58,8 +58,8 @@ static int template_execute(
|
|||||||
|
|
||||||
static inline msgpack_object template_callback_root(unpack_user* u)
|
static inline msgpack_object template_callback_root(unpack_user* u)
|
||||||
{
|
{
|
||||||
MSGPACK_UNUSED(u);
|
|
||||||
msgpack_object o;
|
msgpack_object o;
|
||||||
|
MSGPACK_UNUSED(u);
|
||||||
o.type = MSGPACK_OBJECT_NIL;
|
o.type = MSGPACK_OBJECT_NIL;
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
@@ -306,26 +306,28 @@ static inline _msgpack_atomic_counter_t get_count(void* buffer)
|
|||||||
return *(volatile _msgpack_atomic_counter_t*)buffer;
|
return *(volatile _msgpack_atomic_counter_t*)buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool msgpack_unpacker_init(msgpack_unpacker* mpac, size_t initial_buffer_size)
|
bool msgpack_unpacker_init(msgpack_unpacker* mpac, size_t initial_buffer_size)
|
||||||
{
|
{
|
||||||
|
char* buffer;
|
||||||
|
void* ctx;
|
||||||
|
msgpack_zone* z;
|
||||||
|
|
||||||
if(initial_buffer_size < COUNTER_SIZE) {
|
if(initial_buffer_size < COUNTER_SIZE) {
|
||||||
initial_buffer_size = COUNTER_SIZE;
|
initial_buffer_size = COUNTER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* buffer = (char*)malloc(initial_buffer_size);
|
buffer = (char*)malloc(initial_buffer_size);
|
||||||
if(buffer == NULL) {
|
if(buffer == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* ctx = malloc(sizeof(template_context));
|
ctx = malloc(sizeof(template_context));
|
||||||
if(ctx == NULL) {
|
if(ctx == NULL) {
|
||||||
free(buffer);
|
free(buffer);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
msgpack_zone* z = msgpack_zone_new(MSGPACK_ZONE_CHUNK_SIZE);
|
z = msgpack_zone_new(MSGPACK_ZONE_CHUNK_SIZE);
|
||||||
if(z == NULL) {
|
if(z == NULL) {
|
||||||
free(ctx);
|
free(ctx);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
@@ -357,7 +359,6 @@ void msgpack_unpacker_destroy(msgpack_unpacker* mpac)
|
|||||||
decr_count(mpac->buffer);
|
decr_count(mpac->buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
msgpack_unpacker* msgpack_unpacker_new(size_t initial_buffer_size)
|
msgpack_unpacker* msgpack_unpacker_new(size_t initial_buffer_size)
|
||||||
{
|
{
|
||||||
msgpack_unpacker* mpac = (msgpack_unpacker*)malloc(sizeof(msgpack_unpacker));
|
msgpack_unpacker* mpac = (msgpack_unpacker*)malloc(sizeof(msgpack_unpacker));
|
||||||
@@ -394,6 +395,7 @@ bool msgpack_unpacker_expand_buffer(msgpack_unpacker* mpac, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(mpac->off == COUNTER_SIZE) {
|
if(mpac->off == COUNTER_SIZE) {
|
||||||
|
char* tmp;
|
||||||
size_t next_size = (mpac->used + mpac->free) * 2; // include COUNTER_SIZE
|
size_t next_size = (mpac->used + mpac->free) * 2; // include COUNTER_SIZE
|
||||||
while(next_size < size + mpac->used) {
|
while(next_size < size + mpac->used) {
|
||||||
size_t tmp_next_size = next_size * 2;
|
size_t tmp_next_size = next_size * 2;
|
||||||
@@ -404,7 +406,7 @@ bool msgpack_unpacker_expand_buffer(msgpack_unpacker* mpac, size_t size)
|
|||||||
next_size = tmp_next_size;
|
next_size = tmp_next_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* tmp = (char*)realloc(mpac->buffer, next_size);
|
tmp = (char*)realloc(mpac->buffer, next_size);
|
||||||
if(tmp == NULL) {
|
if(tmp == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -413,6 +415,7 @@ bool msgpack_unpacker_expand_buffer(msgpack_unpacker* mpac, size_t size)
|
|||||||
mpac->free = next_size - mpac->used;
|
mpac->free = next_size - mpac->used;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
char* tmp;
|
||||||
size_t next_size = mpac->initial_buffer_size; // include COUNTER_SIZE
|
size_t next_size = mpac->initial_buffer_size; // include COUNTER_SIZE
|
||||||
size_t not_parsed = mpac->used - mpac->off;
|
size_t not_parsed = mpac->used - mpac->off;
|
||||||
while(next_size < size + not_parsed + COUNTER_SIZE) {
|
while(next_size < size + not_parsed + COUNTER_SIZE) {
|
||||||
@@ -424,7 +427,7 @@ bool msgpack_unpacker_expand_buffer(msgpack_unpacker* mpac, size_t size)
|
|||||||
next_size = tmp_next_size;
|
next_size = tmp_next_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* tmp = (char*)malloc(next_size);
|
tmp = (char*)malloc(next_size);
|
||||||
if(tmp == NULL) {
|
if(tmp == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -470,16 +473,19 @@ msgpack_object msgpack_unpacker_data(msgpack_unpacker* mpac)
|
|||||||
|
|
||||||
msgpack_zone* msgpack_unpacker_release_zone(msgpack_unpacker* mpac)
|
msgpack_zone* msgpack_unpacker_release_zone(msgpack_unpacker* mpac)
|
||||||
{
|
{
|
||||||
|
msgpack_zone* r;
|
||||||
|
msgpack_zone* old;
|
||||||
|
|
||||||
if(!msgpack_unpacker_flush_zone(mpac)) {
|
if(!msgpack_unpacker_flush_zone(mpac)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
msgpack_zone* r = msgpack_zone_new(MSGPACK_ZONE_CHUNK_SIZE);
|
r = msgpack_zone_new(MSGPACK_ZONE_CHUNK_SIZE);
|
||||||
if(r == NULL) {
|
if(r == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
msgpack_zone* old = mpac->z;
|
old = mpac->z;
|
||||||
mpac->z = r;
|
mpac->z = r;
|
||||||
CTX_CAST(mpac->ctx)->user.z = mpac->z;
|
CTX_CAST(mpac->ctx)->user.z = mpac->z;
|
||||||
|
|
||||||
@@ -514,9 +520,11 @@ void msgpack_unpacker_reset(msgpack_unpacker* mpac)
|
|||||||
|
|
||||||
msgpack_unpack_return msgpack_unpacker_next(msgpack_unpacker* mpac, msgpack_unpacked* result)
|
msgpack_unpack_return msgpack_unpacker_next(msgpack_unpacker* mpac, msgpack_unpacked* result)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
msgpack_unpacked_destroy(result);
|
msgpack_unpacked_destroy(result);
|
||||||
|
|
||||||
int ret = msgpack_unpacker_execute(mpac);
|
ret = msgpack_unpacker_execute(mpac);
|
||||||
|
|
||||||
if(ret < 0) {
|
if(ret < 0) {
|
||||||
result->zone = NULL;
|
result->zone = NULL;
|
||||||
@@ -546,40 +554,42 @@ msgpack_unpack(const char* data, size_t len, size_t* off,
|
|||||||
// FIXME
|
// FIXME
|
||||||
return MSGPACK_UNPACK_CONTINUE;
|
return MSGPACK_UNPACK_CONTINUE;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
int e;
|
||||||
|
template_context ctx;
|
||||||
|
template_init(&ctx);
|
||||||
|
|
||||||
template_context ctx;
|
ctx.user.z = result_zone;
|
||||||
template_init(&ctx);
|
ctx.user.referenced = false;
|
||||||
|
|
||||||
ctx.user.z = result_zone;
|
e = template_execute(&ctx, data, len, &noff);
|
||||||
ctx.user.referenced = false;
|
if(e < 0) {
|
||||||
|
return MSGPACK_UNPACK_PARSE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
int e = template_execute(&ctx, data, len, &noff);
|
if(off != NULL) { *off = noff; }
|
||||||
if(e < 0) {
|
|
||||||
return MSGPACK_UNPACK_PARSE_ERROR;
|
if(e == 0) {
|
||||||
|
return MSGPACK_UNPACK_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*result = template_data(&ctx);
|
||||||
|
|
||||||
|
if(noff < len) {
|
||||||
|
return MSGPACK_UNPACK_EXTRA_BYTES;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MSGPACK_UNPACK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(off != NULL) { *off = noff; }
|
|
||||||
|
|
||||||
if(e == 0) {
|
|
||||||
return MSGPACK_UNPACK_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*result = template_data(&ctx);
|
|
||||||
|
|
||||||
if(noff < len) {
|
|
||||||
return MSGPACK_UNPACK_EXTRA_BYTES;
|
|
||||||
}
|
|
||||||
|
|
||||||
return MSGPACK_UNPACK_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
msgpack_unpack_return
|
msgpack_unpack_return
|
||||||
msgpack_unpack_next(msgpack_unpacked* result,
|
msgpack_unpack_next(msgpack_unpacked* result,
|
||||||
const char* data, size_t len, size_t* off)
|
const char* data, size_t len, size_t* off)
|
||||||
{
|
{
|
||||||
|
size_t noff = 0;
|
||||||
msgpack_unpacked_destroy(result);
|
msgpack_unpacked_destroy(result);
|
||||||
|
|
||||||
size_t noff = 0;
|
|
||||||
if(off != NULL) { noff = *off; }
|
if(off != NULL) { noff = *off; }
|
||||||
|
|
||||||
if(len <= noff) {
|
if(len <= noff) {
|
||||||
@@ -593,29 +603,31 @@ msgpack_unpack_next(msgpack_unpacked* result,
|
|||||||
if (!result->zone) {
|
if (!result->zone) {
|
||||||
return MSGPACK_UNPACK_NOMEM_ERROR;
|
return MSGPACK_UNPACK_NOMEM_ERROR;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
int e;
|
||||||
|
template_context ctx;
|
||||||
|
template_init(&ctx);
|
||||||
|
|
||||||
template_context ctx;
|
ctx.user.z = result->zone;
|
||||||
template_init(&ctx);
|
ctx.user.referenced = false;
|
||||||
|
|
||||||
ctx.user.z = result->zone;
|
e = template_execute(&ctx, data, len, &noff);
|
||||||
ctx.user.referenced = false;
|
if(e < 0) {
|
||||||
|
msgpack_zone_free(result->zone);
|
||||||
|
result->zone = NULL;
|
||||||
|
return MSGPACK_UNPACK_PARSE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
int e = template_execute(&ctx, data, len, &noff);
|
if(off != NULL) { *off = noff; }
|
||||||
if(e < 0) {
|
|
||||||
msgpack_zone_free(result->zone);
|
if(e == 0) {
|
||||||
result->zone = NULL;
|
return MSGPACK_UNPACK_CONTINUE;
|
||||||
return MSGPACK_UNPACK_PARSE_ERROR;
|
}
|
||||||
|
|
||||||
|
result->data = template_data(&ctx);
|
||||||
|
|
||||||
|
return MSGPACK_UNPACK_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(off != NULL) { *off = noff; }
|
|
||||||
|
|
||||||
if(e == 0) {
|
|
||||||
return MSGPACK_UNPACK_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
result->data = template_data(&ctx);
|
|
||||||
|
|
||||||
return MSGPACK_UNPACK_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(MSGPACK_OLD_COMPILER_BUS_ERROR_WORKAROUND)
|
#if defined(MSGPACK_OLD_COMPILER_BUS_ERROR_WORKAROUND)
|
||||||
|
140
src/vrefbuffer.c
140
src/vrefbuffer.c
@@ -29,15 +29,19 @@ struct msgpack_vrefbuffer_chunk {
|
|||||||
bool msgpack_vrefbuffer_init(msgpack_vrefbuffer* vbuf,
|
bool msgpack_vrefbuffer_init(msgpack_vrefbuffer* vbuf,
|
||||||
size_t ref_size, size_t chunk_size)
|
size_t ref_size, size_t chunk_size)
|
||||||
{
|
{
|
||||||
|
size_t nfirst;
|
||||||
|
struct iovec* array;
|
||||||
|
msgpack_vrefbuffer_chunk* chunk;
|
||||||
|
|
||||||
vbuf->chunk_size = chunk_size;
|
vbuf->chunk_size = chunk_size;
|
||||||
vbuf->ref_size =
|
vbuf->ref_size =
|
||||||
ref_size > MSGPACK_PACKER_MAX_BUFFER_SIZE + 1 ?
|
ref_size > MSGPACK_PACKER_MAX_BUFFER_SIZE + 1 ?
|
||||||
ref_size : MSGPACK_PACKER_MAX_BUFFER_SIZE + 1 ;
|
ref_size : MSGPACK_PACKER_MAX_BUFFER_SIZE + 1 ;
|
||||||
|
|
||||||
size_t nfirst = (sizeof(struct iovec) < 72/2) ?
|
nfirst = (sizeof(struct iovec) < 72/2) ?
|
||||||
72 / sizeof(struct iovec) : 8;
|
72 / sizeof(struct iovec) : 8;
|
||||||
|
|
||||||
struct iovec* array = (struct iovec*)malloc(
|
array = (struct iovec*)malloc(
|
||||||
sizeof(struct iovec) * nfirst);
|
sizeof(struct iovec) * nfirst);
|
||||||
if(array == NULL) {
|
if(array == NULL) {
|
||||||
return false;
|
return false;
|
||||||
@@ -47,21 +51,22 @@ bool msgpack_vrefbuffer_init(msgpack_vrefbuffer* vbuf,
|
|||||||
vbuf->end = array + nfirst;
|
vbuf->end = array + nfirst;
|
||||||
vbuf->array = array;
|
vbuf->array = array;
|
||||||
|
|
||||||
msgpack_vrefbuffer_chunk* chunk = (msgpack_vrefbuffer_chunk*)malloc(
|
chunk = (msgpack_vrefbuffer_chunk*)malloc(
|
||||||
sizeof(msgpack_vrefbuffer_chunk) + chunk_size);
|
sizeof(msgpack_vrefbuffer_chunk) + chunk_size);
|
||||||
if(chunk == NULL) {
|
if(chunk == NULL) {
|
||||||
free(array);
|
free(array);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
msgpack_vrefbuffer_inner_buffer* const ib = &vbuf->inner_buffer;
|
||||||
|
|
||||||
msgpack_vrefbuffer_inner_buffer* const ib = &vbuf->inner_buffer;
|
ib->free = chunk_size;
|
||||||
|
ib->ptr = ((char*)chunk) + sizeof(msgpack_vrefbuffer_chunk);
|
||||||
|
ib->head = chunk;
|
||||||
|
chunk->next = NULL;
|
||||||
|
|
||||||
ib->free = chunk_size;
|
return true;
|
||||||
ib->ptr = ((char*)chunk) + sizeof(msgpack_vrefbuffer_chunk);
|
}
|
||||||
ib->head = chunk;
|
|
||||||
chunk->next = NULL;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void msgpack_vrefbuffer_destroy(msgpack_vrefbuffer* vbuf)
|
void msgpack_vrefbuffer_destroy(msgpack_vrefbuffer* vbuf)
|
||||||
@@ -89,13 +94,15 @@ void msgpack_vrefbuffer_clear(msgpack_vrefbuffer* vbuf)
|
|||||||
c = n;
|
c = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
msgpack_vrefbuffer_inner_buffer* const ib = &vbuf->inner_buffer;
|
{
|
||||||
msgpack_vrefbuffer_chunk* chunk = ib->head;
|
msgpack_vrefbuffer_inner_buffer* const ib = &vbuf->inner_buffer;
|
||||||
chunk->next = NULL;
|
msgpack_vrefbuffer_chunk* chunk = ib->head;
|
||||||
ib->free = vbuf->chunk_size;
|
chunk->next = NULL;
|
||||||
ib->ptr = ((char*)chunk) + sizeof(msgpack_vrefbuffer_chunk);
|
ib->free = vbuf->chunk_size;
|
||||||
|
ib->ptr = ((char*)chunk) + sizeof(msgpack_vrefbuffer_chunk);
|
||||||
|
|
||||||
vbuf->tail = vbuf->array;
|
vbuf->tail = vbuf->array;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int msgpack_vrefbuffer_append_ref(msgpack_vrefbuffer* vbuf,
|
int msgpack_vrefbuffer_append_ref(msgpack_vrefbuffer* vbuf,
|
||||||
@@ -127,14 +134,16 @@ int msgpack_vrefbuffer_append_copy(msgpack_vrefbuffer* vbuf,
|
|||||||
const char* buf, size_t len)
|
const char* buf, size_t len)
|
||||||
{
|
{
|
||||||
msgpack_vrefbuffer_inner_buffer* const ib = &vbuf->inner_buffer;
|
msgpack_vrefbuffer_inner_buffer* const ib = &vbuf->inner_buffer;
|
||||||
|
char* m;
|
||||||
|
|
||||||
if(ib->free < len) {
|
if(ib->free < len) {
|
||||||
|
msgpack_vrefbuffer_chunk* chunk;
|
||||||
size_t sz = vbuf->chunk_size;
|
size_t sz = vbuf->chunk_size;
|
||||||
if(sz < len) {
|
if(sz < len) {
|
||||||
sz = len;
|
sz = len;
|
||||||
}
|
}
|
||||||
|
|
||||||
msgpack_vrefbuffer_chunk* chunk = (msgpack_vrefbuffer_chunk*)malloc(
|
chunk = (msgpack_vrefbuffer_chunk*)malloc(
|
||||||
sizeof(msgpack_vrefbuffer_chunk) + sz);
|
sizeof(msgpack_vrefbuffer_chunk) + sz);
|
||||||
if(chunk == NULL) {
|
if(chunk == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -146,7 +155,7 @@ int msgpack_vrefbuffer_append_copy(msgpack_vrefbuffer* vbuf,
|
|||||||
ib->ptr = ((char*)chunk) + sizeof(msgpack_vrefbuffer_chunk);
|
ib->ptr = ((char*)chunk) + sizeof(msgpack_vrefbuffer_chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* m = ib->ptr;
|
m = ib->ptr;
|
||||||
memcpy(m, buf, len);
|
memcpy(m, buf, len);
|
||||||
ib->free -= len;
|
ib->free -= len;
|
||||||
ib->ptr += len;
|
ib->ptr += len;
|
||||||
@@ -172,57 +181,60 @@ int msgpack_vrefbuffer_migrate(msgpack_vrefbuffer* vbuf, msgpack_vrefbuffer* to)
|
|||||||
|
|
||||||
empty->next = NULL;
|
empty->next = NULL;
|
||||||
|
|
||||||
|
{
|
||||||
const size_t nused = (size_t)(vbuf->tail - vbuf->array);
|
const size_t nused = (size_t)(vbuf->tail - vbuf->array);
|
||||||
if(to->tail + nused < vbuf->end) {
|
if(to->tail + nused < vbuf->end) {
|
||||||
const size_t tosize = (size_t)(to->tail - to->array);
|
struct iovec* nvec;
|
||||||
const size_t reqsize = nused + tosize;
|
const size_t tosize = (size_t)(to->tail - to->array);
|
||||||
size_t nnext = (size_t)(to->end - to->array) * 2;
|
const size_t reqsize = nused + tosize;
|
||||||
while(nnext < reqsize) {
|
size_t nnext = (size_t)(to->end - to->array) * 2;
|
||||||
size_t tmp_nnext = nnext * 2;
|
while(nnext < reqsize) {
|
||||||
if (tmp_nnext <= nnext) {
|
size_t tmp_nnext = nnext * 2;
|
||||||
nnext = reqsize;
|
if (tmp_nnext <= nnext) {
|
||||||
break;
|
nnext = reqsize;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
nnext = tmp_nnext;
|
||||||
}
|
}
|
||||||
nnext = tmp_nnext;
|
|
||||||
|
nvec = (struct iovec*)realloc(
|
||||||
|
to->array, sizeof(struct iovec)*nnext);
|
||||||
|
if(nvec == NULL) {
|
||||||
|
free(empty);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
to->array = nvec;
|
||||||
|
to->end = nvec + nnext;
|
||||||
|
to->tail = nvec + tosize;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct iovec* nvec = (struct iovec*)realloc(
|
memcpy(to->tail, vbuf->array, sizeof(struct iovec)*nused);
|
||||||
to->array, sizeof(struct iovec)*nnext);
|
|
||||||
if(nvec == NULL) {
|
to->tail += nused;
|
||||||
free(empty);
|
vbuf->tail = vbuf->array;
|
||||||
return -1;
|
|
||||||
|
{
|
||||||
|
msgpack_vrefbuffer_inner_buffer* const ib = &vbuf->inner_buffer;
|
||||||
|
msgpack_vrefbuffer_inner_buffer* const toib = &to->inner_buffer;
|
||||||
|
|
||||||
|
msgpack_vrefbuffer_chunk* last = ib->head;
|
||||||
|
while(last->next != NULL) {
|
||||||
|
last = last->next;
|
||||||
|
}
|
||||||
|
last->next = toib->head;
|
||||||
|
toib->head = ib->head;
|
||||||
|
|
||||||
|
if(toib->free < ib->free) {
|
||||||
|
toib->free = ib->free;
|
||||||
|
toib->ptr = ib->ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
ib->head = empty;
|
||||||
|
ib->free = sz;
|
||||||
|
ib->ptr = ((char*)empty) + sizeof(msgpack_vrefbuffer_chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
to->array = nvec;
|
|
||||||
to->end = nvec + nnext;
|
|
||||||
to->tail = nvec + tosize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(to->tail, vbuf->array, sizeof(struct iovec)*nused);
|
|
||||||
|
|
||||||
to->tail += nused;
|
|
||||||
vbuf->tail = vbuf->array;
|
|
||||||
|
|
||||||
|
|
||||||
msgpack_vrefbuffer_inner_buffer* const ib = &vbuf->inner_buffer;
|
|
||||||
msgpack_vrefbuffer_inner_buffer* const toib = &to->inner_buffer;
|
|
||||||
|
|
||||||
msgpack_vrefbuffer_chunk* last = ib->head;
|
|
||||||
while(last->next != NULL) {
|
|
||||||
last = last->next;
|
|
||||||
}
|
|
||||||
last->next = toib->head;
|
|
||||||
toib->head = ib->head;
|
|
||||||
|
|
||||||
if(toib->free < ib->free) {
|
|
||||||
toib->free = ib->free;
|
|
||||||
toib->ptr = ib->ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
ib->head = empty;
|
|
||||||
ib->free = sz;
|
|
||||||
ib->ptr = ((char*)empty) + sizeof(msgpack_vrefbuffer_chunk);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
25
src/zone.c
25
src/zone.c
@@ -75,6 +75,7 @@ static inline void clear_chunk_list(msgpack_zone_chunk_list* cl, size_t chunk_si
|
|||||||
void* msgpack_zone_malloc_expand(msgpack_zone* zone, size_t size)
|
void* msgpack_zone_malloc_expand(msgpack_zone* zone, size_t size)
|
||||||
{
|
{
|
||||||
msgpack_zone_chunk_list* const cl = &zone->chunk_list;
|
msgpack_zone_chunk_list* const cl = &zone->chunk_list;
|
||||||
|
msgpack_zone_chunk* chunk;
|
||||||
|
|
||||||
size_t sz = zone->chunk_size;
|
size_t sz = zone->chunk_size;
|
||||||
|
|
||||||
@@ -87,16 +88,20 @@ void* msgpack_zone_malloc_expand(msgpack_zone* zone, size_t size)
|
|||||||
sz = tmp_sz;
|
sz = tmp_sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
msgpack_zone_chunk* chunk = (msgpack_zone_chunk*)malloc(
|
chunk = (msgpack_zone_chunk*)malloc(
|
||||||
sizeof(msgpack_zone_chunk) + sz);
|
sizeof(msgpack_zone_chunk) + sz);
|
||||||
if (chunk == NULL) return NULL;
|
if (chunk == NULL) {
|
||||||
char* ptr = ((char*)chunk) + sizeof(msgpack_zone_chunk);
|
return NULL;
|
||||||
chunk->next = cl->head;
|
}
|
||||||
cl->head = chunk;
|
else {
|
||||||
cl->free = sz - size;
|
char* ptr = ((char*)chunk) + sizeof(msgpack_zone_chunk);
|
||||||
cl->ptr = ptr + size;
|
chunk->next = cl->head;
|
||||||
|
cl->head = chunk;
|
||||||
|
cl->free = sz - size;
|
||||||
|
cl->ptr = ptr + size;
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -131,6 +136,7 @@ bool msgpack_zone_push_finalizer_expand(msgpack_zone* zone,
|
|||||||
void (*func)(void* data), void* data)
|
void (*func)(void* data), void* data)
|
||||||
{
|
{
|
||||||
msgpack_zone_finalizer_array* const fa = &zone->finalizer_array;
|
msgpack_zone_finalizer_array* const fa = &zone->finalizer_array;
|
||||||
|
msgpack_zone_finalizer* tmp;
|
||||||
|
|
||||||
const size_t nused = (size_t)(fa->end - fa->array);
|
const size_t nused = (size_t)(fa->end - fa->array);
|
||||||
|
|
||||||
@@ -143,8 +149,7 @@ bool msgpack_zone_push_finalizer_expand(msgpack_zone* zone,
|
|||||||
nnext = nused * 2;
|
nnext = nused * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
msgpack_zone_finalizer* tmp =
|
tmp = (msgpack_zone_finalizer*)realloc(fa->array,
|
||||||
(msgpack_zone_finalizer*)realloc(fa->array,
|
|
||||||
sizeof(msgpack_zone_finalizer) * nnext);
|
sizeof(msgpack_zone_finalizer) * nnext);
|
||||||
if(tmp == NULL) {
|
if(tmp == NULL) {
|
||||||
return false;
|
return false;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#include <msgpack_fwd.hpp>
|
#include <msgpack.hpp>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
class enum_member {
|
class enum_member {
|
||||||
@@ -17,8 +17,6 @@ public:
|
|||||||
|
|
||||||
MSGPACK_ADD_ENUM(enum_member::flags_t);
|
MSGPACK_ADD_ENUM(enum_member::flags_t);
|
||||||
|
|
||||||
#include <msgpack.hpp>
|
|
||||||
|
|
||||||
class compatibility {
|
class compatibility {
|
||||||
public:
|
public:
|
||||||
compatibility() : str1("default"), str2("default") { }
|
compatibility() : str1("default"), str2("default") { }
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#include <msgpack_fwd.hpp>
|
#include <msgpack.hpp>
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -38,8 +38,6 @@ public:
|
|||||||
|
|
||||||
MSGPACK_ADD_ENUM(TestEnumMemberClass::TestEnumType);
|
MSGPACK_ADD_ENUM(TestEnumMemberClass::TestEnumType);
|
||||||
|
|
||||||
#include <msgpack.hpp>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
const unsigned int kLoop = 1000;
|
const unsigned int kLoop = 1000;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#include <msgpack_fwd.hpp>
|
#include <msgpack.hpp>
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
@@ -29,8 +29,6 @@ public:
|
|||||||
|
|
||||||
MSGPACK_ADD_ENUM(TestEnumClassMemberClass::TestEnumClassType);
|
MSGPACK_ADD_ENUM(TestEnumClassMemberClass::TestEnumClassType);
|
||||||
|
|
||||||
#include <msgpack.hpp>
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
const unsigned int kLoop = 10000;
|
const unsigned int kLoop = 10000;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#include <msgpack_fwd.hpp>
|
#include <msgpack.hpp>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -34,10 +34,6 @@ MSGPACK_ADD_ENUM(outer_enum_class::enum_class_test);
|
|||||||
|
|
||||||
#endif // !defined(MSGPACK_USE_CPP03)
|
#endif // !defined(MSGPACK_USE_CPP03)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <msgpack.hpp>
|
|
||||||
|
|
||||||
struct myclass {
|
struct myclass {
|
||||||
myclass() : num(0), str("default") { }
|
myclass() : num(0), str("default") { }
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#include <msgpack_fwd.hpp>
|
#include <msgpack.hpp>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
@@ -40,9 +40,6 @@ MSGPACK_ADD_ENUM(outer_enum_class::enum_class_test);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <msgpack.hpp>
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
const unsigned int kLoop = 1000;
|
const unsigned int kLoop = 1000;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user