mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-05-29 15:34:08 +02:00
Re-designed user types dispatching mechanism.
msgpakc-c 0.5.9 or older uses ADL. msgpack-c 1.0.x uses overloading with header files ordering. msgpack-c 1.1.x uses functor with class template specialization.
This commit is contained in:
parent
6ec09053b1
commit
e8d3c8d6c5
@ -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
|
||||
|
@ -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,28 +40,35 @@
|
||||
}
|
||||
|
||||
// MSGPACK_ADD_ENUM must be used in the global namespace.
|
||||
#define MSGPACK_ADD_ENUM(enum) \
|
||||
#define MSGPACK_ADD_ENUM(enum_name) \
|
||||
namespace msgpack { \
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) { \
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, enum& v) \
|
||||
{ \
|
||||
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); \
|
||||
} \
|
||||
}; \
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
@ -31,7 +32,7 @@ namespace type {
|
||||
// FIXME operator!=
|
||||
<% GENERATION_LIMIT = 31 %>
|
||||
|
||||
template <typename A0<%1.upto(GENERATION_LIMIT+1) {|i|%>, typename A<%=i%><%}%>>
|
||||
template <typename A0 = void<%1.upto(GENERATION_LIMIT+1) {|i|%>, typename A<%=i%> = void<%}%>>
|
||||
struct tuple;
|
||||
|
||||
template <typename Tuple, int N>
|
||||
@ -136,81 +137,90 @@ inline tuple<A0<%1.upto(i) {|j|%>, A<%=j%><%}%>> make_tuple(typename tuple_type<
|
||||
|
||||
} // 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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
<%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;
|
||||
}
|
||||
}
|
||||
};
|
||||
<%}%>
|
||||
|
||||
template <typename Stream>
|
||||
inline const msgpack::packer<Stream>& operator<< (
|
||||
template <>
|
||||
struct pack<type::tuple<> > {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(
|
||||
msgpack::packer<Stream>& o,
|
||||
const type::tuple<>&) {
|
||||
const type::tuple<>&) const {
|
||||
o.pack_array(0);
|
||||
return o;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
<%0.upto(GENERATION_LIMIT) {|i|%>
|
||||
template <typename Stream, typename A0<%1.upto(i) {|j|%>, typename A<%=j%><%}%>>
|
||||
inline const msgpack::packer<Stream>& operator<< (
|
||||
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;
|
||||
}
|
||||
}
|
||||
};
|
||||
<%}%>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
<%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);<%}%>
|
||||
}
|
||||
}
|
||||
};
|
||||
<%}%>
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
} // 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
|
@ -23,3 +23,4 @@
|
||||
#include "msgpack/sbuffer.hpp"
|
||||
#include "msgpack/vrefbuffer.hpp"
|
||||
#include "msgpack/version.hpp"
|
||||
#include "msgpack/type.hpp"
|
||||
|
87
include/msgpack/adaptor/adaptor_base.hpp
Normal file
87
include/msgpack/adaptor/adaptor_base.hpp
Normal file
@ -0,0 +1,87 @@
|
||||
//
|
||||
// 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 {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
} // namespace msgpack
|
||||
|
||||
|
||||
#endif // MSGPACK_ADAPTOR_BASE_HPP
|
@ -19,37 +19,49 @@
|
||||
#define MSGPACK_TYPE_BOOL_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include <vector>
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
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 <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const bool& v)
|
||||
{
|
||||
template <>
|
||||
struct pack<bool> {
|
||||
template <typename Stream>
|
||||
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
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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
|
@ -28,48 +28,98 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const char* v)
|
||||
{
|
||||
namespace adaptor {
|
||||
|
||||
template <>
|
||||
struct pack<const char*> {
|
||||
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;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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));
|
||||
o.via.str.ptr = ptr;
|
||||
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 <typename Stream>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, char* v)
|
||||
{
|
||||
return msgpack::operator<<(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 pack<char*> {
|
||||
template <typename Stream>
|
||||
packer<Stream>& operator()(packer<Stream>& o, char* v) const {
|
||||
return o << static_cast<const char*>(v);
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (object& 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);
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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
|
@ -20,7 +20,7 @@
|
||||
#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>
|
||||
@ -29,8 +29,11 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
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) {
|
||||
@ -44,18 +47,23 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::array<T
|
||||
} while(p < pend);
|
||||
}
|
||||
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;
|
||||
@ -67,7 +75,10 @@ inline void operator<< (msgpack::object::with_zone& o, const std::array<T, N>& v
|
||||
o.via.array.ptr = p;
|
||||
for (auto const& e : v) *p++ = msgpack::object(e, o.zone);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#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>
|
||||
@ -28,9 +28,11 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
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(); }
|
||||
@ -45,37 +47,44 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::array<c
|
||||
break;
|
||||
}
|
||||
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));
|
||||
o.via.bin.ptr = ptr;
|
||||
o.via.bin.size = size;
|
||||
std::memcpy(ptr, v.data(), size);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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,7 +20,7 @@
|
||||
#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>
|
||||
@ -29,9 +29,11 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
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;
|
||||
@ -40,20 +42,23 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::forward
|
||||
++p;
|
||||
}
|
||||
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;
|
||||
@ -66,7 +71,10 @@ inline void operator<< (msgpack::object::with_zone& o, const std::forward_list<T
|
||||
o.via.array.ptr = p;
|
||||
for(auto const& e : v) *p++ = msgpack::object(e, o.zone);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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,7 +19,7 @@
|
||||
#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>
|
||||
@ -56,16 +56,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 +102,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,16 +146,22 @@ 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
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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,7 +19,7 @@
|
||||
#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>
|
||||
@ -28,9 +28,11 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
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);
|
||||
@ -42,11 +44,13 @@ 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());
|
||||
@ -55,11 +59,12 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
o.pack(it->second);
|
||||
}
|
||||
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;
|
||||
@ -78,12 +83,13 @@ inline void operator<< (msgpack::object::with_zone& o, const std::unordered_map<
|
||||
++it;
|
||||
} 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);
|
||||
@ -96,11 +102,13 @@ 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());
|
||||
@ -109,11 +117,12 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
o.pack(it->second);
|
||||
}
|
||||
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;
|
||||
@ -132,7 +141,10 @@ inline void operator<< (msgpack::object::with_zone& o, const std::unordered_mult
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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,7 +19,7 @@
|
||||
#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>
|
||||
@ -28,9 +28,11 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
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;
|
||||
@ -41,11 +43,13 @@ 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());
|
||||
@ -53,11 +57,12 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
o.pack(*it);
|
||||
}
|
||||
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;
|
||||
@ -75,12 +80,13 @@ inline void operator<< (msgpack::object::with_zone& o, const std::unordered_set<
|
||||
++it;
|
||||
} 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;
|
||||
@ -91,11 +97,13 @@ 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());
|
||||
@ -103,11 +111,12 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
o.pack(*it);
|
||||
}
|
||||
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;
|
||||
@ -125,7 +134,10 @@ inline void operator<< (msgpack::object::with_zone& o, const std::unordered_mult
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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,7 +19,7 @@
|
||||
#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>
|
||||
@ -28,9 +28,11 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
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;
|
||||
@ -40,11 +42,13 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::deque<T
|
||||
p->convert(*it);
|
||||
}
|
||||
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());
|
||||
@ -52,11 +56,12 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
o.pack(*it);
|
||||
}
|
||||
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;
|
||||
@ -74,7 +79,10 @@ inline void operator<< (msgpack::object::with_zone& o, const std::deque<T>& v)
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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,28 +40,35 @@
|
||||
}
|
||||
|
||||
// MSGPACK_ADD_ENUM must be used in the global namespace.
|
||||
#define MSGPACK_ADD_ENUM(enum) \
|
||||
#define MSGPACK_ADD_ENUM(enum_name) \
|
||||
namespace msgpack { \
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) { \
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, enum& v) \
|
||||
{ \
|
||||
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); \
|
||||
} \
|
||||
}; \
|
||||
|
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,31 +44,38 @@
|
||||
}
|
||||
|
||||
// MSGPACK_ADD_ENUM must be used in the global namespace.
|
||||
#define MSGPACK_ADD_ENUM(enum) \
|
||||
#define MSGPACK_ADD_ENUM(enum_name) \
|
||||
namespace msgpack { \
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) { \
|
||||
inline msgpack::object const& operator>> (msgpack::object const& o, enum& v) \
|
||||
{ \
|
||||
std::underlying_type<enum>::type tmp; \
|
||||
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); \
|
||||
} \
|
||||
}; \
|
||||
} \
|
||||
|
@ -119,14 +119,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 +164,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,15 +208,21 @@ 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
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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,7 +19,7 @@
|
||||
#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 {
|
||||
@ -56,69 +56,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 <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int8& v)
|
||||
template <>
|
||||
struct pack<type::fix_int8> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_int8& v) const
|
||||
{ o.pack_fix_int8(v); return o; }
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int16& v)
|
||||
template <>
|
||||
struct pack<type::fix_int16> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_int16& v) const
|
||||
{ o.pack_fix_int16(v); return o; }
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int32& v)
|
||||
template <>
|
||||
struct pack<type::fix_int32> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_int32& v) const
|
||||
{ o.pack_fix_int32(v); return o; }
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_int64& v)
|
||||
template <>
|
||||
struct pack<type::fix_int64> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_int64& v) const
|
||||
{ o.pack_fix_int64(v); return o; }
|
||||
};
|
||||
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint8& v)
|
||||
template <>
|
||||
struct pack<type::fix_uint8> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_uint8& v) const
|
||||
{ o.pack_fix_uint8(v); return o; }
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint16& v)
|
||||
template <>
|
||||
struct pack<type::fix_uint16> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_uint16& v) const
|
||||
{ o.pack_fix_uint16(v); return o; }
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint32& v)
|
||||
template <>
|
||||
struct pack<type::fix_uint32> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_uint32& v) const
|
||||
{ o.pack_fix_uint32(v); return o; }
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::fix_uint64& v)
|
||||
template <>
|
||||
struct pack<type::fix_uint64> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const type::fix_uint64& v) const
|
||||
{ o.pack_fix_uint64(v); return o; }
|
||||
};
|
||||
|
||||
|
||||
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();
|
||||
@ -127,10 +175,12 @@ inline void operator<< (msgpack::object& o, type::fix_int8 v)
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
o.via.u64 = v.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object& o, type::fix_int16 v)
|
||||
{
|
||||
template <>
|
||||
struct object<type::fix_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();
|
||||
@ -139,10 +189,12 @@ inline void operator<< (msgpack::object& o, type::fix_int16 v)
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
o.via.u64 = v.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object& o, type::fix_int32 v)
|
||||
{
|
||||
template <>
|
||||
struct object<type::fix_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();
|
||||
@ -151,10 +203,12 @@ inline void operator<< (msgpack::object& o, type::fix_int32 v)
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
o.via.u64 = v.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object& o, type::fix_int64 v)
|
||||
{
|
||||
template <>
|
||||
struct object<type::fix_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();
|
||||
@ -163,47 +217,83 @@ inline void operator<< (msgpack::object& o, type::fix_int64 v)
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
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
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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
|
@ -28,9 +28,11 @@ MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
// 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);
|
||||
}
|
||||
@ -44,18 +46,22 @@ inline msgpack::object const& operator>> (msgpack::object const& o, float& v)
|
||||
throw msgpack::type_error();
|
||||
}
|
||||
return o;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const float& v)
|
||||
{
|
||||
template <>
|
||||
struct pack<float> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const float& v) const {
|
||||
o.pack_float(v);
|
||||
return o;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
@ -69,34 +75,50 @@ inline msgpack::object const& operator>> (msgpack::object const& o, double& v)
|
||||
throw msgpack::type_error();
|
||||
}
|
||||
return o;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const double& v)
|
||||
{
|
||||
template <>
|
||||
struct pack<double> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const double& v) const {
|
||||
o.pack_double(v);
|
||||
return o;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
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
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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,7 +19,7 @@
|
||||
#define MSGPACK_TYPE_INT_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include <limits>
|
||||
|
||||
namespace msgpack {
|
||||
@ -101,95 +101,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 <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, char v)
|
||||
template <>
|
||||
struct pack<char> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, char v) const
|
||||
{ o.pack_char(v); return o; }
|
||||
};
|
||||
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed char v)
|
||||
template <>
|
||||
struct pack<signed char> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, signed char v) const
|
||||
{ o.pack_signed_char(v); return o; }
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed short v)
|
||||
template <>
|
||||
struct pack<signed short> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, signed short v) const
|
||||
{ o.pack_short(v); return o; }
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed int v)
|
||||
template <>
|
||||
struct pack<signed int> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, signed int v) const
|
||||
{ o.pack_int(v); return o; }
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed long v)
|
||||
template <>
|
||||
struct pack<signed long> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, signed long v) const
|
||||
{ o.pack_long(v); return o; }
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, signed long long v)
|
||||
template <>
|
||||
struct pack<signed long long> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, signed long long v) const
|
||||
{ o.pack_long_long(v); return o; }
|
||||
};
|
||||
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned char v)
|
||||
template <>
|
||||
struct pack<unsigned char> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, unsigned char v) const
|
||||
{ o.pack_unsigned_char(v); return o; }
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned short v)
|
||||
template <>
|
||||
struct pack<unsigned short> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, unsigned short v) const
|
||||
{ o.pack_unsigned_short(v); return o; }
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned int v)
|
||||
template <>
|
||||
struct pack<unsigned int> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, unsigned int v) const
|
||||
{ o.pack_unsigned_int(v); return o; }
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned long v)
|
||||
template <>
|
||||
struct pack<unsigned long> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, unsigned long v) const
|
||||
{ o.pack_unsigned_long(v); return o; }
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, unsigned long long v)
|
||||
template <>
|
||||
struct pack<unsigned long long> {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, unsigned long long v) const
|
||||
{ o.pack_unsigned_long_long(v); return o; }
|
||||
};
|
||||
|
||||
|
||||
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;
|
||||
@ -198,10 +267,12 @@ inline void operator<< (msgpack::object& o, signed char v)
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
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;
|
||||
@ -210,10 +281,12 @@ inline void operator<< (msgpack::object& o, signed short v)
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
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;
|
||||
@ -222,10 +295,12 @@ inline void operator<< (msgpack::object& o, signed int v)
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
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;
|
||||
@ -234,10 +309,12 @@ inline void operator<< (msgpack::object& o, signed long v)
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
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;
|
||||
@ -246,60 +323,107 @@ inline void operator<< (msgpack::object& o, signed long long v)
|
||||
o.type = msgpack::type::POSITIVE_INTEGER;
|
||||
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
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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,7 +19,7 @@
|
||||
#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>
|
||||
@ -28,9 +28,11 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
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;
|
||||
@ -40,11 +42,13 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::list<T>
|
||||
p->convert(*it);
|
||||
}
|
||||
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());
|
||||
@ -52,11 +56,12 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
o.pack(*it);
|
||||
}
|
||||
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;
|
||||
@ -74,7 +79,10 @@ inline void operator<< (msgpack::object::with_zone& o, const std::list<T>& v)
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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
|
@ -45,10 +45,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;
|
||||
@ -60,11 +61,13 @@ 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());
|
||||
@ -73,11 +76,12 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const ty
|
||||
o.pack(it->second);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K, typename V>
|
||||
inline void operator<< (msgpack::object::with_zone& o, const type::assoc_vector<K,V>& v)
|
||||
{
|
||||
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;
|
||||
@ -96,12 +100,12 @@ inline void operator<< (msgpack::object::with_zone& o, const type::assoc_vector<
|
||||
++it;
|
||||
} 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);
|
||||
@ -120,11 +124,13 @@ 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());
|
||||
@ -133,11 +139,12 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
o.pack(it->second);
|
||||
}
|
||||
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;
|
||||
@ -156,12 +163,13 @@ inline void operator<< (msgpack::object::with_zone& o, const std::map<K,V>& v)
|
||||
++it;
|
||||
} 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);
|
||||
@ -174,11 +182,13 @@ 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());
|
||||
@ -187,11 +197,12 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
o.pack(it->second);
|
||||
}
|
||||
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;
|
||||
@ -210,7 +221,10 @@ inline void operator<< (msgpack::object::with_zone& o, const std::multimap<K,V>&
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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,7 +19,7 @@
|
||||
#define MSGPACK_TYPE_NIL_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
@ -31,28 +31,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 <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const type::nil&)
|
||||
{
|
||||
template <>
|
||||
struct pack<type::nil> {
|
||||
template <typename Stream>
|
||||
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,6 +73,7 @@ inline void msgpack::object::as<void>() const
|
||||
convert(v);
|
||||
}
|
||||
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
} // 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,42 +19,50 @@
|
||||
#define MSGPACK_TYPE_PAIR_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/object_fwd.hpp"
|
||||
#include "msgpack/adaptor/adaptor_base.hpp"
|
||||
#include <utility>
|
||||
|
||||
namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
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;
|
||||
o.via.array.size = 2;
|
||||
p[0] = msgpack::object(v.first, o.zone);
|
||||
p[1] = msgpack::object(v.second, o.zone);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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,8 +19,8 @@
|
||||
#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 {
|
||||
@ -63,33 +63,45 @@ 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 <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const msgpack::type::raw_ref& v)
|
||||
{
|
||||
template <>
|
||||
struct pack<msgpack::type::raw_ref> {
|
||||
template <typename Stream>
|
||||
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
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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,7 +19,7 @@
|
||||
#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>
|
||||
@ -28,9 +28,11 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
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;
|
||||
@ -41,11 +43,13 @@ 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());
|
||||
@ -53,11 +57,12 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
o.pack(*it);
|
||||
}
|
||||
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;
|
||||
@ -75,12 +80,12 @@ inline void operator<< (msgpack::object::with_zone& o, const std::set<T>& v)
|
||||
++it;
|
||||
} 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;
|
||||
@ -91,11 +96,13 @@ 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());
|
||||
@ -103,11 +110,12 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
o.pack(*it);
|
||||
}
|
||||
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;
|
||||
@ -125,7 +133,10 @@ inline void operator<< (msgpack::object::with_zone& o, const std::multiset<T>& v
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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,7 +19,7 @@
|
||||
#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>
|
||||
@ -28,8 +28,11 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
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);
|
||||
@ -42,34 +45,43 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::string&
|
||||
break;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::string& v)
|
||||
{
|
||||
template <>
|
||||
struct pack<std::string> {
|
||||
template <typename Stream>
|
||||
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));
|
||||
o.via.str.ptr = ptr;
|
||||
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
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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)
|
||||
@ -47,9 +47,11 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
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);
|
||||
@ -61,11 +63,13 @@ 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());
|
||||
@ -74,11 +78,12 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MS
|
||||
o.pack(it->second);
|
||||
}
|
||||
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;
|
||||
@ -97,12 +102,12 @@ inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::un
|
||||
++it;
|
||||
} 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);
|
||||
@ -115,11 +120,13 @@ 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());
|
||||
@ -128,11 +135,12 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MS
|
||||
o.pack(it->second);
|
||||
}
|
||||
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;
|
||||
@ -151,7 +159,10 @@ inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::un
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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)
|
||||
@ -47,9 +47,11 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
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;
|
||||
@ -60,11 +62,13 @@ 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());
|
||||
@ -72,11 +76,12 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MS
|
||||
o.pack(*it);
|
||||
}
|
||||
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;
|
||||
@ -94,12 +99,13 @@ inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::un
|
||||
++it;
|
||||
} 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;
|
||||
@ -110,11 +116,13 @@ 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());
|
||||
@ -122,11 +130,12 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const MS
|
||||
o.pack(*it);
|
||||
}
|
||||
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;
|
||||
@ -144,7 +153,10 @@ inline void operator<< (msgpack::object::with_zone& o, const MSGPACK_STD_TR1::un
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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,7 +19,7 @@
|
||||
#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>
|
||||
@ -28,15 +28,17 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
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;
|
||||
@ -44,11 +46,13 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::vector<
|
||||
} while(p < pend);
|
||||
}
|
||||
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());
|
||||
@ -56,11 +60,12 @@ inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const st
|
||||
o.pack(*it);
|
||||
}
|
||||
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;
|
||||
@ -78,7 +83,10 @@ inline void operator<< (msgpack::object::with_zone& o, const std::vector<T>& v)
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -26,8 +26,11 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
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);
|
||||
@ -40,21 +43,25 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::vector<
|
||||
}
|
||||
}
|
||||
return o;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::vector<bool>& v)
|
||||
{
|
||||
template <>
|
||||
struct pack<std::vector<bool> > {
|
||||
template <typename Stream>
|
||||
msgpack::packer<Stream>& operator()(msgpack::packer<Stream>& o, const std::vector<bool>& v) const {
|
||||
o.pack_array(v.size());
|
||||
for(std::vector<bool>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
o.pack(static_cast<bool>(*it));
|
||||
}
|
||||
return o;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
inline void operator<< (msgpack::object::with_zone& o, const std::vector<bool>& v)
|
||||
{
|
||||
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;
|
||||
@ -66,12 +73,15 @@ inline void operator<< (msgpack::object::with_zone& o, const std::vector<bool>&
|
||||
o.via.array.size = v.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
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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,7 +19,7 @@
|
||||
#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>
|
||||
@ -28,8 +28,11 @@ namespace msgpack {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
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);
|
||||
@ -44,35 +47,44 @@ inline msgpack::object const& operator>> (msgpack::object const& o, std::vector<
|
||||
break;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename Stream>
|
||||
inline msgpack::packer<Stream>& operator<< (msgpack::packer<Stream>& o, const std::vector<char>& v)
|
||||
{
|
||||
template <>
|
||||
struct pack<std::vector<char> > {
|
||||
template <typename Stream>
|
||||
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));
|
||||
o.via.bin.ptr = ptr;
|
||||
o.via.bin.size = size;
|
||||
std::memcpy(ptr, &v.front(), size);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -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
|
@ -20,7 +20,7 @@
|
||||
#define MSGPACK_ITERATOR_HPP
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
#include <msgpack_fwd.hpp>
|
||||
#include <msgpack/object_fwd.hpp>
|
||||
|
||||
namespace msgpack
|
||||
{
|
||||
|
@ -19,61 +19,21 @@
|
||||
#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 {
|
||||
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
struct object::with_zone : object {
|
||||
with_zone(msgpack::zone& zone) : zone(zone) { }
|
||||
msgpack::zone& zone;
|
||||
private:
|
||||
with_zone();
|
||||
};
|
||||
|
||||
struct object::implicit_type {
|
||||
implicit_type(object const& o) : obj(o) { }
|
||||
~implicit_type() { }
|
||||
@ -85,119 +45,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 +198,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 +211,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 +219,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 +228,48 @@ inline void operator<< (msgpack::object::with_zone& o, const msgpack::object& v)
|
||||
default:
|
||||
throw msgpack::type_error();
|
||||
}
|
||||
}
|
||||
|
||||
inline void operator<< (msgpack::object::with_zone& o, const msgpack::object::with_zone& v)
|
||||
{
|
||||
return o << static_cast<msgpack::object const&>(v);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
void msgpack_unpack(object const& o)
|
||||
{
|
||||
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 +412,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);
|
||||
}
|
||||
|
||||
|
@ -143,37 +143,12 @@ 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();
|
||||
};
|
||||
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define MSGPACK_PACK_HPP
|
||||
|
||||
#include "msgpack/versioning.hpp"
|
||||
#include "msgpack/cpp_config.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
#include <limits>
|
||||
@ -119,11 +120,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 +142,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>
|
||||
|
@ -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 \
|
||||
|
@ -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;
|
||||
|
77
tmp/msgpack/versioning.hpp
Normal file
77
tmp/msgpack/versioning.hpp
Normal file
@ -0,0 +1,77 @@
|
||||
/*
|
||||
* 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_VERSIONING_HPP
|
||||
#define MSGPACK_VERSIONING_HPP
|
||||
|
||||
#if !defined(MSGPACK_DEFAULT_API_VERSION)
|
||||
#define MSGPACK_DEFAULT_API_VERSION 1
|
||||
#endif
|
||||
|
||||
#define MSGPACK_DEFAULT_API_NS MSGPACK_PP_CAT(v, MSGPACK_DEFAULT_API_VERSION)
|
||||
|
||||
#if MSGPACK_DEFAULT_API_VERSION == 1
|
||||
#define MSGPACK_PP_ENABLE_NS_v1 ()
|
||||
//#elif MSGPACK_DEFAULT_API_VERSION == 2
|
||||
//#define MSGPACK_PP_ENABLE_NS_v2 ()
|
||||
#else
|
||||
#error
|
||||
#endif
|
||||
|
||||
#define MSGPACK_PP_CAT(a, ...) MSGPACK_PP_PRIMITIVE_CAT(a, __VA_ARGS__)
|
||||
#define MSGPACK_PP_PRIMITIVE_CAT(a, ...) a ## __VA_ARGS__
|
||||
|
||||
#define MSGPACK_PP_IIF(c) MSGPACK_PP_PRIMITIVE_CAT(MSGPACK_PP_IIF_, c)
|
||||
#define MSGPACK_PP_IIF_0(t, ...) __VA_ARGS__
|
||||
#define MSGPACK_PP_IIF_1(t, ...) t
|
||||
|
||||
#define MSGPACK_PP_PROBE(x) x, 1
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
#define MSGPACK_PP_MSVC_VA_ARGS_WORKAROUND(define, args) define args
|
||||
#define MSGPACK_PP_CHECK(...) MSGPACK_PP_MSVC_VA_ARGS_WORKAROUND(MSGPACK_PP_CHECK_N, (__VA_ARGS__, 0))
|
||||
#define MSGPACK_PP_CHECK_N(x, n, ...) n
|
||||
|
||||
#else // defined(__MSC_VER)
|
||||
|
||||
#define MSGPACK_PP_CHECK(...) MSGPACK_PP_CHECK_N(__VA_ARGS__, 0)
|
||||
#define MSGPACK_PP_CHECK_N(x, n, ...) n
|
||||
|
||||
#endif // defined(__MSC_VER)
|
||||
|
||||
|
||||
#define MSGPACK_PP_NS_ENABLED_PROBE(ns) MSGPACK_PP_NS_ENABLED_PROBE_PROXY( MSGPACK_PP_ENABLE_NS_##ns )
|
||||
#define MSGPACK_PP_NS_ENABLED_PROBE_PROXY(...) MSGPACK_PP_NS_ENABLED_PROBE_PRIMIVIE(__VA_ARGS__)
|
||||
#define MSGPACK_PP_NS_ENABLED_PROBE_PRIMIVIE(x) MSGPACK_PP_NS_ENABLED_PROBE_COMBINE_ x
|
||||
#define MSGPACK_PP_NS_ENABLED_PROBE_COMBINE_(...) MSGPACK_PP_PROBE(~)
|
||||
|
||||
#define MSGPACK_PP_IS_NS_ENABLED(ns) MSGPACK_PP_CHECK(MSGPACK_PP_NS_ENABLED_PROBE(ns))
|
||||
|
||||
#if __cplusplus < 201103
|
||||
#define MSGPACK_API_VERSION_NAMESPACE(ns) MSGPACK_PP_IIF(MSGPACK_PP_IS_NS_ENABLED(ns)) \
|
||||
(namespace ns{}; using namespace ns; namespace ns, \
|
||||
namespace ns)
|
||||
|
||||
#else // __cplusplus < 201103
|
||||
|
||||
#define MSGPACK_API_VERSION_NAMESPACE(ns) MSGPACK_PP_IIF(MSGPACK_PP_IS_NS_ENABLED(ns)) \
|
||||
(inline namespace ns, namespace ns)
|
||||
|
||||
#endif // __cplusplus < 201103
|
||||
|
||||
#endif // MSGPACK_VERSIONING_HPP
|
Loading…
x
Reference in New Issue
Block a user