mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-22 16:02:30 +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 typos in documents (#240)
|
||||
* Update CHANGELOG.md for version 1.0.0 (#242)
|
||||
|
@@ -98,65 +98,38 @@ LIST (APPEND msgpack_HEADERS
|
||||
IF (MSGPACK_ENABLE_CXX)
|
||||
LIST (APPEND msgpack_HEADERS
|
||||
include/msgpack.hpp
|
||||
include/msgpack_fwd.hpp
|
||||
include/msgpack/adaptor/adaptor_base.hpp
|
||||
include/msgpack/adaptor/bool.hpp
|
||||
include/msgpack/adaptor/bool_fwd.hpp
|
||||
include/msgpack/adaptor/char_ptr.hpp
|
||||
include/msgpack/adaptor/char_ptr_fwd.hpp
|
||||
include/msgpack/adaptor/check_container_size.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_fwd.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_fwd.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_fwd.hpp
|
||||
include/msgpack/adaptor/define.hpp
|
||||
include/msgpack/adaptor/deque.hpp
|
||||
include/msgpack/adaptor/deque_fwd.hpp
|
||||
include/msgpack/adaptor/detail/cpp03_define.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_msgpack_tuple.hpp
|
||||
include/msgpack/adaptor/detail/cpp11_msgpack_tuple_fwd.hpp
|
||||
include/msgpack/adaptor/fixint.hpp
|
||||
include/msgpack/adaptor/fixint_fwd.hpp
|
||||
include/msgpack/adaptor/float.hpp
|
||||
include/msgpack/adaptor/float_fwd.hpp
|
||||
include/msgpack/adaptor/int.hpp
|
||||
include/msgpack/adaptor/int_fwd.hpp
|
||||
include/msgpack/adaptor/list.hpp
|
||||
include/msgpack/adaptor/list_fwd.hpp
|
||||
include/msgpack/adaptor/map.hpp
|
||||
include/msgpack/adaptor/map_fwd.hpp
|
||||
include/msgpack/adaptor/msgpack_tuple.hpp
|
||||
include/msgpack/adaptor/msgpack_tuple_fwd.hpp
|
||||
include/msgpack/adaptor/nil.hpp
|
||||
include/msgpack/adaptor/nil_fwd.hpp
|
||||
include/msgpack/adaptor/pair.hpp
|
||||
include/msgpack/adaptor/pair_fwd.hpp
|
||||
include/msgpack/adaptor/raw.hpp
|
||||
include/msgpack/adaptor/raw_fwd.hpp
|
||||
include/msgpack/adaptor/set.hpp
|
||||
include/msgpack/adaptor/set_fwd.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_fwd.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_fwd.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_fwd.hpp
|
||||
include/msgpack/cpp_config.hpp
|
||||
include/msgpack/detail/cpp03_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 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 "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 ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_c
|
||||
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 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 "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 ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile_cpp
|
||||
VERBATIM
|
||||
|
@@ -1,7 +1,7 @@
|
||||
`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.
|
||||
|
||||
@@ -201,7 +201,7 @@ the binaries:' text box.
|
||||
### Documentation
|
||||
|
||||
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
|
||||
------------
|
||||
|
@@ -19,8 +19,8 @@
|
||||
#define MSGPACK_CPP03_DEFINE_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/adaptor/msgpack_tuple_fwd.hpp"
|
||||
#include "msgpack/adaptor/int_fwd.hpp"
|
||||
#include "msgpack/adaptor/msgpack_tuple.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
|
||||
#define MSGPACK_DEFINE(...) \
|
||||
@@ -40,44 +40,57 @@
|
||||
}
|
||||
|
||||
// MSGPACK_ADD_ENUM must be used in the global namespace.
|
||||
#define MSGPACK_ADD_ENUM(enum) \
|
||||
#define MSGPACK_ADD_ENUM(enum_name) \
|
||||
namespace msgpack { \
|
||||
/** @cond */ \
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) { \
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, enum& v) \
|
||||
{ \
|
||||
/** @endcond */ \
|
||||
namespace adaptor { \
|
||||
template<> \
|
||||
struct convert<enum_name> { \
|
||||
msgpack::object const& operator()(msgpack::object const& o, enum_name& v) const {\
|
||||
int tmp; \
|
||||
o >> tmp; \
|
||||
v = static_cast<enum>(tmp); \
|
||||
v = static_cast<enum_name>(tmp); \
|
||||
return o; \
|
||||
} \
|
||||
inline void operator<< (msgpack::object& o, const enum& v) \
|
||||
{ \
|
||||
}; \
|
||||
template<> \
|
||||
struct object<enum_name> { \
|
||||
void operator()(msgpack::object& o, const enum_name& v) const {\
|
||||
o << static_cast<int>(v); \
|
||||
} \
|
||||
inline void operator<< (msgpack::object::with_zone& o, const enum& v) \
|
||||
{ \
|
||||
}; \
|
||||
template<> \
|
||||
struct object_with_zone<enum_name> { \
|
||||
void operator()(msgpack::object::with_zone& o, const enum_name& v) const { \
|
||||
o << static_cast<int>(v); \
|
||||
} \
|
||||
namespace detail { \
|
||||
}; \
|
||||
template<> \
|
||||
struct pack<enum_name> { \
|
||||
template <typename Stream> \
|
||||
struct packer_serializer<Stream, enum> { \
|
||||
static msgpack::packer<Stream>& pack(msgpack::packer<Stream>& o, const enum& v) { \
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const enum_name& v) const { \
|
||||
return o << static_cast<int>(v); \
|
||||
} \
|
||||
}; \
|
||||
} \
|
||||
/** @cond */ \
|
||||
} \
|
||||
/** @endcond */ \
|
||||
}
|
||||
|
||||
namespace msgpack {
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
namespace type {
|
||||
|
||||
|
||||
/// @cond
|
||||
<% GENERATION_LIMIT = 31 %>
|
||||
template <typename A0 = void<%1.upto(GENERATION_LIMIT+1) {|i|%>, typename A<%=i%> = void<%}%>>
|
||||
struct define;
|
||||
|
||||
/// @endcond
|
||||
|
||||
template <>
|
||||
struct define<> {
|
||||
@@ -99,6 +112,8 @@ struct define<> {
|
||||
o->via.array.size = 0;
|
||||
}
|
||||
};
|
||||
|
||||
/// @cond
|
||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||
template <typename A0<%1.upto(i) {|j|%>, typename 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%>;<%}%>
|
||||
};
|
||||
<%}%>
|
||||
/// @endcond
|
||||
|
||||
inline define<> make_define()
|
||||
{
|
||||
return define<>();
|
||||
}
|
||||
|
||||
/// @cond
|
||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||
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%><%}%>)
|
||||
@@ -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%><%}%>);
|
||||
}
|
||||
<%}%>
|
||||
/// @endcond
|
||||
|
||||
} // namespace type
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
} // namespace msgpack
|
||||
|
||||
|
||||
|
@@ -20,10 +20,13 @@
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace type {
|
||||
|
||||
@@ -31,8 +34,10 @@ namespace type {
|
||||
// FIXME operator!=
|
||||
<% 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;
|
||||
/// @endcond
|
||||
|
||||
template <typename Tuple, int N>
|
||||
struct tuple_element;
|
||||
@@ -67,6 +72,7 @@ struct tuple_type<const T&> {
|
||||
typedef const T& transparent_reference;
|
||||
};
|
||||
|
||||
/// @cond
|
||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||
<%0.upto(i) {|j|%>
|
||||
template <typename A0<%1.upto(i) {|k|%>, typename A<%=k%><%}%>>
|
||||
@@ -91,6 +97,7 @@ private:
|
||||
};
|
||||
<%}%>
|
||||
<%}%>
|
||||
/// @endcond
|
||||
|
||||
template <>
|
||||
struct tuple<> {
|
||||
@@ -98,6 +105,8 @@ struct tuple<> {
|
||||
tuple(msgpack::object const& o) { o.convert(*this); }
|
||||
typedef tuple<> value_type;
|
||||
};
|
||||
|
||||
/// @cond
|
||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||
template <typename A0<%1.upto(i) {|j|%>, typename 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)
|
||||
{ return t.template get<N>(); }
|
||||
<%}%>
|
||||
/// @endcond
|
||||
|
||||
inline tuple<> make_tuple()
|
||||
{
|
||||
return tuple<>();
|
||||
}
|
||||
|
||||
/// @cond
|
||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||
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%><%}%>)
|
||||
@@ -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%><%}%>);
|
||||
}
|
||||
<%}%>
|
||||
/// @endcond
|
||||
|
||||
} // namespace type
|
||||
|
||||
inline msgpack::object const& operator>> (
|
||||
namespace adaptor {
|
||||
|
||||
template <>
|
||||
struct convert<type::tuple<> > {
|
||||
msgpack::object const& operator()(
|
||||
msgpack::object const& o,
|
||||
type::tuple<>&) {
|
||||
type::tuple<>&) const {
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
/// @cond
|
||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||
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,
|
||||
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.via.array.size < <%=i+1%>) { throw msgpack::type_error(); }
|
||||
<%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.
|
||||
o.via.array.ptr[<%=j%>].msgpack::object::convert<typename type::tuple_type<A<%=j%>>::type>(v.template get<<%=j%>>());<%}%>
|
||||
return o;
|
||||
}
|
||||
};
|
||||
<%}%>
|
||||
/// @endcond
|
||||
|
||||
template <>
|
||||
struct pack<type::tuple<> > {
|
||||
template <typename Stream>
|
||||
inline const msgpack::packer<Stream>& operator<< (
|
||||
msgpack::packer<Stream>& operator()(
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<>&) {
|
||||
const type::tuple<>&) const {
|
||||
o.pack_array(0);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
/// @cond
|
||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||
template <typename Stream, typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||
inline const msgpack::packer<Stream>& operator<< (
|
||||
template <typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||
struct pack<type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> > {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) {
|
||||
const type::tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>>& v) const {
|
||||
o.pack_array(<%=i+1%>);
|
||||
<%0.upto(i) {|j|%>
|
||||
o.pack(v.template get<<%=j%>>());<%}%>
|
||||
return o;
|
||||
}
|
||||
};
|
||||
<%}%>
|
||||
/// @endcond
|
||||
|
||||
inline void operator<< (
|
||||
template <>
|
||||
struct object_with_zone<type::tuple<> > {
|
||||
void operator()(
|
||||
msgpack::object::with_zone& o,
|
||||
const type::tuple<>&) {
|
||||
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%><%}%>>
|
||||
inline void operator<< (
|
||||
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 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)
|
||||
/// @endcond
|
||||
|
||||
} // 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
|
||||
|
@@ -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 %>
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
class zone {
|
||||
struct finalizer {
|
||||
@@ -179,10 +181,12 @@ public:
|
||||
{
|
||||
::operator delete(p, place);
|
||||
}
|
||||
/// @cond
|
||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||
template <typename T<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||
T* allocate(<%=(1..i).map{|j|"A#{j} a#{j}"}.join(', ')%>);
|
||||
<%}%>
|
||||
/// @endcond
|
||||
|
||||
private:
|
||||
void undo_allocate(size_t size);
|
||||
@@ -304,6 +308,7 @@ inline void zone::undo_allocate(size_t size)
|
||||
m_chunk_list.m_free += size;
|
||||
}
|
||||
|
||||
/// @cond
|
||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||
template <typename T<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||
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)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -8,8 +8,6 @@ typedef struct receiver {
|
||||
size_t rest;
|
||||
} receiver;
|
||||
|
||||
receiver r;
|
||||
|
||||
void receiver_init(receiver *r) {
|
||||
msgpack_packer pk;
|
||||
|
||||
@@ -52,6 +50,8 @@ void unpack(receiver* r) {
|
||||
msgpack_unpack_return ret;
|
||||
char* buf;
|
||||
size_t recv_len;
|
||||
int recv_count = 0;
|
||||
int i = 0;
|
||||
|
||||
msgpack_unpacked_init(&result);
|
||||
if (msgpack_unpacker_buffer_capacity(unp) < EACH_RECV_SIZE) {
|
||||
@@ -64,16 +64,14 @@ void unpack(receiver* r) {
|
||||
msgpack_unpacker_buffer_consumed(unp, recv_len);
|
||||
|
||||
|
||||
int recv_count = 0;
|
||||
while (recv_len > 0) {
|
||||
int i = 0;
|
||||
printf("receive count: %d %zd bytes received.:\n", recv_count++, recv_len);
|
||||
printf("receive count: %d %zd bytes received.\n", recv_count++, recv_len);
|
||||
ret = msgpack_unpacker_next(unp, &result);
|
||||
while (ret == MSGPACK_UNPACK_SUCCESS) {
|
||||
msgpack_object obj = result.data;
|
||||
|
||||
/* Use obj. */
|
||||
printf("Object no %d:\n", i++);
|
||||
printf("Object no %d:\n", ++i);
|
||||
msgpack_object_print(stdout, obj);
|
||||
printf("\n");
|
||||
/* If you want to allocate something on the zone, you can use zone. */
|
||||
@@ -110,10 +108,16 @@ int main(void) {
|
||||
/* Output */
|
||||
|
||||
/*
|
||||
receive count: 0 4 bytes received.
|
||||
receive count: 1 4 bytes received.
|
||||
receive count: 2 4 bytes received.
|
||||
Object no 1:
|
||||
[1, true, "example"]
|
||||
receive count: 3 4 bytes received.
|
||||
receive count: 4 4 bytes received.
|
||||
Object no 2:
|
||||
"second"
|
||||
receive count: 5 1 bytes received.
|
||||
Object no 3:
|
||||
[42, false]
|
||||
*/
|
||||
|
@@ -3,12 +3,15 @@
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* msgpack::sbuffer is a simple buffer implementation. */
|
||||
msgpack_sbuffer sbuf;
|
||||
msgpack_packer pk;
|
||||
msgpack_zone mempool;
|
||||
msgpack_object deserialized;
|
||||
|
||||
/* msgpack::sbuffer is a simple buffer implementation. */
|
||||
msgpack_sbuffer_init(&sbuf);
|
||||
|
||||
/* serialize values into the buffer using msgpack_sbuffer_write callback function. */
|
||||
msgpack_packer pk;
|
||||
msgpack_packer_init(&pk, &sbuf, msgpack_sbuffer_write);
|
||||
|
||||
msgpack_pack_array(&pk, 3);
|
||||
@@ -19,10 +22,8 @@ int main(void)
|
||||
|
||||
/* deserialize the buffer into msgpack_object instance. */
|
||||
/* deserialized object is valid during the msgpack_zone instance alive. */
|
||||
msgpack_zone mempool;
|
||||
msgpack_zone_init(&mempool, 2048);
|
||||
|
||||
msgpack_object deserialized;
|
||||
msgpack_unpack(sbuf.data, sbuf.size, NULL, &mempool, &deserialized);
|
||||
|
||||
/* print the deserialized object. */
|
||||
|
@@ -1,13 +1,16 @@
|
||||
#include <msgpack.h>
|
||||
#include <assert.h>
|
||||
|
||||
void test()
|
||||
{
|
||||
size_t size = 10000000;
|
||||
msgpack_sbuffer buf;
|
||||
msgpack_packer * pk;
|
||||
size_t upk_pos = 0;
|
||||
msgpack_unpacked msg;
|
||||
|
||||
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);
|
||||
{
|
||||
@@ -17,9 +20,6 @@ void test()
|
||||
}
|
||||
msgpack_packer_free(pk);
|
||||
|
||||
|
||||
size_t upk_pos = 0;
|
||||
msgpack_unpacked msg;
|
||||
msgpack_unpacked_init(&msg);
|
||||
|
||||
while (msgpack_unpack_next(&msg, buf.data, buf.size, &upk_pos)) {
|
||||
|
@@ -1,14 +1,17 @@
|
||||
#include <msgpack.h>
|
||||
#include <assert.h>
|
||||
|
||||
void test()
|
||||
{
|
||||
uint64_t test_u64 = 0xFFF0000000000001LL;
|
||||
size_t size = 10000000;
|
||||
msgpack_sbuffer buf;
|
||||
msgpack_packer * pk;
|
||||
size_t upk_pos = 0;
|
||||
msgpack_unpacked msg;
|
||||
|
||||
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);
|
||||
{
|
||||
@@ -18,9 +21,6 @@ void test()
|
||||
}
|
||||
msgpack_packer_free(pk);
|
||||
|
||||
|
||||
size_t upk_pos = 0;
|
||||
msgpack_unpacked msg;
|
||||
msgpack_unpacked_init(&msg);
|
||||
|
||||
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;
|
||||
|
||||
/* Use obj. */
|
||||
printf("Object no %d:\n", i++);
|
||||
printf("Object no %d:\n", ++i);
|
||||
msgpack_object_print(stdout, obj);
|
||||
printf("\n");
|
||||
/* If you want to allocate something on the zone, you can use zone. */
|
||||
@@ -72,4 +72,5 @@ Object no 2:
|
||||
"second"
|
||||
Object no 3:
|
||||
[42, false]
|
||||
All msgpack_object in the buffer is consumed.
|
||||
*/
|
||||
|
@@ -21,8 +21,7 @@
|
||||
#include <sstream>
|
||||
#include <cassert>
|
||||
|
||||
// msgpack.hpp is also ok
|
||||
#include <msgpack_fwd.hpp>
|
||||
#include <msgpack.hpp>
|
||||
|
||||
|
||||
class my_class {
|
||||
@@ -57,8 +56,6 @@ void print(std::string const& buf) {
|
||||
std::cout << std::dec << std::endl;
|
||||
}
|
||||
|
||||
#include <msgpack.hpp>
|
||||
|
||||
int main() {
|
||||
{ // pack, unpack
|
||||
my_class my("John Smith", 42);
|
||||
|
@@ -21,27 +21,6 @@
|
||||
#include <sstream>
|
||||
#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>
|
||||
|
||||
class my_class {
|
||||
@@ -63,14 +42,14 @@ private:
|
||||
int age_;
|
||||
};
|
||||
|
||||
|
||||
// definitions
|
||||
|
||||
// User defined class template specialization
|
||||
namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS) {
|
||||
namespace adaptor {
|
||||
|
||||
inline object const& operator>> (msgpack::object const& o, my_class& v) {
|
||||
template<>
|
||||
struct convert<my_class> {
|
||||
msgpack::object const& operator()(msgpack::object const& o, my_class& v) const {
|
||||
if (o.type != msgpack::type::ARRAY) throw msgpack::type_error();
|
||||
if (o.via.array.size != 2) throw msgpack::type_error();
|
||||
v = my_class(
|
||||
@@ -78,25 +57,33 @@ inline object const& operator>> (msgpack::object const& o, my_class& v) {
|
||||
o.via.array.ptr[1].as<int>());
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<>
|
||||
struct pack<my_class> {
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (msgpack::packer<Stream>& o, my_class const& v) {
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object::with_zone& o, my_class const& v) {
|
||||
template <>
|
||||
struct object_with_zone<my_class> {
|
||||
void operator()(msgpack::object::with_zone& o, my_class const& v) const {
|
||||
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 = static_cast<msgpack::object*>(
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -15,11 +15,12 @@
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
#include <msgpack_fwd.hpp>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
#include <msgpack.hpp>
|
||||
|
||||
enum my_enum {
|
||||
elem1,
|
||||
elem2,
|
||||
@@ -28,8 +29,6 @@ enum my_enum {
|
||||
|
||||
MSGPACK_ADD_ENUM(my_enum);
|
||||
|
||||
#include <msgpack.hpp>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
{ // pack, unpack
|
||||
|
@@ -20,6 +20,8 @@
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
// This example uses obsolete APIs
|
||||
// See protocol_new.cpp
|
||||
namespace myprotocol {
|
||||
using namespace msgpack::type;
|
||||
using msgpack::define;
|
||||
|
@@ -23,3 +23,4 @@
|
||||
#include "msgpack/sbuffer.hpp"
|
||||
#include "msgpack/vrefbuffer.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
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include <vector>
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, bool& v)
|
||||
{
|
||||
namespace adaptor {
|
||||
|
||||
template <>
|
||||
struct convert<bool> {
|
||||
msgpack::object const& operator()(msgpack::object const& o, bool& v) const {
|
||||
if(o.type != msgpack::type::BOOLEAN) { throw msgpack::type_error(); }
|
||||
v = o.via.boolean;
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<bool> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const bool& 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& o, bool v)
|
||||
{
|
||||
template <>
|
||||
struct object<bool> {
|
||||
void operator()(msgpack::object& o, bool v) const {
|
||||
o.type = msgpack::type::BOOLEAN;
|
||||
o.via.boolean = v;
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object::with_zone& o, bool v)
|
||||
{ static_cast<msgpack::object&>(o) << 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)
|
||||
/// @endcond
|
||||
|
||||
} // 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,19 +26,26 @@
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
template <>
|
||||
struct pack<const char*> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const char* v)
|
||||
{
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object::with_zone& o, const char* v)
|
||||
{
|
||||
template <>
|
||||
struct object_with_zone<const char*> {
|
||||
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));
|
||||
@@ -46,32 +53,112 @@ inline void operator<< (msgpack::object::with_zone& o, const char* v)
|
||||
o.via.str.size = size;
|
||||
std::memcpy(ptr, v, size);
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object& o, const char* v)
|
||||
{
|
||||
template <>
|
||||
struct object<const char*> {
|
||||
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 <>
|
||||
struct pack<char*> {
|
||||
template <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, char* v)
|
||||
{
|
||||
return msgpack::operator<<(o, static_cast<const char*>(v));
|
||||
packer<Stream>& operator()(packer<Stream>& o, char* v) const {
|
||||
return o << static_cast<const char*>(v);
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (object::with_zone& o, char* v)
|
||||
{
|
||||
msgpack::operator<<(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);
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (object& o, char* v)
|
||||
{
|
||||
msgpack::operator<<(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)
|
||||
/// @endcond
|
||||
|
||||
} // 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 {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
struct container_size_overflow : public std::runtime_error {
|
||||
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)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -20,17 +20,22 @@
|
||||
#define MSGPACK_CPP11_ARRAY_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
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>> {
|
||||
msgpack::object const& operator()(msgpack::object const& o, std::array<T, N>& v) const {
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
if(o.via.array.size != N) { throw msgpack::type_error(); }
|
||||
if(o.via.array.size > 0) {
|
||||
@@ -45,17 +50,22 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::array<T
|
||||
}
|
||||
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) {
|
||||
template <typename T, std::size_t N>
|
||||
struct pack<std::array<T, N>> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::array<T, N>& v) const {
|
||||
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>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::array<T, N>& v) {
|
||||
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;
|
||||
@@ -68,8 +78,13 @@ inline void operator<< (msgpack::object::with_zone& o, const std::array<T, N>& v
|
||||
for (auto const& e : v) *p++ = msgpack::object(e, o.zone);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -19,18 +19,22 @@
|
||||
#define MSGPACK_TYPE_ARRAY_CHAR_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
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) {
|
||||
case msgpack::type::BIN:
|
||||
if(o.via.bin.size != N) { throw msgpack::type_error(); }
|
||||
@@ -46,29 +50,33 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::array<c
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Stream, std::size_t N>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::array<char, N>& v)
|
||||
{
|
||||
template <std::size_t N>
|
||||
struct pack<std::array<char, N>> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::array<char, N>& v) const {
|
||||
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>
|
||||
inline void operator<< (msgpack::object& 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());
|
||||
o.type = msgpack::type::BIN;
|
||||
o.via.bin.ptr = v.data();
|
||||
o.via.bin.size = size;
|
||||
}
|
||||
};
|
||||
|
||||
template <std::size_t N>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::array<char, N>& v)
|
||||
{
|
||||
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));
|
||||
@@ -76,8 +84,13 @@ inline void operator<< (msgpack::object::with_zone& o, const std::array<char, N>
|
||||
o.via.bin.size = size;
|
||||
std::memcpy(ptr, v.data(), size);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -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,18 +20,22 @@
|
||||
#define MSGPACK_CPP11_FORWARD_LIST_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <forward_list>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
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(); }
|
||||
v.resize(o.via.array.size);
|
||||
msgpack::object* p = o.via.array.ptr;
|
||||
@@ -41,19 +45,22 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::forward
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::forward_list<T>& v)
|
||||
{
|
||||
template <typename T>
|
||||
struct pack<std::forward_list<T>> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::forward_list<T>& v) const {
|
||||
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>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::forward_list<T>& v)
|
||||
{
|
||||
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;
|
||||
@@ -67,8 +74,13 @@ inline void operator<< (msgpack::object::with_zone& o, const std::forward_list<T
|
||||
for(auto const& e : v) *p++ = msgpack::object(e, o.zone);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // 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
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <tuple>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
// --- Pack from tuple to packer stream ---
|
||||
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>
|
||||
inline const msgpack::packer<Stream>& operator<< (
|
||||
template <typename... Args>
|
||||
struct pack<std::tuple<Args...>> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(
|
||||
msgpack::packer<Stream>& o,
|
||||
const std::tuple<Args...>& v) {
|
||||
const std::tuple<Args...>& v) const {
|
||||
uint32_t size = checked_get_container_size(sizeof...(Args));
|
||||
o.pack_array(size);
|
||||
StdTuplePacker<Stream, decltype(v), sizeof...(Args)>::pack(o, v);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
// --- Convert from tuple to object ---
|
||||
|
||||
@@ -96,15 +104,21 @@ struct StdTupleConverter<Tuple, 0> {
|
||||
}
|
||||
};
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
template <typename... Args>
|
||||
inline msgpack::object const& operator>> (
|
||||
struct convert<std::tuple<Args...>> {
|
||||
msgpack::object const& operator()(
|
||||
msgpack::object const& o,
|
||||
std::tuple<Args...>& v) {
|
||||
std::tuple<Args...>& v) const {
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
if(o.via.array.size < sizeof...(Args)) { throw msgpack::type_error(); }
|
||||
StdTupleConverter<decltype(v), sizeof...(Args)>::convert(o, v);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
// --- Convert from tuple to object with zone ---
|
||||
template <typename Tuple, std::size_t N>
|
||||
@@ -134,18 +148,26 @@ struct StdTupleToObjectWithZone<Tuple, 0> {
|
||||
}
|
||||
};
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
template <typename... Args>
|
||||
inline void operator<< (
|
||||
struct object_with_zone<std::tuple<Args...>> {
|
||||
void operator()(
|
||||
msgpack::object::with_zone& o,
|
||||
std::tuple<Args...> const& v) {
|
||||
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)
|
||||
/// @endcond
|
||||
|
||||
} // 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,18 +19,22 @@
|
||||
#define MSGPACK_TYPE_UNORDERED_MAP_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
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(); }
|
||||
msgpack::object_kv* p(o.via.map.ptr);
|
||||
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||
@@ -43,10 +47,12 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::unorder
|
||||
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)
|
||||
{
|
||||
template <typename K, typename V>
|
||||
struct pack<std::unordered_map<K, V>> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::unordered_map<K,V>& v) const {
|
||||
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());
|
||||
@@ -56,10 +62,11 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K, typename V>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::unordered_map<K,V>& 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;
|
||||
@@ -79,11 +86,12 @@ inline void operator<< (msgpack::object::with_zone& o, const std::unordered_map<
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
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(); }
|
||||
msgpack::object_kv* p(o.via.map.ptr);
|
||||
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||
@@ -97,10 +105,12 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::unorder
|
||||
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)
|
||||
{
|
||||
template <typename K, typename V>
|
||||
struct pack<std::unordered_multimap<K, V>> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::unordered_multimap<K,V>& v) const {
|
||||
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());
|
||||
@@ -110,10 +120,11 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K, typename V>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::unordered_multimap<K,V>& 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;
|
||||
@@ -133,8 +144,13 @@ inline void operator<< (msgpack::object::with_zone& o, const std::unordered_mult
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -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,18 +19,22 @@
|
||||
#define MSGPACK_TYPE_UNORDERED_SET_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
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(); }
|
||||
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
||||
msgpack::object* const pbegin = o.via.array.ptr;
|
||||
@@ -42,10 +46,12 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::unorder
|
||||
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)
|
||||
{
|
||||
template <typename T>
|
||||
struct pack<std::unordered_set<T>> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::unordered_set<T>& v) const {
|
||||
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());
|
||||
@@ -54,10 +60,11 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::unordered_set<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;
|
||||
if(v.empty()) {
|
||||
o.via.array.ptr = nullptr;
|
||||
@@ -76,11 +83,12 @@ inline void operator<< (msgpack::object::with_zone& o, const std::unordered_set<
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::unordered_multiset<T>& v)
|
||||
{
|
||||
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;
|
||||
@@ -92,10 +100,12 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::unorder
|
||||
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)
|
||||
{
|
||||
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());
|
||||
@@ -104,10 +114,11 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::unordered_multiset<T>& v)
|
||||
{
|
||||
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;
|
||||
@@ -126,8 +137,13 @@ inline void operator<< (msgpack::object::with_zone& o, const std::unordered_mult
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -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,18 +19,22 @@
|
||||
#define MSGPACK_TYPE_DEQUE_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <deque>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
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(); }
|
||||
v.resize(o.via.array.size);
|
||||
msgpack::object* p = o.via.array.ptr;
|
||||
@@ -41,10 +45,12 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::deque<T
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::deque<T>& v)
|
||||
{
|
||||
template <typename T>
|
||||
struct pack<std::deque<T> > {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::deque<T>& v) const {
|
||||
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());
|
||||
@@ -53,10 +59,11 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::deque<T>& v)
|
||||
{
|
||||
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;
|
||||
@@ -75,8 +82,13 @@ inline void operator<< (msgpack::object::with_zone& o, const std::deque<T>& v)
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // 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
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/adaptor/msgpack_tuple_fwd.hpp"
|
||||
#include "msgpack/adaptor/int_fwd.hpp"
|
||||
#include "msgpack/adaptor/msgpack_tuple.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
|
||||
#define MSGPACK_DEFINE(...) \
|
||||
@@ -40,44 +40,57 @@
|
||||
}
|
||||
|
||||
// MSGPACK_ADD_ENUM must be used in the global namespace.
|
||||
#define MSGPACK_ADD_ENUM(enum) \
|
||||
#define MSGPACK_ADD_ENUM(enum_name) \
|
||||
namespace msgpack { \
|
||||
/** @cond */ \
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) { \
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, enum& v) \
|
||||
{ \
|
||||
/** @endcond */ \
|
||||
namespace adaptor { \
|
||||
template<> \
|
||||
struct convert<enum_name> { \
|
||||
msgpack::object const& operator()(msgpack::object const& o, enum_name& v) const {\
|
||||
int tmp; \
|
||||
o >> tmp; \
|
||||
v = static_cast<enum>(tmp); \
|
||||
v = static_cast<enum_name>(tmp); \
|
||||
return o; \
|
||||
} \
|
||||
inline void operator<< (msgpack::object& o, const enum& v) \
|
||||
{ \
|
||||
}; \
|
||||
template<> \
|
||||
struct object<enum_name> { \
|
||||
void operator()(msgpack::object& o, const enum_name& v) const {\
|
||||
o << static_cast<int>(v); \
|
||||
} \
|
||||
inline void operator<< (msgpack::object::with_zone& o, const enum& v) \
|
||||
{ \
|
||||
}; \
|
||||
template<> \
|
||||
struct object_with_zone<enum_name> { \
|
||||
void operator()(msgpack::object::with_zone& o, const enum_name& v) const { \
|
||||
o << static_cast<int>(v); \
|
||||
} \
|
||||
namespace detail { \
|
||||
}; \
|
||||
template<> \
|
||||
struct pack<enum_name> { \
|
||||
template <typename Stream> \
|
||||
struct packer_serializer<Stream, enum> { \
|
||||
static msgpack::packer<Stream>& pack(msgpack::packer<Stream>& o, const enum& v) { \
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const enum_name& v) const { \
|
||||
return o << static_cast<int>(v); \
|
||||
} \
|
||||
}; \
|
||||
} \
|
||||
/** @cond */ \
|
||||
} \
|
||||
/** @endcond */ \
|
||||
}
|
||||
|
||||
namespace msgpack {
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
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>
|
||||
struct define;
|
||||
|
||||
/// @endcond
|
||||
|
||||
template <>
|
||||
struct define<> {
|
||||
@@ -100,6 +113,8 @@ struct define<> {
|
||||
}
|
||||
};
|
||||
|
||||
/// @cond
|
||||
|
||||
template <typename A0>
|
||||
struct define<A0> {
|
||||
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;
|
||||
};
|
||||
|
||||
/// @endcond
|
||||
|
||||
inline define<> make_define()
|
||||
{
|
||||
return define<>();
|
||||
}
|
||||
|
||||
/// @cond
|
||||
|
||||
template <typename 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);
|
||||
}
|
||||
|
||||
/// @endcond
|
||||
|
||||
} // namespace type
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
} // 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
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
|
||||
// for MSGPACK_ADD_ENUM
|
||||
#include "msgpack/adaptor/int_fwd.hpp"
|
||||
#include "msgpack/adaptor/int.hpp"
|
||||
|
||||
#include <type_traits>
|
||||
#include <tuple>
|
||||
@@ -44,39 +44,52 @@
|
||||
}
|
||||
|
||||
// MSGPACK_ADD_ENUM must be used in the global namespace.
|
||||
#define MSGPACK_ADD_ENUM(enum) \
|
||||
#define MSGPACK_ADD_ENUM(enum_name) \
|
||||
namespace msgpack { \
|
||||
/** @cond */ \
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) { \
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, enum& v) \
|
||||
{ \
|
||||
std::underlying_type<enum>::type tmp; \
|
||||
/** @endcond */ \
|
||||
namespace adaptor { \
|
||||
template<> \
|
||||
struct convert<enum_name> { \
|
||||
msgpack::object const& operator()(msgpack::object const& o, enum_name& v) const { \
|
||||
std::underlying_type<enum_name>::type tmp; \
|
||||
o >> tmp; \
|
||||
v = static_cast<enum>(tmp); \
|
||||
v = static_cast<enum_name>(tmp); \
|
||||
return o; \
|
||||
} \
|
||||
inline void operator<< (msgpack::object& o, const enum& v) \
|
||||
{ \
|
||||
auto tmp = static_cast<std::underlying_type<enum>::type>(v); \
|
||||
}; \
|
||||
template<> \
|
||||
struct object<enum_name> { \
|
||||
void operator()(msgpack::object& o, const enum_name& v) const { \
|
||||
auto tmp = static_cast<std::underlying_type<enum_name>::type>(v); \
|
||||
o << tmp; \
|
||||
} \
|
||||
inline void operator<< (msgpack::object::with_zone& o, const enum& v) \
|
||||
{ \
|
||||
auto tmp = static_cast<std::underlying_type<enum>::type>(v); \
|
||||
}; \
|
||||
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; \
|
||||
} \
|
||||
namespace detail { \
|
||||
}; \
|
||||
template <> \
|
||||
struct pack<enum_name> { \
|
||||
template <typename Stream> \
|
||||
struct packer_serializer<Stream, enum> { \
|
||||
static msgpack::packer<Stream>& pack(msgpack::packer<Stream>& o, const enum& v) { \
|
||||
return o << static_cast<std::underlying_type<enum>::type>(v); \
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const enum_name& v) const { \
|
||||
return o << static_cast<std::underlying_type<enum_name>::type>(v); \
|
||||
} \
|
||||
}; \
|
||||
} \
|
||||
/** @cond */ \
|
||||
} \
|
||||
/** @endcond */ \
|
||||
}
|
||||
|
||||
namespace msgpack {
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
namespace type {
|
||||
|
||||
template <typename Tuple, std::size_t N>
|
||||
@@ -178,7 +191,9 @@ define<Args...> make_define(Args&... args)
|
||||
}
|
||||
|
||||
} // namespace type
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
} // namespace msgpack
|
||||
|
||||
#endif // MSGPACK_CPP11_DEFINE_HPP
|
||||
|
@@ -25,7 +25,9 @@
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace type {
|
||||
// tuple
|
||||
@@ -119,14 +121,21 @@ struct MsgpackTuplePacker<Stream, Tuple, 0> {
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Stream, typename... Args>
|
||||
const msgpack::packer<Stream>& operator<< (
|
||||
namespace adaptor {
|
||||
|
||||
template <typename... Args>
|
||||
struct pack<type::tuple<Args...>> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<Args...>& v) {
|
||||
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 ---
|
||||
|
||||
@@ -157,15 +166,21 @@ struct MsgpackTupleConverter<Tuple, 0> {
|
||||
}
|
||||
};
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
template <typename... Args>
|
||||
msgpack::object const& operator>> (
|
||||
struct convert<type::tuple<Args...>> {
|
||||
msgpack::object const& operator()(
|
||||
msgpack::object const& o,
|
||||
type::tuple<Args...>& v) {
|
||||
type::tuple<Args...>& v) const {
|
||||
if(o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
if(o.via.array.size < sizeof...(Args)) { throw msgpack::type_error(); }
|
||||
MsgpackTupleConverter<decltype(v), sizeof...(Args)>::convert(o, v);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
// --- Convert from tuple to object with zone ---
|
||||
template <typename Tuple, std::size_t N>
|
||||
@@ -195,17 +210,25 @@ struct MsgpackTupleToObjectWithZone<Tuple, 0> {
|
||||
}
|
||||
};
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
template <typename... Args>
|
||||
inline void operator<< (
|
||||
struct object_with_zone<type::tuple<Args...>> {
|
||||
void operator()(
|
||||
msgpack::object::with_zone& o,
|
||||
type::tuple<Args...> const& v) {
|
||||
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)
|
||||
///@endcond
|
||||
|
||||
} // 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
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/adaptor/int.hpp"
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace type {
|
||||
|
||||
@@ -56,69 +58,117 @@ typedef fix_int<int64_t> fix_int64;
|
||||
|
||||
} // 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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
|
||||
template <>
|
||||
struct pack<type::fix_int8> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int8& v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_int8& v) const
|
||||
{ o.pack_fix_int8(v); return o; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<type::fix_int16> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int16& v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_int16& v) const
|
||||
{ o.pack_fix_int16(v); return o; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<type::fix_int32> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int32& v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_int32& v) const
|
||||
{ o.pack_fix_int32(v); return o; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<type::fix_int64> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int64& v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_int64& v) const
|
||||
{ o.pack_fix_int64(v); return o; }
|
||||
};
|
||||
|
||||
|
||||
template <>
|
||||
struct pack<type::fix_uint8> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint8& v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_uint8& v) const
|
||||
{ o.pack_fix_uint8(v); return o; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<type::fix_uint16> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint16& v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_uint16& v) const
|
||||
{ o.pack_fix_uint16(v); return o; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<type::fix_uint32> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint32& v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_uint32& v) const
|
||||
{ o.pack_fix_uint32(v); return o; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<type::fix_uint64> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint64& v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_uint64& v) const
|
||||
{ o.pack_fix_uint64(v); return o; }
|
||||
};
|
||||
|
||||
|
||||
inline void operator<< (msgpack::object& o, type::fix_int8 v)
|
||||
{
|
||||
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();
|
||||
@@ -128,9 +178,11 @@ inline void operator<< (msgpack::object& o, type::fix_int8 v)
|
||||
o.via.u64 = v.get();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object& o, type::fix_int16 v)
|
||||
{
|
||||
template <>
|
||||
struct object<type::fix_int16> {
|
||||
void operator()(msgpack::object& o, type::fix_int16 v) const {
|
||||
if(v.get() < 0) {
|
||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||
o.via.i64 = v.get();
|
||||
@@ -140,9 +192,11 @@ inline void operator<< (msgpack::object& o, type::fix_int16 v)
|
||||
o.via.u64 = v.get();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object& o, type::fix_int32 v)
|
||||
{
|
||||
template <>
|
||||
struct object<type::fix_int32> {
|
||||
void operator()(msgpack::object& o, type::fix_int32 v) const {
|
||||
if (v.get() < 0) {
|
||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||
o.via.i64 = v.get();
|
||||
@@ -152,9 +206,11 @@ inline void operator<< (msgpack::object& o, type::fix_int32 v)
|
||||
o.via.u64 = v.get();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object& o, type::fix_int64 v)
|
||||
{
|
||||
template <>
|
||||
struct object<type::fix_int64> {
|
||||
void operator()(msgpack::object& o, type::fix_int64 v) const {
|
||||
if (v.get() < 0) {
|
||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||
o.via.i64 = v.get();
|
||||
@@ -164,48 +220,86 @@ inline void operator<< (msgpack::object& o, type::fix_int64 v)
|
||||
o.via.u64 = v.get();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
inline void operator<< (msgpack::object& o, type::fix_uint8 v)
|
||||
template <>
|
||||
struct object<type::fix_uint8> {
|
||||
void operator()(msgpack::object& o, type::fix_uint8 v) const
|
||||
{ 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(); }
|
||||
};
|
||||
|
||||
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(); }
|
||||
};
|
||||
|
||||
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(); }
|
||||
};
|
||||
|
||||
|
||||
inline void operator<< (msgpack::object::with_zone& o, type::fix_int8 v)
|
||||
template <>
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // 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,13 +24,17 @@
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
// FIXME check overflow, underflow
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, float& v)
|
||||
{
|
||||
template <>
|
||||
struct convert<float> {
|
||||
msgpack::object const& operator()(msgpack::object const& o, float& v) const {
|
||||
if(o.type == msgpack::type::FLOAT) {
|
||||
v = static_cast<float>(o.via.f64);
|
||||
}
|
||||
@@ -45,17 +49,21 @@ inline msgpack::object const& operator>> (msgpack::object const& o, float& v)
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<float> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const float& v)
|
||||
{
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const float& v) const {
|
||||
o.pack_float(v);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, double& v)
|
||||
{
|
||||
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;
|
||||
}
|
||||
@@ -70,35 +78,53 @@ inline msgpack::object const& operator>> (msgpack::object const& o, double& v)
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<double> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const double& v)
|
||||
{
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const double& v) const {
|
||||
o.pack_double(v);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
inline void operator<< (msgpack::object& o, float v)
|
||||
{
|
||||
template <>
|
||||
struct object<float> {
|
||||
void operator()(msgpack::object& o, float v) const {
|
||||
o.type = msgpack::type::FLOAT;
|
||||
o.via.f64 = static_cast<double>(v);
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object& o, double v)
|
||||
{
|
||||
template <>
|
||||
struct object<double> {
|
||||
void operator()(msgpack::object& o, double v) const {
|
||||
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; }
|
||||
template <>
|
||||
struct object_with_zone<float> {
|
||||
void operator()(msgpack::object::with_zone& o, float v) const {
|
||||
static_cast<msgpack::object&>(o) << v;
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object::with_zone& o, double v)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
template <>
|
||||
struct object_with_zone<double> {
|
||||
void operator()(msgpack::object::with_zone& o, double v) const {
|
||||
static_cast<msgpack::object&>(o) << v;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // 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
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include <limits>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1){
|
||||
/// @endcond
|
||||
|
||||
namespace type {
|
||||
namespace detail {
|
||||
@@ -101,95 +103,164 @@ namespace detail {
|
||||
} // namespace detail
|
||||
} // 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; }
|
||||
};
|
||||
|
||||
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, signed char& v)
|
||||
template <>
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
|
||||
template <>
|
||||
struct pack<char> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, char v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, char v) const
|
||||
{ o.pack_char(v); return o; }
|
||||
};
|
||||
|
||||
|
||||
template <>
|
||||
struct pack<signed char> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed char v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, signed char v) const
|
||||
{ o.pack_signed_char(v); return o; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<signed short> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed short v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, signed short v) const
|
||||
{ o.pack_short(v); return o; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<signed int> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed int v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, signed int v) const
|
||||
{ o.pack_int(v); return o; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<signed long> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed long v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, signed long v) const
|
||||
{ o.pack_long(v); return o; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<signed long long> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed long long v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, signed long long v) const
|
||||
{ o.pack_long_long(v); return o; }
|
||||
};
|
||||
|
||||
|
||||
template <>
|
||||
struct pack<unsigned char> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned char v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, unsigned char v) const
|
||||
{ o.pack_unsigned_char(v); return o; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<unsigned short> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned short v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, unsigned short v) const
|
||||
{ o.pack_unsigned_short(v); return o; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<unsigned int> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned int v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, unsigned int v) const
|
||||
{ o.pack_unsigned_int(v); return o; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<unsigned long> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned long v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, unsigned long v) const
|
||||
{ o.pack_unsigned_long(v); return o; }
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<unsigned long long> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned long long v)
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, unsigned long long v) const
|
||||
{ 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); }
|
||||
};
|
||||
|
||||
|
||||
inline void operator<< (msgpack::object& o, signed char 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;
|
||||
@@ -199,9 +270,11 @@ inline void operator<< (msgpack::object& o, signed char v)
|
||||
o.via.u64 = v;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object& o, signed short v)
|
||||
{
|
||||
template <>
|
||||
struct object<signed short> {
|
||||
void operator()(msgpack::object& o, signed short v) const {
|
||||
if (v < 0) {
|
||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||
o.via.i64 = v;
|
||||
@@ -211,9 +284,11 @@ inline void operator<< (msgpack::object& o, signed short v)
|
||||
o.via.u64 = v;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object& o, signed int v)
|
||||
{
|
||||
template <>
|
||||
struct object<signed int> {
|
||||
void operator()(msgpack::object& o, signed int v) const {
|
||||
if (v < 0) {
|
||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||
o.via.i64 = v;
|
||||
@@ -223,9 +298,11 @@ inline void operator<< (msgpack::object& o, signed int v)
|
||||
o.via.u64 = v;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object& o, signed long v)
|
||||
{
|
||||
template <>
|
||||
struct object<signed long> {
|
||||
void operator()(msgpack::object& o, signed long v) const {
|
||||
if (v < 0) {
|
||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||
o.via.i64 = v;
|
||||
@@ -235,9 +312,11 @@ inline void operator<< (msgpack::object& o, signed long v)
|
||||
o.via.u64 = v;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object& o, signed long long v)
|
||||
{
|
||||
template <>
|
||||
struct object<signed long long> {
|
||||
void operator()(msgpack::object& o, signed long long v) const {
|
||||
if (v < 0) {
|
||||
o.type = msgpack::type::NEGATIVE_INTEGER;
|
||||
o.via.i64 = v;
|
||||
@@ -247,61 +326,110 @@ inline void operator<< (msgpack::object& o, signed long long v)
|
||||
o.via.u64 = v;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object& o, unsigned char v)
|
||||
template <>
|
||||
struct object<unsigned char> {
|
||||
void operator()(msgpack::object& o, unsigned char v) const
|
||||
{ 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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
inline void operator<< (msgpack::object::with_zone& o, char v)
|
||||
template <>
|
||||
struct object_with_zone<char> {
|
||||
void operator()(msgpack::object::with_zone& o, char v) const
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
};
|
||||
|
||||
|
||||
inline void operator<< (msgpack::object::with_zone& o, signed char v)
|
||||
template <>
|
||||
struct object_with_zone<signed char> {
|
||||
void operator()(msgpack::object::with_zone& o, signed char v) const
|
||||
{ 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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
|
||||
inline void operator<< (msgpack::object::with_zone& o, unsigned char v)
|
||||
template <>
|
||||
struct object_with_zone<unsigned char> {
|
||||
void operator()(msgpack::object::with_zone& o, unsigned char v) const
|
||||
{ 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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // 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,18 +19,22 @@
|
||||
#define MSGPACK_TYPE_LIST_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
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(); }
|
||||
v.resize(o.via.array.size);
|
||||
msgpack::object* p = o.via.array.ptr;
|
||||
@@ -41,10 +45,12 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::list<T>
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::list<T>& v)
|
||||
{
|
||||
template <typename T>
|
||||
struct pack<std::list<T> > {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::list<T>& v) const {
|
||||
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());
|
||||
@@ -53,10 +59,11 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::list<T>& v)
|
||||
{
|
||||
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;
|
||||
@@ -75,8 +82,13 @@ inline void operator<< (msgpack::object::with_zone& o, const std::list<T>& v)
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // 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 {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace type {
|
||||
|
||||
@@ -45,10 +47,11 @@ namespace detail {
|
||||
|
||||
} //namespace type
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
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(); }
|
||||
v.resize(o.via.map.size);
|
||||
msgpack::object_kv* p = o.via.map.ptr;
|
||||
@@ -61,10 +64,12 @@ inline msgpack::object const& operator>> (msgpack::object const& o, type::assoc_
|
||||
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)
|
||||
{
|
||||
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());
|
||||
@@ -74,10 +79,11 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const ty
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K, typename V>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const type::assoc_vector<K,V>& 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;
|
||||
@@ -97,11 +103,11 @@ inline void operator<< (msgpack::object::with_zone& o, const type::assoc_vector<
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <typename K, typename V>
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, 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 {
|
||||
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);
|
||||
@@ -121,10 +127,12 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::map<K,
|
||||
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)
|
||||
{
|
||||
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());
|
||||
o.pack_map(size);
|
||||
for(typename std::map<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
||||
@@ -134,10 +142,11 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K, typename V>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::map<K,V>& 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;
|
||||
@@ -157,11 +166,12 @@ inline void operator<< (msgpack::object::with_zone& o, const std::map<K,V>& v)
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
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(); }
|
||||
msgpack::object_kv* p(o.via.map.ptr);
|
||||
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||
@@ -175,10 +185,12 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::multima
|
||||
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)
|
||||
{
|
||||
template <typename K, typename V>
|
||||
struct pack<std::multimap<K, V> > {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::multimap<K,V>& v) const {
|
||||
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());
|
||||
@@ -188,10 +200,11 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K, typename V>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::multimap<K,V>& 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;
|
||||
@@ -211,8 +224,13 @@ inline void operator<< (msgpack::object::with_zone& o, const std::multimap<K,V>&
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // 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
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace type {
|
||||
|
||||
@@ -31,28 +33,40 @@ struct nil { };
|
||||
|
||||
} // namespace type
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, type::nil&)
|
||||
{
|
||||
template <>
|
||||
struct convert<type::nil> {
|
||||
msgpack::object const& operator()(msgpack::object const& o, type::nil&) const {
|
||||
if(o.type != msgpack::type::NIL) { throw msgpack::type_error(); }
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<type::nil> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::nil&)
|
||||
{
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::nil&) const {
|
||||
o.pack_nil();
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object& o, type::nil)
|
||||
{
|
||||
template <>
|
||||
struct object<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)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
template <>
|
||||
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 <>
|
||||
inline void msgpack::object::as<void>() const
|
||||
@@ -61,7 +75,9 @@ inline void msgpack::object::as<void>() const
|
||||
convert(v);
|
||||
}
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // 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,35 +19,42 @@
|
||||
#define MSGPACK_TYPE_PAIR_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include <utility>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
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.via.array.size != 2) { throw msgpack::type_error(); }
|
||||
o.via.array.ptr[0].convert(v.first);
|
||||
o.via.array.ptr[1].convert(v.second);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Stream, typename T1, typename T2>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::pair<T1, T2>& v)
|
||||
{
|
||||
template <typename T1, typename T2>
|
||||
struct pack<std::pair<T1, T2> > {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::pair<T1, T2>& v) const {
|
||||
o.pack_array(2);
|
||||
o.pack(v.first);
|
||||
o.pack(v.second);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T1, typename T2>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::pair<T1, T2>& v)
|
||||
{
|
||||
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;
|
||||
@@ -55,8 +62,13 @@ inline void operator<< (msgpack::object::with_zone& o, const std::pair<T1, T2>&
|
||||
p[0] = msgpack::object(v.first, o.zone);
|
||||
p[1] = msgpack::object(v.second, o.zone);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // 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
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include <string.h>
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace type {
|
||||
|
||||
@@ -63,35 +65,49 @@ struct raw_ref {
|
||||
|
||||
} // 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> {
|
||||
msgpack::object const& operator()(msgpack::object const& o, msgpack::type::raw_ref& v) const {
|
||||
if(o.type != msgpack::type::BIN) { throw msgpack::type_error(); }
|
||||
v.ptr = o.via.bin.ptr;
|
||||
v.size = o.via.bin.size;
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<msgpack::type::raw_ref> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const msgpack::type::raw_ref& v)
|
||||
{
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const msgpack::type::raw_ref& v) const {
|
||||
o.pack_bin(v.size);
|
||||
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> {
|
||||
void operator()(msgpack::object& o, const msgpack::type::raw_ref& v) const {
|
||||
o.type = msgpack::type::BIN;
|
||||
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)
|
||||
{ static_cast<msgpack::object&>(o) << v; }
|
||||
template <>
|
||||
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
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -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,18 +19,22 @@
|
||||
#define MSGPACK_TYPE_SET_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <set>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
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(); }
|
||||
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
||||
msgpack::object* const pbegin = o.via.array.ptr;
|
||||
@@ -42,10 +46,12 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::set<T>&
|
||||
tmp.swap(v);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::set<T>& v)
|
||||
{
|
||||
template <typename T>
|
||||
struct pack<std::set<T> > {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::set<T>& v) const {
|
||||
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());
|
||||
@@ -54,10 +60,11 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::set<T>& v)
|
||||
{
|
||||
struct object_with_zone<std::set<T> > {
|
||||
void operator()(msgpack::object::with_zone& o, const std::set<T>& v) const {
|
||||
o.type = msgpack::type::ARRAY;
|
||||
if(v.empty()) {
|
||||
o.via.array.ptr = nullptr;
|
||||
@@ -76,11 +83,11 @@ inline void operator<< (msgpack::object::with_zone& o, const std::set<T>& v)
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::multiset<T>& v)
|
||||
{
|
||||
struct convert<std::multiset<T> > {
|
||||
msgpack::object const& operator()(msgpack::object const& o, std::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;
|
||||
@@ -92,10 +99,12 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::multise
|
||||
tmp.swap(v);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::multiset<T>& v)
|
||||
{
|
||||
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());
|
||||
o.pack_array(size);
|
||||
for(typename std::multiset<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||
@@ -104,10 +113,11 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::multiset<T>& v)
|
||||
{
|
||||
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;
|
||||
@@ -126,8 +136,13 @@ inline void operator<< (msgpack::object::with_zone& o, const std::multiset<T>& v
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // 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,17 +19,22 @@
|
||||
#define MSGPACK_TYPE_STRING_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::string& v)
|
||||
{
|
||||
namespace adaptor {
|
||||
|
||||
template <>
|
||||
struct convert<std::string> {
|
||||
msgpack::object const& operator()(msgpack::object const& o, std::string& v) const {
|
||||
switch (o.type) {
|
||||
case msgpack::type::BIN:
|
||||
v.assign(o.via.bin.ptr, o.via.bin.size);
|
||||
@@ -43,18 +48,32 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::string&
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<std::string> {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::string& v)
|
||||
{
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::string& v) const {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_str(size);
|
||||
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> {
|
||||
void operator()(msgpack::object& o, const std::string& v) const {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.type = msgpack::type::STR;
|
||||
o.via.str.ptr = v.data();
|
||||
o.via.str.size = size;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct object_with_zone<std::string> {
|
||||
void operator()(msgpack::object::with_zone& o, const std::string& v) const {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.type = msgpack::type::STR;
|
||||
char* ptr = static_cast<char*>(o.zone.allocate_align(size));
|
||||
@@ -62,16 +81,13 @@ inline void operator<< (msgpack::object::with_zone& o, const std::string& v)
|
||||
o.via.str.size = size;
|
||||
std::memcpy(ptr, v.data(), v.size());
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object& o, const std::string& v)
|
||||
{
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.type = msgpack::type::STR;
|
||||
o.via.str.ptr = v.data();
|
||||
o.via.str.size = size;
|
||||
}
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // 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
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#if defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
||||
@@ -45,11 +45,15 @@
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
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(); }
|
||||
msgpack::object_kv* p(o.via.map.ptr);
|
||||
msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||
@@ -62,10 +66,12 @@ inline msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_
|
||||
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)
|
||||
{
|
||||
template <typename K, typename V>
|
||||
struct pack<MSGPACK_STD_TR1::unordered_map<K, V> > {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_map<K,V>& v) const {
|
||||
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());
|
||||
@@ -75,10 +81,11 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MS
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K, typename V>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_map<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 {
|
||||
o.type = msgpack::type::MAP;
|
||||
if(v.empty()) {
|
||||
o.via.map.ptr = nullptr;
|
||||
@@ -98,11 +105,11 @@ inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::un
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template <typename K, typename V>
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, 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 {
|
||||
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);
|
||||
@@ -116,10 +123,12 @@ inline msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_
|
||||
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)
|
||||
{
|
||||
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());
|
||||
o.pack_map(size);
|
||||
for(typename MSGPACK_STD_TR1::unordered_multimap<K,V>::const_iterator it(v.begin()), it_end(v.end());
|
||||
@@ -129,10 +138,11 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MS
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K, typename V>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_multimap<K,V>& 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;
|
||||
@@ -152,8 +162,13 @@ inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::un
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -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
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#if defined(_LIBCPP_VERSION) || (_MSC_VER >= 1700)
|
||||
@@ -45,11 +45,15 @@
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
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(); }
|
||||
msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
||||
msgpack::object* const pbegin = o.via.array.ptr;
|
||||
@@ -61,10 +65,12 @@ inline msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_
|
||||
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)
|
||||
{
|
||||
template <typename T>
|
||||
struct pack<MSGPACK_STD_TR1::unordered_set<T> > {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_set<T>& v) const {
|
||||
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());
|
||||
@@ -73,10 +79,11 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MS
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_set<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;
|
||||
if(v.empty()) {
|
||||
o.via.array.ptr = nullptr;
|
||||
@@ -95,11 +102,12 @@ inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::un
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_TR1::unordered_multiset<T>& v)
|
||||
{
|
||||
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;
|
||||
@@ -111,10 +119,12 @@ inline msgpack::object const& operator>> (msgpack::object const& o, MSGPACK_STD_
|
||||
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)
|
||||
{
|
||||
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());
|
||||
@@ -123,10 +133,11 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MS
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
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_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;
|
||||
@@ -145,8 +156,13 @@ inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::un
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -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,24 +19,28 @@
|
||||
#define MSGPACK_TYPE_VECTOR_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
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(); }
|
||||
v.resize(o.via.array.size);
|
||||
if(o.via.array.size > 0) {
|
||||
msgpack::object* p = o.via.array.ptr;
|
||||
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 {
|
||||
p->convert(*it);
|
||||
++p;
|
||||
@@ -45,10 +49,12 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::vector<
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::vector<T>& v)
|
||||
{
|
||||
template <typename T>
|
||||
struct pack<std::vector<T> > {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::vector<T>& v) const {
|
||||
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());
|
||||
@@ -57,10 +63,11 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::vector<T>& v)
|
||||
{
|
||||
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;
|
||||
@@ -79,8 +86,13 @@ inline void operator<< (msgpack::object::with_zone& o, const std::vector<T>& v)
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -24,10 +24,15 @@
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::vector<bool>& v)
|
||||
{
|
||||
namespace adaptor {
|
||||
|
||||
template <>
|
||||
struct convert<std::vector<bool> > {
|
||||
msgpack::object const& operator()(msgpack::object const& o, std::vector<bool>& v) const {
|
||||
if (o.type != msgpack::type::ARRAY) { throw msgpack::type_error(); }
|
||||
if (o.via.array.size > 0) {
|
||||
v.resize(o.via.array.size);
|
||||
@@ -41,39 +46,50 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::vector<
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<std::vector<bool> > {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::vector<bool>& v)
|
||||
{
|
||||
o.pack_array(v.size());
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::vector<bool>& v)
|
||||
{
|
||||
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 {
|
||||
msgpack::object* p = static_cast<msgpack::object*>(o.zone.allocate_align(sizeof(msgpack::object)*v.size()));
|
||||
msgpack::object* const pend = p + 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* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = v.size();
|
||||
o.via.array.size = size;
|
||||
std::vector<bool>::const_iterator it(v.begin());
|
||||
do {
|
||||
*p = object(static_cast<bool>(*it), o.zone);
|
||||
*p = msgpack::object(static_cast<bool>(*it), o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // 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,17 +19,22 @@
|
||||
#define MSGPACK_TYPE_VECTOR_CHAR_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "msgpack/adaptor/check_container_size.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, std::vector<char>& v)
|
||||
{
|
||||
namespace adaptor {
|
||||
|
||||
template <>
|
||||
struct convert<std::vector<char> > {
|
||||
msgpack::object const& operator()(msgpack::object const& o, std::vector<char>& v) const {
|
||||
switch (o.type) {
|
||||
case msgpack::type::BIN:
|
||||
v.resize(o.via.bin.size);
|
||||
@@ -45,27 +50,33 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::vector<
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct pack<std::vector<char> > {
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::vector<char>& v)
|
||||
{
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::vector<char>& v) const {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_bin(size);
|
||||
o.pack_bin_body(&v.front(), size);
|
||||
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object& o, const std::vector<char>& v)
|
||||
{
|
||||
template <>
|
||||
struct object<std::vector<char> > {
|
||||
void operator()(msgpack::object& o, const std::vector<char>& v) const {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.type = msgpack::type::BIN;
|
||||
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> > {
|
||||
void operator()(msgpack::object::with_zone& o, const std::vector<char>& 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));
|
||||
@@ -73,8 +84,13 @@ inline void operator<< (msgpack::object::with_zone& o, const std::vector<char>&
|
||||
o.via.bin.size = size;
|
||||
std::memcpy(ptr, &v.front(), size);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -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 {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
template <typename T>
|
||||
struct unique_ptr : std::auto_ptr<T> {
|
||||
@@ -75,7 +77,9 @@ template <typename T>
|
||||
struct enable_if<false, T> {
|
||||
};
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
@@ -86,7 +90,9 @@ struct enable_if<false, T> {
|
||||
#include <tuple>
|
||||
|
||||
namespace msgpack {
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
// unique_ptr
|
||||
using std::unique_ptr;
|
||||
@@ -98,7 +104,9 @@ MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
using std::swap;
|
||||
using std::enable_if;
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
} // namespace msgpack
|
||||
|
||||
|
||||
|
@@ -35,7 +35,9 @@
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
class zone {
|
||||
struct finalizer {
|
||||
@@ -179,6 +181,7 @@ public:
|
||||
{
|
||||
::operator delete(p, place);
|
||||
}
|
||||
/// @cond
|
||||
|
||||
template <typename T>
|
||||
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>
|
||||
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:
|
||||
void undo_allocate(size_t size);
|
||||
@@ -349,6 +353,7 @@ inline void zone::undo_allocate(size_t size)
|
||||
m_chunk_list.m_free += size;
|
||||
}
|
||||
|
||||
/// @cond
|
||||
|
||||
template <typename T>
|
||||
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)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -36,7 +36,9 @@
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
class zone {
|
||||
private:
|
||||
@@ -361,7 +363,9 @@ T* zone::allocate(Args... args)
|
||||
}
|
||||
}
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -25,7 +25,9 @@
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
class fbuffer {
|
||||
public:
|
||||
@@ -57,7 +59,9 @@ private:
|
||||
FILE* m_file;
|
||||
};
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -20,12 +20,14 @@
|
||||
#define MSGPACK_ITERATOR_HPP
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
#include <msgpack_fwd.hpp>
|
||||
#include <msgpack/object_fwd.hpp>
|
||||
|
||||
namespace msgpack
|
||||
{
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(MSGPACK_DEFAULT_API_NS)
|
||||
{
|
||||
/// @endcond
|
||||
inline object_kv* begin(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; }
|
||||
@@ -35,7 +37,9 @@ namespace msgpack
|
||||
inline const object* begin(const object_array &array) { return array.ptr; }
|
||||
inline object* end(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)
|
||||
|
@@ -19,60 +19,22 @@
|
||||
#define MSGPACK_OBJECT_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/pack.hpp"
|
||||
#include "msgpack/zone.hpp"
|
||||
#include "msgpack/adaptor/int_fwd.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"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
|
||||
#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 <cstring>
|
||||
#include <stdexcept>
|
||||
#include <typeinfo>
|
||||
#include <limits>
|
||||
#include <ostream>
|
||||
#include <typeinfo>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
struct object::with_zone : object {
|
||||
with_zone(msgpack::zone& zone) : zone(zone) { }
|
||||
msgpack::zone& zone;
|
||||
private:
|
||||
with_zone();
|
||||
};
|
||||
/// @endcond
|
||||
|
||||
struct object::implicit_type {
|
||||
implicit_type(object const& o) : obj(o) { }
|
||||
@@ -85,119 +47,123 @@ private:
|
||||
msgpack::object const& obj;
|
||||
};
|
||||
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, msgpack::object& v)
|
||||
{
|
||||
v = o;
|
||||
return o;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, T& v)
|
||||
{
|
||||
// If you get a error 'class your_class has no member named 'msgpack_unpack',
|
||||
// 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:
|
||||
// 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;
|
||||
}
|
||||
|
||||
// obsolete
|
||||
template <typename Type>
|
||||
class define : public Type {
|
||||
public:
|
||||
typedef Type msgpack_type;
|
||||
typedef define<Type> define_type;
|
||||
|
||||
define() {}
|
||||
define(const msgpack_type& v) : msgpack_type(v) {}
|
||||
|
||||
template <typename Packer>
|
||||
void msgpack_pack(Packer& o) const
|
||||
{
|
||||
msgpack::operator<<(o, static_cast<const msgpack_type&>(*this));
|
||||
}
|
||||
|
||||
void msgpack_unpack(object const& o)
|
||||
{
|
||||
msgpack::operator>>(o, static_cast<msgpack_type&>(*this));
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
} // 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;
|
||||
}
|
||||
|
||||
inline void operator<< (msgpack::object::with_zone& o, const msgpack::object& v)
|
||||
{
|
||||
template <typename T>
|
||||
template <typename Stream>
|
||||
inline
|
||||
msgpack::packer<Stream>&
|
||||
msgpack::adaptor::pack<T>::operator()(msgpack::packer<Stream>& o, T const& v) const {
|
||||
return detail::packer_serializer<Stream, T>::pack(o, v);
|
||||
}
|
||||
|
||||
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) {
|
||||
@@ -234,7 +200,7 @@ inline void operator<< (msgpack::object::with_zone& o, const msgpack::object& v)
|
||||
}
|
||||
|
||||
case msgpack::type::ARRAY:
|
||||
o.via.array.ptr = static_cast<object*>(o.zone.allocate_align(sizeof(object) * v.via.array.size));
|
||||
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),
|
||||
@@ -247,7 +213,7 @@ inline void operator<< (msgpack::object::with_zone& o, const msgpack::object& v)
|
||||
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.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),
|
||||
@@ -255,7 +221,7 @@ inline void operator<< (msgpack::object::with_zone& o, const msgpack::object& v)
|
||||
* const pvend(v.via.map.ptr + v.via.map.size);
|
||||
pv < pvend;
|
||||
++po, ++pv) {
|
||||
object_kv* kv = new (po) object_kv;
|
||||
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);
|
||||
}
|
||||
@@ -264,52 +230,48 @@ inline void operator<< (msgpack::object::with_zone& o, const msgpack::object& v)
|
||||
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
|
||||
template <typename Type>
|
||||
class define : public Type {
|
||||
public:
|
||||
typedef Type msgpack_type;
|
||||
typedef define<Type> define_type;
|
||||
|
||||
define() {}
|
||||
define(const msgpack_type& v) : msgpack_type(v) {}
|
||||
|
||||
template <typename Packer>
|
||||
void msgpack_pack(Packer& o) const
|
||||
{
|
||||
msgpack::operator<<(o, static_cast<const msgpack_type&>(*this));
|
||||
}
|
||||
|
||||
inline void operator<< (msgpack::object::with_zone& o, const msgpack::object::with_zone& v)
|
||||
void msgpack_unpack(object const& o)
|
||||
{
|
||||
return o << static_cast<msgpack::object const&>(v);
|
||||
msgpack::operator>>(o, static_cast<msgpack_type&>(*this));
|
||||
}
|
||||
};
|
||||
|
||||
// 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 T>
|
||||
@@ -452,42 +414,6 @@ inline object::object()
|
||||
template <typename T>
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -703,7 +629,9 @@ inline std::ostream& operator<< (std::ostream& s, const msgpack::object& o)
|
||||
return s;
|
||||
}
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -27,7 +27,9 @@
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
|
||||
namespace type {
|
||||
@@ -143,39 +145,16 @@ struct object_kv {
|
||||
msgpack::object val;
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
template <typename Stream, typename T>
|
||||
struct packer_serializer;
|
||||
} // namespace detail
|
||||
|
||||
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);
|
||||
struct object::with_zone : object {
|
||||
with_zone(msgpack::zone& zone) : zone(zone) { }
|
||||
msgpack::zone& zone;
|
||||
private:
|
||||
with_zone();
|
||||
};
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#define MSGPACK_PACK_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/cpp_config.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <limits>
|
||||
@@ -29,7 +30,9 @@
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
template <typename Stream>
|
||||
class packer {
|
||||
@@ -119,11 +122,13 @@ private:
|
||||
private:
|
||||
packer(const packer&);
|
||||
packer& operator=(const packer&);
|
||||
packer();
|
||||
#else // defined(MSGPACK_USE_CPP03)
|
||||
public:
|
||||
packer(const packer&) = delete;
|
||||
packer& operator=(const packer&) = delete;
|
||||
packer() = delete;
|
||||
#endif // defined(MSGPACK_USE_CPP03)
|
||||
packer();
|
||||
};
|
||||
|
||||
|
||||
@@ -139,14 +144,6 @@ inline void pack(Stream& s, const T& 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__)
|
||||
template <typename T>
|
||||
@@ -1055,7 +1052,9 @@ inline void packer<Stream>::pack_imp_int64(T d)
|
||||
}
|
||||
}
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -28,7 +28,9 @@
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
class sbuffer {
|
||||
public:
|
||||
@@ -127,7 +129,9 @@ private:
|
||||
size_t m_alloc;
|
||||
};
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -64,7 +64,9 @@ const size_t COUNTER_SIZE = sizeof(_msgpack_atomic_counter_t);
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -97,7 +97,7 @@ 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)
|
||||
{
|
||||
assert(len >= *off);
|
||||
|
||||
{
|
||||
const unsigned char* p = (unsigned char*)data + *off;
|
||||
const unsigned char* const pe = (unsigned char*)data + len;
|
||||
const void* n = NULL;
|
||||
@@ -457,7 +457,7 @@ _end:
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#undef msgpack_unpack_func
|
||||
#undef msgpack_unpack_callback
|
||||
|
@@ -1,3 +1,3 @@
|
||||
#define MSGPACK_VERSION_MAJOR 1
|
||||
#define MSGPACK_VERSION_MINOR 0
|
||||
#define MSGPACK_VERSION_REVISION 1
|
||||
#define MSGPACK_VERSION_MINOR 1
|
||||
#define MSGPACK_VERSION_REVISION 0
|
||||
|
@@ -41,7 +41,9 @@ struct iovec {
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace detail {
|
||||
// int64, uint64, double
|
||||
@@ -289,7 +291,9 @@ private:
|
||||
|
||||
};
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
|
@@ -33,7 +33,9 @@
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
class zbuffer {
|
||||
public:
|
||||
@@ -164,7 +166,9 @@ private:
|
||||
size_t m_init_size;
|
||||
};
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // 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_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_zone.hpp include/msgpack/detail/cpp03_zone.hpp
|
||||
|
@@ -54,65 +54,38 @@ nobase_include_HEADERS = \
|
||||
if ENABLE_CXX
|
||||
nobase_include_HEADERS += \
|
||||
../include/msgpack.hpp \
|
||||
../include/msgpack_fwd.hpp \
|
||||
../include/msgpack/adaptor/adaptor_base.hpp \
|
||||
../include/msgpack/adaptor/bool.hpp \
|
||||
../include/msgpack/adaptor/bool_fwd.hpp \
|
||||
../include/msgpack/adaptor/char_ptr.hpp \
|
||||
../include/msgpack/adaptor/char_ptr_fwd.hpp \
|
||||
../include/msgpack/adaptor/check_container_size.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_fwd.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_fwd.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_fwd.hpp \
|
||||
../include/msgpack/adaptor/define.hpp \
|
||||
../include/msgpack/adaptor/deque.hpp \
|
||||
../include/msgpack/adaptor/deque_fwd.hpp \
|
||||
../include/msgpack/adaptor/detail/cpp03_define.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_msgpack_tuple.hpp \
|
||||
../include/msgpack/adaptor/detail/cpp11_msgpack_tuple_fwd.hpp \
|
||||
../include/msgpack/adaptor/fixint.hpp \
|
||||
../include/msgpack/adaptor/fixint_fwd.hpp \
|
||||
../include/msgpack/adaptor/float.hpp \
|
||||
../include/msgpack/adaptor/float_fwd.hpp \
|
||||
../include/msgpack/adaptor/int.hpp \
|
||||
../include/msgpack/adaptor/int_fwd.hpp \
|
||||
../include/msgpack/adaptor/list.hpp \
|
||||
../include/msgpack/adaptor/list_fwd.hpp \
|
||||
../include/msgpack/adaptor/map.hpp \
|
||||
../include/msgpack/adaptor/map_fwd.hpp \
|
||||
../include/msgpack/adaptor/msgpack_tuple.hpp \
|
||||
../include/msgpack/adaptor/msgpack_tuple_fwd.hpp \
|
||||
../include/msgpack/adaptor/nil.hpp \
|
||||
../include/msgpack/adaptor/nil_fwd.hpp \
|
||||
../include/msgpack/adaptor/pair.hpp \
|
||||
../include/msgpack/adaptor/pair_fwd.hpp \
|
||||
../include/msgpack/adaptor/raw.hpp \
|
||||
../include/msgpack/adaptor/raw_fwd.hpp \
|
||||
../include/msgpack/adaptor/set.hpp \
|
||||
../include/msgpack/adaptor/set_fwd.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_fwd.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_fwd.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_fwd.hpp \
|
||||
../include/msgpack/cpp_config.hpp \
|
||||
../include/msgpack/detail/cpp03_zone.hpp \
|
||||
../include/msgpack/detail/cpp11_zone.hpp \
|
||||
@@ -141,6 +114,8 @@ doxygen_c:
|
||||
cat ../Doxyfile > Doxyfile_c
|
||||
echo "FILE_PATTERNS = *.h" >> 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
|
||||
doxygen Doxyfile_c
|
||||
|
||||
@@ -148,6 +123,8 @@ doxygen_cpp:
|
||||
cat ../Doxyfile > Doxyfile_cpp
|
||||
echo "FILE_PATTERNS = *.hpp" >> 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
|
||||
doxygen Doxyfile_cpp
|
||||
|
||||
|
@@ -20,7 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(_MSC_VER) || _MSC_VER >= 1700
|
||||
#if !defined(_MSC_VER) || _MSC_VER >= 1800
|
||||
#include <inttypes.h>
|
||||
#endif
|
||||
|
||||
@@ -71,8 +71,10 @@ int msgpack_pack_object(msgpack_packer* pk, msgpack_object d)
|
||||
case MSGPACK_OBJECT_ARRAY:
|
||||
{
|
||||
int ret = msgpack_pack_array(pk, d.via.array.size);
|
||||
if(ret < 0) { return ret; }
|
||||
|
||||
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) {
|
||||
@@ -82,12 +84,15 @@ int msgpack_pack_object(msgpack_packer* pk, msgpack_object d)
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
case MSGPACK_OBJECT_MAP:
|
||||
{
|
||||
int ret = msgpack_pack_map(pk, d.via.map.size);
|
||||
if(ret < 0) { return ret; }
|
||||
|
||||
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) {
|
||||
@@ -99,6 +104,7 @@ int msgpack_pack_object(msgpack_packer* pk, msgpack_object d)
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
return -1;
|
||||
@@ -172,9 +178,9 @@ void msgpack_object_print(FILE* out, msgpack_object o)
|
||||
fprintf(out, "[");
|
||||
if(o.via.array.size != 0) {
|
||||
msgpack_object* p = o.via.array.ptr;
|
||||
msgpack_object* const pend = o.via.array.ptr + o.via.array.size;
|
||||
msgpack_object_print(out, *p);
|
||||
++p;
|
||||
msgpack_object* const pend = o.via.array.ptr + o.via.array.size;
|
||||
for(; p < pend; ++p) {
|
||||
fprintf(out, ", ");
|
||||
msgpack_object_print(out, *p);
|
||||
@@ -187,11 +193,11 @@ void msgpack_object_print(FILE* out, msgpack_object o)
|
||||
fprintf(out, "{");
|
||||
if(o.via.map.size != 0) {
|
||||
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);
|
||||
fprintf(out, "=>");
|
||||
msgpack_object_print(out, p->val);
|
||||
++p;
|
||||
msgpack_object_kv* const pend = o.via.map.ptr + o.via.map.size;
|
||||
for(; p < pend; ++p) {
|
||||
fprintf(out, ", ");
|
||||
msgpack_object_print(out, p->key);
|
||||
|
46
src/unpack.c
46
src/unpack.c
@@ -58,8 +58,8 @@ static int template_execute(
|
||||
|
||||
static inline msgpack_object template_callback_root(unpack_user* u)
|
||||
{
|
||||
MSGPACK_UNUSED(u);
|
||||
msgpack_object o;
|
||||
MSGPACK_UNUSED(u);
|
||||
o.type = MSGPACK_OBJECT_NIL;
|
||||
return o;
|
||||
}
|
||||
@@ -306,26 +306,28 @@ static inline _msgpack_atomic_counter_t get_count(void* buffer)
|
||||
return *(volatile _msgpack_atomic_counter_t*)buffer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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) {
|
||||
initial_buffer_size = COUNTER_SIZE;
|
||||
}
|
||||
|
||||
char* buffer = (char*)malloc(initial_buffer_size);
|
||||
buffer = (char*)malloc(initial_buffer_size);
|
||||
if(buffer == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void* ctx = malloc(sizeof(template_context));
|
||||
ctx = malloc(sizeof(template_context));
|
||||
if(ctx == NULL) {
|
||||
free(buffer);
|
||||
return false;
|
||||
}
|
||||
|
||||
msgpack_zone* z = msgpack_zone_new(MSGPACK_ZONE_CHUNK_SIZE);
|
||||
z = msgpack_zone_new(MSGPACK_ZONE_CHUNK_SIZE);
|
||||
if(z == NULL) {
|
||||
free(ctx);
|
||||
free(buffer);
|
||||
@@ -357,7 +359,6 @@ void msgpack_unpacker_destroy(msgpack_unpacker* mpac)
|
||||
decr_count(mpac->buffer);
|
||||
}
|
||||
|
||||
|
||||
msgpack_unpacker* msgpack_unpacker_new(size_t initial_buffer_size)
|
||||
{
|
||||
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) {
|
||||
char* tmp;
|
||||
size_t next_size = (mpac->used + mpac->free) * 2; // include COUNTER_SIZE
|
||||
while(next_size < size + mpac->used) {
|
||||
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;
|
||||
}
|
||||
|
||||
char* tmp = (char*)realloc(mpac->buffer, next_size);
|
||||
tmp = (char*)realloc(mpac->buffer, next_size);
|
||||
if(tmp == NULL) {
|
||||
return false;
|
||||
}
|
||||
@@ -413,6 +415,7 @@ bool msgpack_unpacker_expand_buffer(msgpack_unpacker* mpac, size_t size)
|
||||
mpac->free = next_size - mpac->used;
|
||||
|
||||
} else {
|
||||
char* tmp;
|
||||
size_t next_size = mpac->initial_buffer_size; // include COUNTER_SIZE
|
||||
size_t not_parsed = mpac->used - mpac->off;
|
||||
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;
|
||||
}
|
||||
|
||||
char* tmp = (char*)malloc(next_size);
|
||||
tmp = (char*)malloc(next_size);
|
||||
if(tmp == NULL) {
|
||||
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* r;
|
||||
msgpack_zone* old;
|
||||
|
||||
if(!msgpack_unpacker_flush_zone(mpac)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
msgpack_zone* r = msgpack_zone_new(MSGPACK_ZONE_CHUNK_SIZE);
|
||||
r = msgpack_zone_new(MSGPACK_ZONE_CHUNK_SIZE);
|
||||
if(r == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
msgpack_zone* old = mpac->z;
|
||||
old = mpac->z;
|
||||
mpac->z = r;
|
||||
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)
|
||||
{
|
||||
int ret;
|
||||
|
||||
msgpack_unpacked_destroy(result);
|
||||
|
||||
int ret = msgpack_unpacker_execute(mpac);
|
||||
ret = msgpack_unpacker_execute(mpac);
|
||||
|
||||
if(ret < 0) {
|
||||
result->zone = NULL;
|
||||
@@ -546,14 +554,15 @@ msgpack_unpack(const char* data, size_t len, size_t* off,
|
||||
// FIXME
|
||||
return MSGPACK_UNPACK_CONTINUE;
|
||||
}
|
||||
|
||||
else {
|
||||
int e;
|
||||
template_context ctx;
|
||||
template_init(&ctx);
|
||||
|
||||
ctx.user.z = result_zone;
|
||||
ctx.user.referenced = false;
|
||||
|
||||
int e = template_execute(&ctx, data, len, &noff);
|
||||
e = template_execute(&ctx, data, len, &noff);
|
||||
if(e < 0) {
|
||||
return MSGPACK_UNPACK_PARSE_ERROR;
|
||||
}
|
||||
@@ -572,14 +581,15 @@ msgpack_unpack(const char* data, size_t len, size_t* off,
|
||||
|
||||
return MSGPACK_UNPACK_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
msgpack_unpack_return
|
||||
msgpack_unpack_next(msgpack_unpacked* result,
|
||||
const char* data, size_t len, size_t* off)
|
||||
{
|
||||
size_t noff = 0;
|
||||
msgpack_unpacked_destroy(result);
|
||||
|
||||
size_t noff = 0;
|
||||
if(off != NULL) { noff = *off; }
|
||||
|
||||
if(len <= noff) {
|
||||
@@ -593,14 +603,15 @@ msgpack_unpack_next(msgpack_unpacked* result,
|
||||
if (!result->zone) {
|
||||
return MSGPACK_UNPACK_NOMEM_ERROR;
|
||||
}
|
||||
|
||||
else {
|
||||
int e;
|
||||
template_context ctx;
|
||||
template_init(&ctx);
|
||||
|
||||
ctx.user.z = result->zone;
|
||||
ctx.user.referenced = false;
|
||||
|
||||
int e = template_execute(&ctx, data, len, &noff);
|
||||
e = template_execute(&ctx, data, len, &noff);
|
||||
if(e < 0) {
|
||||
msgpack_zone_free(result->zone);
|
||||
result->zone = NULL;
|
||||
@@ -617,6 +628,7 @@ msgpack_unpack_next(msgpack_unpacked* result,
|
||||
|
||||
return MSGPACK_UNPACK_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(MSGPACK_OLD_COMPILER_BUS_ERROR_WORKAROUND)
|
||||
// FIXME: Dirty hack to avoid a bus error caused by OS X's old gcc.
|
||||
|
@@ -29,15 +29,19 @@ struct msgpack_vrefbuffer_chunk {
|
||||
bool msgpack_vrefbuffer_init(msgpack_vrefbuffer* vbuf,
|
||||
size_t ref_size, size_t chunk_size)
|
||||
{
|
||||
size_t nfirst;
|
||||
struct iovec* array;
|
||||
msgpack_vrefbuffer_chunk* chunk;
|
||||
|
||||
vbuf->chunk_size = chunk_size;
|
||||
vbuf->ref_size =
|
||||
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;
|
||||
|
||||
struct iovec* array = (struct iovec*)malloc(
|
||||
array = (struct iovec*)malloc(
|
||||
sizeof(struct iovec) * nfirst);
|
||||
if(array == NULL) {
|
||||
return false;
|
||||
@@ -47,13 +51,13 @@ bool msgpack_vrefbuffer_init(msgpack_vrefbuffer* vbuf,
|
||||
vbuf->end = array + nfirst;
|
||||
vbuf->array = array;
|
||||
|
||||
msgpack_vrefbuffer_chunk* chunk = (msgpack_vrefbuffer_chunk*)malloc(
|
||||
chunk = (msgpack_vrefbuffer_chunk*)malloc(
|
||||
sizeof(msgpack_vrefbuffer_chunk) + chunk_size);
|
||||
if(chunk == NULL) {
|
||||
free(array);
|
||||
return false;
|
||||
}
|
||||
|
||||
else {
|
||||
msgpack_vrefbuffer_inner_buffer* const ib = &vbuf->inner_buffer;
|
||||
|
||||
ib->free = chunk_size;
|
||||
@@ -63,6 +67,7 @@ bool msgpack_vrefbuffer_init(msgpack_vrefbuffer* vbuf,
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void msgpack_vrefbuffer_destroy(msgpack_vrefbuffer* vbuf)
|
||||
{
|
||||
@@ -89,6 +94,7 @@ void msgpack_vrefbuffer_clear(msgpack_vrefbuffer* vbuf)
|
||||
c = n;
|
||||
}
|
||||
|
||||
{
|
||||
msgpack_vrefbuffer_inner_buffer* const ib = &vbuf->inner_buffer;
|
||||
msgpack_vrefbuffer_chunk* chunk = ib->head;
|
||||
chunk->next = NULL;
|
||||
@@ -97,6 +103,7 @@ void msgpack_vrefbuffer_clear(msgpack_vrefbuffer* vbuf)
|
||||
|
||||
vbuf->tail = vbuf->array;
|
||||
}
|
||||
}
|
||||
|
||||
int msgpack_vrefbuffer_append_ref(msgpack_vrefbuffer* vbuf,
|
||||
const char* buf, size_t len)
|
||||
@@ -127,14 +134,16 @@ int msgpack_vrefbuffer_append_copy(msgpack_vrefbuffer* vbuf,
|
||||
const char* buf, size_t len)
|
||||
{
|
||||
msgpack_vrefbuffer_inner_buffer* const ib = &vbuf->inner_buffer;
|
||||
char* m;
|
||||
|
||||
if(ib->free < len) {
|
||||
msgpack_vrefbuffer_chunk* chunk;
|
||||
size_t sz = vbuf->chunk_size;
|
||||
if(sz < len) {
|
||||
sz = len;
|
||||
}
|
||||
|
||||
msgpack_vrefbuffer_chunk* chunk = (msgpack_vrefbuffer_chunk*)malloc(
|
||||
chunk = (msgpack_vrefbuffer_chunk*)malloc(
|
||||
sizeof(msgpack_vrefbuffer_chunk) + sz);
|
||||
if(chunk == NULL) {
|
||||
return -1;
|
||||
@@ -146,7 +155,7 @@ int msgpack_vrefbuffer_append_copy(msgpack_vrefbuffer* vbuf,
|
||||
ib->ptr = ((char*)chunk) + sizeof(msgpack_vrefbuffer_chunk);
|
||||
}
|
||||
|
||||
char* m = ib->ptr;
|
||||
m = ib->ptr;
|
||||
memcpy(m, buf, len);
|
||||
ib->free -= len;
|
||||
ib->ptr += len;
|
||||
@@ -172,9 +181,10 @@ int msgpack_vrefbuffer_migrate(msgpack_vrefbuffer* vbuf, msgpack_vrefbuffer* to)
|
||||
|
||||
empty->next = NULL;
|
||||
|
||||
|
||||
{
|
||||
const size_t nused = (size_t)(vbuf->tail - vbuf->array);
|
||||
if(to->tail + nused < vbuf->end) {
|
||||
struct iovec* nvec;
|
||||
const size_t tosize = (size_t)(to->tail - to->array);
|
||||
const size_t reqsize = nused + tosize;
|
||||
size_t nnext = (size_t)(to->end - to->array) * 2;
|
||||
@@ -187,7 +197,7 @@ int msgpack_vrefbuffer_migrate(msgpack_vrefbuffer* vbuf, msgpack_vrefbuffer* to)
|
||||
nnext = tmp_nnext;
|
||||
}
|
||||
|
||||
struct iovec* nvec = (struct iovec*)realloc(
|
||||
nvec = (struct iovec*)realloc(
|
||||
to->array, sizeof(struct iovec)*nnext);
|
||||
if(nvec == NULL) {
|
||||
free(empty);
|
||||
@@ -204,7 +214,7 @@ int msgpack_vrefbuffer_migrate(msgpack_vrefbuffer* vbuf, msgpack_vrefbuffer* to)
|
||||
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;
|
||||
|
||||
@@ -223,6 +233,8 @@ int msgpack_vrefbuffer_migrate(msgpack_vrefbuffer* vbuf, msgpack_vrefbuffer* to)
|
||||
ib->head = empty;
|
||||
ib->free = sz;
|
||||
ib->ptr = ((char*)empty) + sizeof(msgpack_vrefbuffer_chunk);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
13
src/zone.c
13
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)
|
||||
{
|
||||
msgpack_zone_chunk_list* const cl = &zone->chunk_list;
|
||||
msgpack_zone_chunk* chunk;
|
||||
|
||||
size_t sz = zone->chunk_size;
|
||||
|
||||
@@ -87,9 +88,12 @@ void* msgpack_zone_malloc_expand(msgpack_zone* zone, size_t size)
|
||||
sz = tmp_sz;
|
||||
}
|
||||
|
||||
msgpack_zone_chunk* chunk = (msgpack_zone_chunk*)malloc(
|
||||
chunk = (msgpack_zone_chunk*)malloc(
|
||||
sizeof(msgpack_zone_chunk) + sz);
|
||||
if (chunk == NULL) return NULL;
|
||||
if (chunk == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
char* ptr = ((char*)chunk) + sizeof(msgpack_zone_chunk);
|
||||
chunk->next = cl->head;
|
||||
cl->head = chunk;
|
||||
@@ -98,6 +102,7 @@ void* msgpack_zone_malloc_expand(msgpack_zone* zone, size_t size)
|
||||
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static inline void init_finalizer_array(msgpack_zone_finalizer_array* fa)
|
||||
@@ -131,6 +136,7 @@ bool msgpack_zone_push_finalizer_expand(msgpack_zone* zone,
|
||||
void (*func)(void* data), void* data)
|
||||
{
|
||||
msgpack_zone_finalizer_array* const fa = &zone->finalizer_array;
|
||||
msgpack_zone_finalizer* tmp;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
msgpack_zone_finalizer* tmp =
|
||||
(msgpack_zone_finalizer*)realloc(fa->array,
|
||||
tmp = (msgpack_zone_finalizer*)realloc(fa->array,
|
||||
sizeof(msgpack_zone_finalizer) * nnext);
|
||||
if(tmp == NULL) {
|
||||
return false;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <msgpack_fwd.hpp>
|
||||
#include <msgpack.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
class enum_member {
|
||||
@@ -17,8 +17,6 @@ public:
|
||||
|
||||
MSGPACK_ADD_ENUM(enum_member::flags_t);
|
||||
|
||||
#include <msgpack.hpp>
|
||||
|
||||
class compatibility {
|
||||
public:
|
||||
compatibility() : str1("default"), str2("default") { }
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <msgpack_fwd.hpp>
|
||||
#include <msgpack.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
@@ -38,8 +38,6 @@ public:
|
||||
|
||||
MSGPACK_ADD_ENUM(TestEnumMemberClass::TestEnumType);
|
||||
|
||||
#include <msgpack.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
const unsigned int kLoop = 1000;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <msgpack_fwd.hpp>
|
||||
#include <msgpack.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
@@ -29,8 +29,6 @@ public:
|
||||
|
||||
MSGPACK_ADD_ENUM(TestEnumClassMemberClass::TestEnumClassType);
|
||||
|
||||
#include <msgpack.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
const unsigned int kLoop = 10000;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <msgpack_fwd.hpp>
|
||||
#include <msgpack.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
||||
@@ -34,10 +34,6 @@ MSGPACK_ADD_ENUM(outer_enum_class::enum_class_test);
|
||||
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
|
||||
|
||||
#include <msgpack.hpp>
|
||||
|
||||
struct myclass {
|
||||
myclass() : num(0), str("default") { }
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <msgpack_fwd.hpp>
|
||||
#include <msgpack.hpp>
|
||||
#include <gtest/gtest.h>
|
||||
#include <cmath>
|
||||
|
||||
@@ -40,9 +40,6 @@ MSGPACK_ADD_ENUM(outer_enum_class::enum_class_test);
|
||||
|
||||
|
||||
|
||||
#include <msgpack.hpp>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
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