mirror of
https://github.com/EttusResearch/uhd.git
synced 2026-10-25 17:36:10 +00:00
deps: rpclib: Remove dependency on __cplusplus value
In some cases, rpclib uses the value of the `__cplusplus` macro to determine implementation details. We remove these, as UHD requires C++17 anyway now and the value of __cplusplus may be broken depending on compilers.
This commit is contained in:
parent
4d59a22cf9
commit
3fb9555bee
@ -22,10 +22,7 @@
|
||||
#include "rpc/msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "rpc/msgpack/adaptor/check_container_size.hpp"
|
||||
#include "rpc/msgpack/meta.hpp"
|
||||
|
||||
#if !defined (MSGPACK_USE_CPP03)
|
||||
#include "rpc/msgpack/adaptor/cpp11/tuple.hpp"
|
||||
#endif // #if !defined (MSGPACK_USE_CPP03)
|
||||
|
||||
#include <boost/fusion/support/is_sequence.hpp>
|
||||
#include <boost/fusion/sequence/intrinsic/size.hpp>
|
||||
@ -42,8 +39,6 @@ MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
#if !defined (MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T>
|
||||
struct as<
|
||||
T,
|
||||
@ -87,8 +82,6 @@ struct as<
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined (MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T>
|
||||
struct convert<T, typename clmdep_msgpack::enable_if<boost::fusion::traits::is_sequence<T>::value>::type > {
|
||||
clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, T& v) const {
|
||||
|
||||
@ -269,8 +269,6 @@ typedef basic_variant<
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
#if !defined (MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename STR, typename BIN, typename EXT>
|
||||
struct as<clmdep_msgpack::type::basic_variant<STR, BIN, EXT> > {
|
||||
clmdep_msgpack::type::basic_variant<STR, BIN, EXT> operator()(clmdep_msgpack::object const& o) const {
|
||||
@ -302,8 +300,6 @@ struct as<clmdep_msgpack::type::basic_variant<STR, BIN, EXT> > {
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined (MSGPACK_USE_CPP03)
|
||||
|
||||
|
||||
template <typename STR, typename BIN, typename EXT>
|
||||
struct convert<clmdep_msgpack::type::basic_variant<STR, BIN, EXT> > {
|
||||
|
||||
@ -42,7 +42,6 @@ MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
#if !defined (MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T>
|
||||
struct as<boost::optional<T>, typename std::enable_if<clmdep_msgpack::has_as<T>::value>::type> {
|
||||
@ -52,8 +51,6 @@ struct as<boost::optional<T>, typename std::enable_if<clmdep_msgpack::has_as<T>:
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined (MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T>
|
||||
struct convert<boost::optional<T> > {
|
||||
clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, boost::optional<T>& v) const {
|
||||
|
||||
@ -30,10 +30,8 @@ MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
struct container_size_overflow : public std::runtime_error {
|
||||
explicit container_size_overflow(const std::string& msg)
|
||||
:std::runtime_error(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
explicit container_size_overflow(const char* msg):
|
||||
std::runtime_error(msg) {}
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
|
||||
@ -20,13 +20,8 @@
|
||||
|
||||
#include "rpc/msgpack/cpp_config.hpp"
|
||||
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
#include "detail/cpp03_define_array.hpp"
|
||||
#include "detail/cpp03_define_map.hpp"
|
||||
#else // MSGPACK_USE_CPP03
|
||||
#include "detail/cpp11_define_array.hpp"
|
||||
#include "detail/cpp11_define_map.hpp"
|
||||
#endif // MSGPACK_USE_CPP03
|
||||
|
||||
#if defined(MSGPACK_USE_DEFINE_MAP)
|
||||
#define MSGPACK_DEFINE MSGPACK_DEFINE_MAP
|
||||
|
||||
@ -32,8 +32,6 @@ MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T, typename Alloc>
|
||||
struct as<std::deque<T, Alloc>, typename std::enable_if<clmdep_msgpack::has_as<T>::value>::type> {
|
||||
std::deque<T, Alloc> operator()(const clmdep_msgpack::object& o) const {
|
||||
@ -51,8 +49,6 @@ struct as<std::deque<T, Alloc>, typename std::enable_if<clmdep_msgpack::has_as<T
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T, typename Alloc>
|
||||
struct convert<std::deque<T, Alloc> > {
|
||||
clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::deque<T, Alloc>& v) const {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -32,8 +32,6 @@ MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T, typename Alloc>
|
||||
struct as<std::list<T, Alloc>, typename std::enable_if<clmdep_msgpack::has_as<T>::value>::type> {
|
||||
std::list<T, Alloc> operator()(clmdep_msgpack::object const& o) const {
|
||||
@ -48,8 +46,6 @@ struct as<std::list<T, Alloc>, typename std::enable_if<clmdep_msgpack::has_as<T>
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T, typename Alloc>
|
||||
struct convert<std::list<T, Alloc> > {
|
||||
clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::list<T, Alloc>& v) const {
|
||||
|
||||
@ -36,9 +36,7 @@ namespace type {
|
||||
|
||||
template <typename K, typename V, typename Compare = std::less<K>, typename Alloc = std::allocator<std::pair<K, V> > >
|
||||
class assoc_vector : public std::vector< std::pair<K, V>, Alloc > {
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
using std::vector<std::pair<K, V>, Alloc>::vector;
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
};
|
||||
|
||||
namespace detail {
|
||||
@ -53,8 +51,6 @@ namespace detail {
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename K, typename V, typename Compare, typename Alloc>
|
||||
struct as<
|
||||
type::assoc_vector<K, V, Compare, Alloc>,
|
||||
@ -73,8 +69,6 @@ struct as<
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename K, typename V, typename Compare, typename Alloc>
|
||||
struct convert<type::assoc_vector<K, V, Compare, Alloc> > {
|
||||
clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, type::assoc_vector<K, V, Compare, Alloc>& v) const {
|
||||
@ -132,8 +126,6 @@ struct object_with_zone<type::assoc_vector<K, V, Compare, Alloc> > {
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename K, typename V, typename Compare, typename Alloc>
|
||||
struct as<
|
||||
std::map<K, V, Compare, Alloc>,
|
||||
@ -150,8 +142,6 @@ struct as<
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename K, typename V, typename Compare, typename Alloc>
|
||||
struct convert<std::map<K, V, Compare, Alloc> > {
|
||||
clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::map<K, V, Compare, Alloc>& v) const {
|
||||
@ -162,17 +152,9 @@ struct convert<std::map<K, V, Compare, Alloc> > {
|
||||
for (; p != pend; ++p) {
|
||||
K key;
|
||||
p->key.convert(key);
|
||||
#if __cplusplus >= 201103L
|
||||
p->val.convert(tmp[std::move(key)]);
|
||||
#else
|
||||
p->val.convert(tmp[key]);
|
||||
#endif
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
v = std::move(tmp);
|
||||
#else
|
||||
tmp.swap(v);
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
};
|
||||
@ -217,8 +199,6 @@ struct object_with_zone<std::map<K, V, Compare, Alloc> > {
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename K, typename V, typename Compare, typename Alloc>
|
||||
struct as<
|
||||
std::multimap<K, V, Compare, Alloc>,
|
||||
@ -235,8 +215,6 @@ struct as<
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename K, typename V, typename Compare, typename Alloc>
|
||||
struct convert<std::multimap<K, V, Compare, Alloc> > {
|
||||
clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::multimap<K, V, Compare, Alloc>& v) const {
|
||||
@ -248,17 +226,9 @@ struct convert<std::multimap<K, V, Compare, Alloc> > {
|
||||
std::pair<K, V> value;
|
||||
p->key.convert(value.first);
|
||||
p->val.convert(value.second);
|
||||
#if __cplusplus >= 201103L
|
||||
tmp.insert(std::move(value));
|
||||
#else
|
||||
tmp.insert(value);
|
||||
#endif
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
v = std::move(tmp);
|
||||
#else
|
||||
tmp.swap(v);
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
@ -19,11 +19,6 @@
|
||||
#define MSGPACK_MSGPACK_TUPLE_HPP
|
||||
|
||||
#include "rpc/msgpack/cpp_config.hpp"
|
||||
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
#include "detail/cpp03_msgpack_tuple.hpp"
|
||||
#else // MSGPACK_USE_CPP03
|
||||
#include "detail/cpp11_msgpack_tuple.hpp"
|
||||
#endif // MSGPACK_USE_CPP03
|
||||
|
||||
#endif // MSGPACK_MSGPACK_TUPLE_HPP
|
||||
|
||||
@ -32,8 +32,6 @@ MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct as<std::pair<T1, T2>,
|
||||
typename std::enable_if<clmdep_msgpack::all_of<clmdep_msgpack::has_as, T1, T2>::value>::type> {
|
||||
@ -44,8 +42,6 @@ struct as<std::pair<T1, T2>,
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T1, typename T2>
|
||||
struct convert<std::pair<T1, T2> > {
|
||||
clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::pair<T1, T2>& v) const {
|
||||
|
||||
@ -32,8 +32,6 @@ MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T, typename Compare, typename Alloc>
|
||||
struct as<std::set<T, Compare, Alloc>, typename std::enable_if<clmdep_msgpack::has_as<T>::value>::type> {
|
||||
std::set<T, Compare, Alloc> operator()(clmdep_msgpack::object const& o) const {
|
||||
@ -49,8 +47,6 @@ struct as<std::set<T, Compare, Alloc>, typename std::enable_if<clmdep_msgpack::h
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T, typename Compare, typename Alloc>
|
||||
struct convert<std::set<T, Compare, Alloc> > {
|
||||
clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::set<T, Compare, Alloc>& v) const {
|
||||
@ -62,11 +58,7 @@ struct convert<std::set<T, Compare, Alloc> > {
|
||||
--p;
|
||||
tmp.insert(p->as<T>());
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
v = std::move(tmp);
|
||||
#else
|
||||
tmp.swap(v);
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
};
|
||||
@ -109,8 +101,6 @@ struct object_with_zone<std::set<T, Compare, Alloc> > {
|
||||
}
|
||||
};
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T, typename Compare, typename Alloc>
|
||||
struct as<std::multiset<T, Compare, Alloc>, typename std::enable_if<clmdep_msgpack::has_as<T>::value>::type> {
|
||||
std::multiset<T, Compare, Alloc> operator()(clmdep_msgpack::object const& o) const {
|
||||
@ -126,8 +116,6 @@ struct as<std::multiset<T, Compare, Alloc>, typename std::enable_if<clmdep_msgpa
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T, typename Compare, typename Alloc>
|
||||
struct convert<std::multiset<T, Compare, Alloc> > {
|
||||
clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::multiset<T, Compare, Alloc>& v) const {
|
||||
@ -139,11 +127,7 @@ struct convert<std::multiset<T, Compare, Alloc> > {
|
||||
--p;
|
||||
tmp.insert(p->as<T>());
|
||||
}
|
||||
#if __cplusplus >= 201103L
|
||||
v = std::move(tmp);
|
||||
#else
|
||||
tmp.swap(v);
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
@ -1,179 +0,0 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2008-2015 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_MAP_HPP
|
||||
#define MSGPACK_TYPE_TR1_UNORDERED_MAP_HPP
|
||||
|
||||
#include "rpc/msgpack/versioning.hpp"
|
||||
#include "rpc/msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "rpc/msgpack/adaptor/check_container_size.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 clmdep_msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
template <typename K, typename V, typename Hash, typename Pred, typename Alloc>
|
||||
struct convert<MSGPACK_STD_TR1::unordered_map<K, V, Hash, Pred, Alloc> > {
|
||||
clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, MSGPACK_STD_TR1::unordered_map<K, V, Hash, Pred, Alloc>& v) const {
|
||||
if(o.type != clmdep_msgpack::type::MAP) { throw clmdep_msgpack::type_error(); }
|
||||
clmdep_msgpack::object_kv* p(o.via.map.ptr);
|
||||
clmdep_msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||
MSGPACK_STD_TR1::unordered_map<K, V, Hash, Pred, Alloc> tmp;
|
||||
for(; p != pend; ++p) {
|
||||
K key;
|
||||
p->key.convert(key);
|
||||
p->val.convert(tmp[key]);
|
||||
}
|
||||
tmp.swap(v);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K, typename V, typename Hash, typename Pred, typename Alloc>
|
||||
struct pack<MSGPACK_STD_TR1::unordered_map<K, V, Hash, Pred, Alloc> > {
|
||||
template <typename Stream>
|
||||
clmdep_msgpack::packer<Stream>& operator()(clmdep_msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_map<K, V, Hash, Pred, Alloc>& v) const {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_map(size);
|
||||
for(typename MSGPACK_STD_TR1::unordered_map<K, V, Hash, Pred, Alloc>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
o.pack(it->first);
|
||||
o.pack(it->second);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K, typename V, typename Hash, typename Pred, typename Alloc>
|
||||
struct object_with_zone<MSGPACK_STD_TR1::unordered_map<K, V, Hash, Pred, Alloc> > {
|
||||
void operator()(clmdep_msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_map<K, V, Hash, Pred, Alloc>& v) const {
|
||||
o.type = clmdep_msgpack::type::MAP;
|
||||
if(v.empty()) {
|
||||
o.via.map.ptr = nullptr;
|
||||
o.via.map.size = 0;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
clmdep_msgpack::object_kv* p = static_cast<clmdep_msgpack::object_kv*>(o.zone.allocate_align(sizeof(clmdep_msgpack::object_kv)*size));
|
||||
clmdep_msgpack::object_kv* const pend = p + size;
|
||||
o.via.map.ptr = p;
|
||||
o.via.map.size = size;
|
||||
typename MSGPACK_STD_TR1::unordered_map<K, V, Hash, Pred, Alloc>::const_iterator it(v.begin());
|
||||
do {
|
||||
p->key = clmdep_msgpack::object(it->first, o.zone);
|
||||
p->val = clmdep_msgpack::object(it->second, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K, typename V, typename Hash, typename Pred, typename Alloc>
|
||||
struct convert<MSGPACK_STD_TR1::unordered_multimap<K, V, Hash, Pred, Alloc> > {
|
||||
clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, MSGPACK_STD_TR1::unordered_multimap<K, V, Hash, Pred, Alloc>& v) const {
|
||||
if(o.type != clmdep_msgpack::type::MAP) { throw clmdep_msgpack::type_error(); }
|
||||
clmdep_msgpack::object_kv* p(o.via.map.ptr);
|
||||
clmdep_msgpack::object_kv* const pend(o.via.map.ptr + o.via.map.size);
|
||||
MSGPACK_STD_TR1::unordered_multimap<K, V, Hash, Pred, Alloc> tmp;
|
||||
for(; p != pend; ++p) {
|
||||
std::pair<K, V> value;
|
||||
p->key.convert(value.first);
|
||||
p->val.convert(value.second);
|
||||
tmp.insert(value);
|
||||
}
|
||||
tmp.swap(v);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K, typename V, typename Hash, typename Pred, typename Alloc>
|
||||
struct pack<MSGPACK_STD_TR1::unordered_multimap<K, V, Hash, Pred, Alloc> > {
|
||||
template <typename Stream>
|
||||
clmdep_msgpack::packer<Stream>& operator()(clmdep_msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_multimap<K, V, Hash, Pred, Alloc>& v) const {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_map(size);
|
||||
for(typename MSGPACK_STD_TR1::unordered_multimap<K, V, Hash, Pred, Alloc>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
o.pack(it->first);
|
||||
o.pack(it->second);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename K, typename V, typename Hash, typename Pred, typename Alloc>
|
||||
struct object_with_zone<MSGPACK_STD_TR1::unordered_multimap<K, V, Hash, Pred, Alloc> > {
|
||||
void operator()(clmdep_msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_multimap<K, V, Hash, Pred, Alloc>& v) const {
|
||||
o.type = clmdep_msgpack::type::MAP;
|
||||
if(v.empty()) {
|
||||
o.via.map.ptr = nullptr;
|
||||
o.via.map.size = 0;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
clmdep_msgpack::object_kv* p = static_cast<clmdep_msgpack::object_kv*>(o.zone.allocate_align(sizeof(clmdep_msgpack::object_kv)*size));
|
||||
clmdep_msgpack::object_kv* const pend = p + size;
|
||||
o.via.map.ptr = p;
|
||||
o.via.map.size = size;
|
||||
typename MSGPACK_STD_TR1::unordered_multimap<K, V, Hash, Pred, Alloc>::const_iterator it(v.begin());
|
||||
do {
|
||||
p->key = clmdep_msgpack::object(it->first, o.zone);
|
||||
p->val = clmdep_msgpack::object(it->second, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace clmdep_msgpack
|
||||
|
||||
#undef MSGPACK_STD_TR1
|
||||
|
||||
#endif // MSGPACK_STD_TR1
|
||||
|
||||
#endif // MSGPACK_TYPE_TR1_UNORDERED_MAP_HPP
|
||||
@ -1,173 +0,0 @@
|
||||
//
|
||||
// MessagePack for C++ static resolution routine
|
||||
//
|
||||
// Copyright (C) 2008-2015 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_HPP
|
||||
#define MSGPACK_TYPE_TR1_UNORDERED_SET_HPP
|
||||
|
||||
#include "rpc/msgpack/versioning.hpp"
|
||||
#include "rpc/msgpack/adaptor/adaptor_base.hpp"
|
||||
#include "rpc/msgpack/adaptor/check_container_size.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 clmdep_msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
template <typename T, typename Hash, typename Compare, typename Alloc>
|
||||
struct convert<MSGPACK_STD_TR1::unordered_set<T, Hash, Compare, Alloc> > {
|
||||
clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, MSGPACK_STD_TR1::unordered_set<T, Hash, Compare, Alloc>& v) const {
|
||||
if(o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); }
|
||||
clmdep_msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
||||
clmdep_msgpack::object* const pbegin = o.via.array.ptr;
|
||||
MSGPACK_STD_TR1::unordered_set<T, Hash, Compare, Alloc> tmp;
|
||||
while(p > pbegin) {
|
||||
--p;
|
||||
tmp.insert(p->as<T>());
|
||||
}
|
||||
tmp.swap(v);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename Hash, typename Compare, typename Alloc>
|
||||
struct pack<MSGPACK_STD_TR1::unordered_set<T, Hash, Compare, Alloc> > {
|
||||
template <typename Stream>
|
||||
clmdep_msgpack::packer<Stream>& operator()(clmdep_msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_set<T, Hash, Compare, Alloc>& v) const {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_array(size);
|
||||
for(typename MSGPACK_STD_TR1::unordered_set<T, Hash, Compare, Alloc>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
o.pack(*it);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename Hash, typename Compare, typename Alloc>
|
||||
struct object_with_zone<MSGPACK_STD_TR1::unordered_set<T, Hash, Compare, Alloc> > {
|
||||
void operator()(clmdep_msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_set<T, Hash, Compare, Alloc>& v) const {
|
||||
o.type = clmdep_msgpack::type::ARRAY;
|
||||
if(v.empty()) {
|
||||
o.via.array.ptr = nullptr;
|
||||
o.via.array.size = 0;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
clmdep_msgpack::object* p = static_cast<clmdep_msgpack::object*>(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size));
|
||||
clmdep_msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = size;
|
||||
typename MSGPACK_STD_TR1::unordered_set<T, Hash, Compare, Alloc>::const_iterator it(v.begin());
|
||||
do {
|
||||
*p = clmdep_msgpack::object(*it, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename T, typename Hash, typename Compare, typename Alloc>
|
||||
struct convert<MSGPACK_STD_TR1::unordered_multiset<T, Hash, Compare, Alloc> > {
|
||||
clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, MSGPACK_STD_TR1::unordered_multiset<T, Hash, Compare, Alloc>& v) const {
|
||||
if(o.type != clmdep_msgpack::type::ARRAY) { throw clmdep_msgpack::type_error(); }
|
||||
clmdep_msgpack::object* p = o.via.array.ptr + o.via.array.size;
|
||||
clmdep_msgpack::object* const pbegin = o.via.array.ptr;
|
||||
MSGPACK_STD_TR1::unordered_multiset<T, Hash, Compare, Alloc> tmp;
|
||||
while(p > pbegin) {
|
||||
--p;
|
||||
tmp.insert(p->as<T>());
|
||||
}
|
||||
tmp.swap(v);
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename Hash, typename Compare, typename Alloc>
|
||||
struct pack<MSGPACK_STD_TR1::unordered_multiset<T, Hash, Compare, Alloc> > {
|
||||
template <typename Stream>
|
||||
clmdep_msgpack::packer<Stream>& operator()(clmdep_msgpack::packer<Stream>& o, const MSGPACK_STD_TR1::unordered_multiset<T, Hash, Compare, Alloc>& v) const {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
o.pack_array(size);
|
||||
for(typename MSGPACK_STD_TR1::unordered_multiset<T, Hash, Compare, Alloc>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
o.pack(*it);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, typename Hash, typename Compare, typename Alloc>
|
||||
struct object_with_zone<MSGPACK_STD_TR1::unordered_multiset<T, Hash, Compare, Alloc> > {
|
||||
void operator()(clmdep_msgpack::object::with_zone& o, const MSGPACK_STD_TR1::unordered_multiset<T, Hash, Compare, Alloc>& v) const {
|
||||
o.type = clmdep_msgpack::type::ARRAY;
|
||||
if(v.empty()) {
|
||||
o.via.array.ptr = nullptr;
|
||||
o.via.array.size = 0;
|
||||
} else {
|
||||
uint32_t size = checked_get_container_size(v.size());
|
||||
clmdep_msgpack::object* p = static_cast<clmdep_msgpack::object*>(o.zone.allocate_align(sizeof(clmdep_msgpack::object)*size));
|
||||
clmdep_msgpack::object* const pend = p + size;
|
||||
o.via.array.ptr = p;
|
||||
o.via.array.size = size;
|
||||
typename MSGPACK_STD_TR1::unordered_multiset<T, Hash, Compare, Alloc>::const_iterator it(v.begin());
|
||||
do {
|
||||
*p = clmdep_msgpack::object(*it, o.zone);
|
||||
++p;
|
||||
++it;
|
||||
} while(p < pend);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace adaptor
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace clmdep_msgpack
|
||||
|
||||
#undef MSGPACK_STD_TR1
|
||||
|
||||
#endif // MSGPACK_STD_TR1
|
||||
|
||||
#endif // MSGPACK_TYPE_TR1_UNORDERED_SET_HPP
|
||||
@ -32,8 +32,6 @@ MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
|
||||
namespace adaptor {
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T, typename Alloc>
|
||||
struct as<std::vector<T, Alloc>, typename std::enable_if<clmdep_msgpack::has_as<T>::value>::type> {
|
||||
std::vector<T, Alloc> operator()(const clmdep_msgpack::object& o) const {
|
||||
@ -52,8 +50,6 @@ struct as<std::vector<T, Alloc>, typename std::enable_if<clmdep_msgpack::has_as<
|
||||
}
|
||||
};
|
||||
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T, typename Alloc>
|
||||
struct convert<std::vector<T, Alloc> > {
|
||||
clmdep_msgpack::object const& operator()(clmdep_msgpack::object const& o, std::vector<T, Alloc>& v) const {
|
||||
|
||||
@ -20,69 +20,6 @@
|
||||
|
||||
#include "rpc/msgpack/versioning.hpp"
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
# if defined(_MSC_VER)
|
||||
# if _MSC_VER < 1900
|
||||
# define MSGPACK_USE_CPP03
|
||||
# endif
|
||||
# elif (__cplusplus < 201103L)
|
||||
# define MSGPACK_USE_CPP03
|
||||
# endif
|
||||
#endif // MSGPACK_USE_CPP03
|
||||
|
||||
|
||||
|
||||
#if defined __cplusplus
|
||||
#if __cplusplus < 201103L
|
||||
|
||||
#if !defined(nullptr)
|
||||
# if _MSC_VER < 1600
|
||||
# define nullptr (0)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace clmdep_msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
template <bool P, typename T = void>
|
||||
struct enable_if {
|
||||
typedef T type;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct enable_if<false, T> {
|
||||
};
|
||||
|
||||
template<typename T, T val>
|
||||
struct integral_constant {
|
||||
static T const value = val;
|
||||
typedef T value_type;
|
||||
typedef integral_constant<T, val> type;
|
||||
};
|
||||
|
||||
typedef integral_constant<bool, true> true_type;
|
||||
typedef integral_constant<bool, false> false_type;
|
||||
|
||||
template<class T, class U>
|
||||
struct is_same : false_type {};
|
||||
|
||||
template<class T>
|
||||
struct is_same<T, T> : true_type {};
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace clmdep_msgpack
|
||||
|
||||
|
||||
#else // __cplusplus < 201103L
|
||||
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
|
||||
@ -107,9 +44,4 @@ MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
} // namespace clmdep_msgpack
|
||||
|
||||
|
||||
#endif // __cplusplus < 201103L
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif /* msgpack/cpp_config.hpp */
|
||||
|
||||
@ -1,676 +0,0 @@
|
||||
//
|
||||
// MessagePack for C++ memory pool
|
||||
//
|
||||
// Copyright (C) 2008-2010 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_CPP03_ZONE_HPP
|
||||
#define MSGPACK_CPP03_ZONE_HPP
|
||||
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "rpc/msgpack/versioning.hpp"
|
||||
|
||||
#ifndef MSGPACK_ZONE_CHUNK_SIZE
|
||||
#define MSGPACK_ZONE_CHUNK_SIZE 8192
|
||||
#endif
|
||||
|
||||
#ifndef MSGPACK_ZONE_ALIGN
|
||||
#define MSGPACK_ZONE_ALIGN sizeof(void*)
|
||||
#endif
|
||||
|
||||
|
||||
namespace clmdep_msgpack {
|
||||
|
||||
/// @cond
|
||||
MSGPACK_API_VERSION_NAMESPACE(v1) {
|
||||
/// @endcond
|
||||
|
||||
class zone {
|
||||
struct finalizer {
|
||||
finalizer(void (*func)(void*), void* data):m_func(func), m_data(data) {}
|
||||
void operator()() { m_func(m_data); }
|
||||
void (*m_func)(void*);
|
||||
void* m_data;
|
||||
};
|
||||
struct finalizer_array {
|
||||
finalizer_array():m_tail(nullptr), m_end(nullptr), m_array(nullptr) {}
|
||||
void call() {
|
||||
finalizer* fin = m_tail;
|
||||
for(; fin != m_array; --fin) (*(fin-1))();
|
||||
}
|
||||
~finalizer_array() {
|
||||
call();
|
||||
::free(m_array);
|
||||
}
|
||||
void clear() {
|
||||
call();
|
||||
m_tail = m_array;
|
||||
}
|
||||
void push(void (*func)(void* data), void* data)
|
||||
{
|
||||
finalizer* fin = m_tail;
|
||||
|
||||
if(fin == m_end) {
|
||||
push_expand(func, data);
|
||||
return;
|
||||
}
|
||||
|
||||
fin->m_func = func;
|
||||
fin->m_data = data;
|
||||
|
||||
++m_tail;
|
||||
}
|
||||
void push_expand(void (*func)(void*), void* data) {
|
||||
const size_t nused = m_end - m_array;
|
||||
size_t nnext;
|
||||
if(nused == 0) {
|
||||
nnext = (sizeof(finalizer) < 72/2) ?
|
||||
72 / sizeof(finalizer) : 8;
|
||||
} else {
|
||||
nnext = nused * 2;
|
||||
}
|
||||
finalizer* tmp =
|
||||
static_cast<finalizer*>(::realloc(m_array, sizeof(finalizer) * nnext));
|
||||
if(!tmp) {
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
m_array = tmp;
|
||||
m_end = tmp + nnext;
|
||||
m_tail = tmp + nused;
|
||||
new (m_tail) finalizer(func, data);
|
||||
|
||||
++m_tail;
|
||||
}
|
||||
finalizer* m_tail;
|
||||
finalizer* m_end;
|
||||
finalizer* m_array;
|
||||
};
|
||||
struct chunk {
|
||||
chunk* m_next;
|
||||
};
|
||||
struct chunk_list {
|
||||
chunk_list(size_t chunk_size)
|
||||
{
|
||||
chunk* c = static_cast<chunk*>(::malloc(sizeof(chunk) + chunk_size));
|
||||
if(!c) {
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
|
||||
m_head = c;
|
||||
m_free = chunk_size;
|
||||
m_ptr = reinterpret_cast<char*>(c) + sizeof(chunk);
|
||||
c->m_next = nullptr;
|
||||
}
|
||||
~chunk_list()
|
||||
{
|
||||
chunk* c = m_head;
|
||||
while(c) {
|
||||
chunk* n = c->m_next;
|
||||
::free(c);
|
||||
c = n;
|
||||
}
|
||||
}
|
||||
void clear(size_t chunk_size)
|
||||
{
|
||||
chunk* c = m_head;
|
||||
while(true) {
|
||||
chunk* n = c->m_next;
|
||||
if(n) {
|
||||
::free(c);
|
||||
c = n;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
m_head->m_next = nullptr;
|
||||
m_free = chunk_size;
|
||||
m_ptr = reinterpret_cast<char*>(m_head) + sizeof(chunk);
|
||||
}
|
||||
size_t m_free;
|
||||
char* m_ptr;
|
||||
chunk* m_head;
|
||||
};
|
||||
size_t m_chunk_size;
|
||||
chunk_list m_chunk_list;
|
||||
finalizer_array m_finalizer_array;
|
||||
|
||||
public:
|
||||
zone(size_t chunk_size = MSGPACK_ZONE_CHUNK_SIZE) /* throw() */;
|
||||
|
||||
public:
|
||||
void* allocate_align(size_t size, size_t align = MSGPACK_ZONE_ALIGN);
|
||||
void* allocate_no_align(size_t size);
|
||||
|
||||
void push_finalizer(void (*func)(void*), void* data);
|
||||
|
||||
template <typename T>
|
||||
void push_finalizer(std::unique_ptr<T> obj);
|
||||
|
||||
void clear();
|
||||
|
||||
void swap(zone& o);
|
||||
static void* operator new(std::size_t size)
|
||||
{
|
||||
void* p = ::malloc(size);
|
||||
if (!p) throw std::bad_alloc();
|
||||
return p;
|
||||
}
|
||||
static void operator delete(void *p) /* throw() */
|
||||
{
|
||||
::free(p);
|
||||
}
|
||||
static void* operator new(std::size_t size, void* place) /* throw() */
|
||||
{
|
||||
return ::operator new(size, place);
|
||||
}
|
||||
static void operator delete(void* p, void* place) /* throw() */
|
||||
{
|
||||
::operator delete(p, place);
|
||||
}
|
||||
/// @cond
|
||||
|
||||
template <typename T>
|
||||
T* allocate();
|
||||
|
||||
template <typename T, typename A1>
|
||||
T* allocate(A1 a1);
|
||||
|
||||
template <typename T, typename A1, typename A2>
|
||||
T* allocate(A1 a1, A2 a2);
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3>
|
||||
T* allocate(A1 a1, A2 a2, A3 a3);
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4>
|
||||
T* allocate(A1 a1, A2 a2, A3 a3, A4 a4);
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5>
|
||||
T* allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5);
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
|
||||
T* allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6);
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
|
||||
T* allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7);
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
|
||||
T* allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8);
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9>
|
||||
T* allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9);
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10>
|
||||
T* allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10);
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11>
|
||||
T* allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11);
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12>
|
||||
T* allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12);
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13>
|
||||
T* allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12, A13 a13);
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14>
|
||||
T* allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12, A13 a13, A14 a14);
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15>
|
||||
T* allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12, A13 a13, A14 a14, A15 a15);
|
||||
|
||||
/// @endcond
|
||||
|
||||
private:
|
||||
void undo_allocate(size_t size);
|
||||
|
||||
template <typename T>
|
||||
static void object_destruct(void* obj);
|
||||
|
||||
template <typename T>
|
||||
static void object_delete(void* obj);
|
||||
|
||||
void* allocate_expand(size_t size);
|
||||
private:
|
||||
zone(const zone&);
|
||||
zone& operator=(const zone&);
|
||||
};
|
||||
|
||||
inline zone::zone(size_t chunk_size) /* throw() */ :m_chunk_size(chunk_size), m_chunk_list(m_chunk_size)
|
||||
{
|
||||
}
|
||||
|
||||
inline void* zone::allocate_align(size_t size, size_t align)
|
||||
{
|
||||
char* aligned =
|
||||
reinterpret_cast<char*>(
|
||||
reinterpret_cast<size_t>(
|
||||
(m_chunk_list.m_ptr + (align - 1))) / align * align);
|
||||
size_t adjusted_size = size + (aligned - m_chunk_list.m_ptr);
|
||||
if(m_chunk_list.m_free >= adjusted_size) {
|
||||
m_chunk_list.m_free -= adjusted_size;
|
||||
m_chunk_list.m_ptr += adjusted_size;
|
||||
return aligned;
|
||||
}
|
||||
return reinterpret_cast<char*>(
|
||||
reinterpret_cast<size_t>(
|
||||
allocate_expand(size + (align - 1))) / align * align);
|
||||
}
|
||||
|
||||
inline void* zone::allocate_no_align(size_t size)
|
||||
{
|
||||
if(m_chunk_list.m_free < size) {
|
||||
return allocate_expand(size);
|
||||
}
|
||||
|
||||
char* ptr = m_chunk_list.m_ptr;
|
||||
m_chunk_list.m_free -= size;
|
||||
m_chunk_list.m_ptr += size;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
inline void* zone::allocate_expand(size_t size)
|
||||
{
|
||||
chunk_list* const cl = &m_chunk_list;
|
||||
|
||||
size_t sz = m_chunk_size;
|
||||
|
||||
while(sz < size) {
|
||||
size_t tmp_sz = sz * 2;
|
||||
if (tmp_sz <= sz) {
|
||||
sz = size;
|
||||
break;
|
||||
}
|
||||
sz = tmp_sz;
|
||||
}
|
||||
|
||||
chunk* c = static_cast<chunk*>(::malloc(sizeof(chunk) + sz));
|
||||
if (!c) throw std::bad_alloc();
|
||||
|
||||
char* ptr = reinterpret_cast<char*>(c) + sizeof(chunk);
|
||||
|
||||
c->m_next = cl->m_head;
|
||||
cl->m_head = c;
|
||||
cl->m_free = sz - size;
|
||||
cl->m_ptr = ptr + size;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
inline void zone::push_finalizer(void (*func)(void*), void* data)
|
||||
{
|
||||
m_finalizer_array.push(func, data);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void zone::push_finalizer(std::unique_ptr<T> obj)
|
||||
{
|
||||
m_finalizer_array.push(&zone::object_delete<T>, obj.release());
|
||||
}
|
||||
|
||||
inline void zone::clear()
|
||||
{
|
||||
m_finalizer_array.clear();
|
||||
m_chunk_list.clear(m_chunk_size);
|
||||
}
|
||||
|
||||
inline void zone::swap(zone& o)
|
||||
{
|
||||
using std::swap;
|
||||
swap(m_chunk_size, o.m_chunk_size);
|
||||
swap(m_chunk_list, o.m_chunk_list);
|
||||
swap(m_finalizer_array, o.m_finalizer_array);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void zone::object_destruct(void* obj)
|
||||
{
|
||||
static_cast<T*>(obj)->~T();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void zone::object_delete(void* obj)
|
||||
{
|
||||
delete static_cast<T*>(obj);
|
||||
}
|
||||
|
||||
inline void zone::undo_allocate(size_t size)
|
||||
{
|
||||
m_chunk_list.m_ptr -= size;
|
||||
m_chunk_list.m_free += size;
|
||||
}
|
||||
|
||||
inline std::size_t aligned_size(
|
||||
std::size_t size,
|
||||
std::size_t align = MSGPACK_ZONE_ALIGN) {
|
||||
return (size + align - 1) / align * align;
|
||||
}
|
||||
|
||||
/// @cond
|
||||
|
||||
template <typename T>
|
||||
T* zone::allocate()
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
try {
|
||||
return new (x) T();
|
||||
} catch (...) {
|
||||
--m_finalizer_array.m_tail;
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename A1>
|
||||
T* zone::allocate(A1 a1)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
try {
|
||||
return new (x) T(a1);
|
||||
} catch (...) {
|
||||
--m_finalizer_array.m_tail;
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename A1, typename A2>
|
||||
T* zone::allocate(A1 a1, A2 a2)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
try {
|
||||
return new (x) T(a1, a2);
|
||||
} catch (...) {
|
||||
--m_finalizer_array.m_tail;
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
try {
|
||||
return new (x) T(a1, a2, a3);
|
||||
} catch (...) {
|
||||
--m_finalizer_array.m_tail;
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
try {
|
||||
return new (x) T(a1, a2, a3, a4);
|
||||
} catch (...) {
|
||||
--m_finalizer_array.m_tail;
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
try {
|
||||
return new (x) T(a1, a2, a3, a4, a5);
|
||||
} catch (...) {
|
||||
--m_finalizer_array.m_tail;
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
try {
|
||||
return new (x) T(a1, a2, a3, a4, a5, a6);
|
||||
} catch (...) {
|
||||
--m_finalizer_array.m_tail;
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
try {
|
||||
return new (x) T(a1, a2, a3, a4, a5, a6, a7);
|
||||
} catch (...) {
|
||||
--m_finalizer_array.m_tail;
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
try {
|
||||
return new (x) T(a1, a2, a3, a4, a5, a6, a7, a8);
|
||||
} catch (...) {
|
||||
--m_finalizer_array.m_tail;
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
try {
|
||||
return new (x) T(a1, a2, a3, a4, a5, a6, a7, a8, a9);
|
||||
} catch (...) {
|
||||
--m_finalizer_array.m_tail;
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
try {
|
||||
return new (x) T(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
|
||||
} catch (...) {
|
||||
--m_finalizer_array.m_tail;
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
try {
|
||||
return new (x) T(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11);
|
||||
} catch (...) {
|
||||
--m_finalizer_array.m_tail;
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
try {
|
||||
return new (x) T(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12);
|
||||
} catch (...) {
|
||||
--m_finalizer_array.m_tail;
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12, A13 a13)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
try {
|
||||
return new (x) T(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13);
|
||||
} catch (...) {
|
||||
--m_finalizer_array.m_tail;
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12, A13 a13, A14 a14)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
try {
|
||||
return new (x) T(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14);
|
||||
} catch (...) {
|
||||
--m_finalizer_array.m_tail;
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename A1, typename A2, typename A3, typename A4, typename A5, typename A6, typename A7, typename A8, typename A9, typename A10, typename A11, typename A12, typename A13, typename A14, typename A15>
|
||||
T* zone::allocate(A1 a1, A2 a2, A3 a3, A4 a4, A5 a5, A6 a6, A7 a7, A8 a8, A9 a9, A10 a10, A11 a11, A12 a12, A13 a13, A14 a14, A15 a15)
|
||||
{
|
||||
void* x = allocate_align(sizeof(T));
|
||||
try {
|
||||
m_finalizer_array.push(&zone::object_destruct<T>, x);
|
||||
} catch (...) {
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
try {
|
||||
return new (x) T(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15);
|
||||
} catch (...) {
|
||||
--m_finalizer_array.m_tail;
|
||||
undo_allocate(sizeof(T));
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// @endcond
|
||||
|
||||
/// @cond
|
||||
} // MSGPACK_API_VERSION_NAMESPACE(v1)
|
||||
/// @endcond
|
||||
|
||||
} // namespace clmdep_msgpack
|
||||
|
||||
#endif // MSGPACK_CPP03_ZONE_HPP
|
||||
@ -46,14 +46,8 @@ public:
|
||||
return m_file;
|
||||
}
|
||||
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
private:
|
||||
fbuffer(const fbuffer&);
|
||||
fbuffer& operator=(const fbuffer&);
|
||||
#else // defined(MSGPACK_USE_CPP03)
|
||||
fbuffer(const fbuffer&) = delete;
|
||||
fbuffer& operator=(const fbuffer&) = delete;
|
||||
#endif // defined(MSGPACK_USE_CPP03)
|
||||
|
||||
private:
|
||||
FILE* m_file;
|
||||
|
||||
@ -18,8 +18,6 @@
|
||||
|
||||
#ifndef MSGPACK_ITERATOR_HPP
|
||||
#define MSGPACK_ITERATOR_HPP
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
#include <rpc/msgpack/object_fwd.hpp>
|
||||
|
||||
namespace clmdep_msgpack
|
||||
@ -42,5 +40,4 @@ namespace clmdep_msgpack
|
||||
/// @endcond
|
||||
}
|
||||
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
#endif // MSGPACK_ITERATOR_HPP
|
||||
|
||||
@ -19,8 +19,6 @@
|
||||
#ifndef MSGPACK_META_HPP
|
||||
#define MSGPACK_META_HPP
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
namespace clmdep_msgpack {
|
||||
@ -54,6 +52,4 @@ struct gen_seq<0, Is...> : seq<Is...> {};
|
||||
|
||||
} // namespace clmdep_msgpack
|
||||
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
#endif // MSGPACK_META_HPP
|
||||
|
||||
@ -71,39 +71,6 @@ public:
|
||||
const std::unique_ptr<clmdep_msgpack::zone>& zone() const
|
||||
{ return m_zone; }
|
||||
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
struct object_handle_ref {
|
||||
object_handle_ref(object_handle* oh):m_oh(oh) {}
|
||||
object_handle* m_oh;
|
||||
};
|
||||
|
||||
object_handle(object_handle& other):
|
||||
m_obj(other.m_obj),
|
||||
m_zone(std::move(other.m_zone)) {
|
||||
}
|
||||
|
||||
object_handle(object_handle_ref ref):
|
||||
m_obj(ref.m_oh->m_obj),
|
||||
m_zone(std::move(ref.m_oh->m_zone)) {
|
||||
}
|
||||
|
||||
object_handle& operator=(object_handle& other) {
|
||||
m_obj = other.m_obj;
|
||||
m_zone = std::move(other.m_zone);
|
||||
return *this;
|
||||
}
|
||||
|
||||
object_handle& operator=(object_handle_ref ref) {
|
||||
m_obj = ref.m_oh->m_obj;
|
||||
m_zone = std::move(ref.m_oh->m_zone);
|
||||
return *this;
|
||||
}
|
||||
|
||||
operator object_handle_ref() {
|
||||
return object_handle_ref(this);
|
||||
}
|
||||
#endif // defined(MSGPACK_USE_CPP03)
|
||||
|
||||
object_handle& assign(object_handle&& other) {
|
||||
m_obj = other.m_obj;
|
||||
m_zone = std::move(other.m_zone);
|
||||
@ -541,18 +508,6 @@ inline bool object::convert_if_not_nil(T& v) const
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T>
|
||||
inline T object::as() const
|
||||
{
|
||||
T v;
|
||||
convert(v);
|
||||
return v;
|
||||
}
|
||||
|
||||
#else // defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T>
|
||||
inline typename std::enable_if<clmdep_msgpack::has_as<T>::value, T>::type object::as() const {
|
||||
return clmdep_msgpack::adaptor::as<T>()(*this);
|
||||
@ -565,8 +520,6 @@ inline typename std::enable_if<!clmdep_msgpack::has_as<T>::value, T>::type objec
|
||||
return v;
|
||||
}
|
||||
|
||||
#endif // defined(MSGPACK_USE_CPP03)
|
||||
|
||||
inline object::object()
|
||||
{
|
||||
type = clmdep_msgpack::type::NIL;
|
||||
|
||||
@ -82,7 +82,6 @@ struct object_ext {
|
||||
};
|
||||
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
struct object;
|
||||
|
||||
namespace adaptor {
|
||||
@ -105,7 +104,6 @@ public:
|
||||
static constexpr bool value = type::value;
|
||||
};
|
||||
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
|
||||
struct object {
|
||||
@ -129,21 +127,12 @@ struct object {
|
||||
|
||||
bool is_nil() const { return type == clmdep_msgpack::type::NIL; }
|
||||
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T>
|
||||
T as() const;
|
||||
|
||||
#else // defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<clmdep_msgpack::has_as<T>::value, T>::type as() const;
|
||||
|
||||
template <typename T>
|
||||
typename std::enable_if<!clmdep_msgpack::has_as<T>::value, T>::type as() const;
|
||||
|
||||
#endif // defined(MSGPACK_USE_CPP03)
|
||||
|
||||
template <typename T>
|
||||
T& convert(T& v) const;
|
||||
template <typename T>
|
||||
|
||||
@ -122,17 +122,10 @@ private:
|
||||
private:
|
||||
Stream& m_stream;
|
||||
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
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)
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -51,7 +51,6 @@ public:
|
||||
::free(m_data);
|
||||
}
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
sbuffer(const sbuffer&) = delete;
|
||||
sbuffer& operator=(const sbuffer&) = delete;
|
||||
|
||||
@ -75,7 +74,6 @@ public:
|
||||
|
||||
return *this;
|
||||
}
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
void write(const char* buf, size_t len)
|
||||
{
|
||||
@ -139,12 +137,6 @@ private:
|
||||
m_alloc = nsize;
|
||||
}
|
||||
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
private:
|
||||
sbuffer(const sbuffer&);
|
||||
sbuffer& operator=(const sbuffer&);
|
||||
#endif // defined(MSGPACK_USE_CPP03)
|
||||
|
||||
private:
|
||||
size_t m_size;
|
||||
char* m_data;
|
||||
|
||||
@ -22,13 +22,6 @@
|
||||
#include "adaptor/msgpack_tuple.hpp"
|
||||
#include "adaptor/define.hpp"
|
||||
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
|
||||
#include "adaptor/tr1/unordered_map.hpp"
|
||||
#include "adaptor/tr1/unordered_set.hpp"
|
||||
|
||||
#else // defined(MSGPACK_USE_CPP03)
|
||||
|
||||
#include "adaptor/cpp11/array.hpp"
|
||||
#include "adaptor/cpp11/array_char.hpp"
|
||||
#include "adaptor/cpp11/array_unsigned_char.hpp"
|
||||
@ -39,8 +32,6 @@
|
||||
#include "adaptor/cpp11/unordered_map.hpp"
|
||||
#include "adaptor/cpp11/unordered_set.hpp"
|
||||
|
||||
#endif // defined(MSGPACK_USE_CPP03)
|
||||
|
||||
#if defined(MSGPACK_USE_BOOST)
|
||||
|
||||
#include "adaptor/boost/fusion.hpp"
|
||||
|
||||
@ -27,10 +27,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <stdexcept>
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
#include <atomic>
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
@ -73,91 +70,71 @@ typedef bool (*unpack_reference_func)(clmdep_msgpack::type::object_type, std::si
|
||||
struct unpack_error : public std::runtime_error {
|
||||
explicit unpack_error(const std::string& msg)
|
||||
:std::runtime_error(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
explicit unpack_error(const char* msg):
|
||||
std::runtime_error(msg) {}
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
};
|
||||
|
||||
struct parse_error : public unpack_error {
|
||||
explicit parse_error(const std::string& msg)
|
||||
:unpack_error(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
explicit parse_error(const char* msg)
|
||||
:unpack_error(msg) {}
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
};
|
||||
|
||||
struct insufficient_bytes : public unpack_error {
|
||||
explicit insufficient_bytes(const std::string& msg)
|
||||
:unpack_error(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
explicit insufficient_bytes(const char* msg)
|
||||
:unpack_error(msg) {}
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
};
|
||||
|
||||
struct size_overflow : public unpack_error {
|
||||
explicit size_overflow(const std::string& msg)
|
||||
:unpack_error(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
explicit size_overflow(const char* msg)
|
||||
:unpack_error(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct array_size_overflow : public size_overflow {
|
||||
array_size_overflow(const std::string& msg)
|
||||
:size_overflow(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
array_size_overflow(const char* msg)
|
||||
:size_overflow(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct map_size_overflow : public size_overflow {
|
||||
map_size_overflow(const std::string& msg)
|
||||
:size_overflow(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
map_size_overflow(const char* msg)
|
||||
:size_overflow(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct str_size_overflow : public size_overflow {
|
||||
str_size_overflow(const std::string& msg)
|
||||
:size_overflow(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
str_size_overflow(const char* msg)
|
||||
:size_overflow(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct bin_size_overflow : public size_overflow {
|
||||
bin_size_overflow(const std::string& msg)
|
||||
:size_overflow(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
bin_size_overflow(const char* msg)
|
||||
:size_overflow(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct ext_size_overflow : public size_overflow {
|
||||
ext_size_overflow(const std::string& msg)
|
||||
:size_overflow(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
ext_size_overflow(const char* msg)
|
||||
:size_overflow(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct depth_size_overflow : public size_overflow {
|
||||
depth_size_overflow(const std::string& msg)
|
||||
:size_overflow(msg) {}
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
depth_size_overflow(const char* msg)
|
||||
:size_overflow(msg) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
class unpack_limit {
|
||||
@ -369,46 +346,25 @@ private:
|
||||
|
||||
inline void init_count(void* buffer)
|
||||
{
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
*reinterpret_cast<volatile _msgpack_atomic_counter_t*>(buffer) = 1;
|
||||
#else // defined(MSGPACK_USE_CPP03)
|
||||
new (buffer) std::atomic<unsigned int>(1);
|
||||
#endif // defined(MSGPACK_USE_CPP03)
|
||||
}
|
||||
|
||||
inline void decr_count(void* buffer)
|
||||
{
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
if(_msgpack_sync_decr_and_fetch(reinterpret_cast<volatile _msgpack_atomic_counter_t*>(buffer)) == 0) {
|
||||
free(buffer);
|
||||
}
|
||||
#else // defined(MSGPACK_USE_CPP03)
|
||||
if (--*reinterpret_cast<std::atomic<unsigned int>*>(buffer) == 0) {
|
||||
free(buffer);
|
||||
}
|
||||
#endif // defined(MSGPACK_USE_CPP03)
|
||||
}
|
||||
|
||||
inline void incr_count(void* buffer)
|
||||
{
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
_msgpack_sync_incr_and_fetch(reinterpret_cast<volatile _msgpack_atomic_counter_t*>(buffer));
|
||||
#else // defined(MSGPACK_USE_CPP03)
|
||||
++*reinterpret_cast<std::atomic<unsigned int>*>(buffer);
|
||||
#endif // defined(MSGPACK_USE_CPP03)
|
||||
}
|
||||
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
inline _msgpack_atomic_counter_t get_count(void* buffer)
|
||||
{
|
||||
return *reinterpret_cast<volatile _msgpack_atomic_counter_t*>(buffer);
|
||||
}
|
||||
#else // defined(MSGPACK_USE_CPP03)
|
||||
inline std::atomic<unsigned int> const& get_count(void* buffer)
|
||||
{
|
||||
return *reinterpret_cast<std::atomic<unsigned int>*>(buffer);
|
||||
}
|
||||
#endif // defined(MSGPACK_USE_CPP03)
|
||||
|
||||
struct fix_tag {
|
||||
char f1[65]; // FIXME unique size is required. or use is_same meta function.
|
||||
@ -1000,10 +956,8 @@ public:
|
||||
std::size_t init_buffer_size = MSGPACK_UNPACKER_INIT_BUFFER_SIZE,
|
||||
unpack_limit const& limit = unpack_limit());
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
unpacker(unpacker&& other);
|
||||
unpacker& operator=(unpacker&& other);
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
~unpacker();
|
||||
|
||||
@ -1110,14 +1064,8 @@ private:
|
||||
std::size_t m_initial_buffer_size;
|
||||
detail::context m_ctx;
|
||||
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
private:
|
||||
unpacker(const unpacker&);
|
||||
unpacker& operator=(const unpacker&);
|
||||
#else // defined(MSGPACK_USE_CPP03)
|
||||
unpacker(const unpacker&) = delete;
|
||||
unpacker& operator=(const unpacker&) = delete;
|
||||
#endif // defined(MSGPACK_USE_CPP03)
|
||||
};
|
||||
|
||||
unpacked unpack(
|
||||
@ -1222,7 +1170,6 @@ inline unpacker::unpacker(unpack_reference_func f,
|
||||
m_ctx.user().set_referenced(false);
|
||||
}
|
||||
|
||||
#if !defined(MSGPACK_USE_CPP03)
|
||||
// Move constructor and move assignment operator
|
||||
|
||||
inline unpacker::unpacker(unpacker&& other)
|
||||
@ -1243,8 +1190,6 @@ inline unpacker& unpacker::operator=(unpacker&& other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // !defined(MSGPACK_USE_CPP03)
|
||||
|
||||
|
||||
inline unpacker::~unpacker()
|
||||
{
|
||||
|
||||
@ -62,16 +62,7 @@
|
||||
|
||||
#define MSGPACK_DETAIL_PP_IS_NS_ENABLED(ns) MSGPACK_DETAIL_PP_CHECK(MSGPACK_DETAIL_PP_NS_ENABLED_PROBE(ns))
|
||||
|
||||
#if __cplusplus < 201103L
|
||||
#define MSGPACK_API_VERSION_NAMESPACE(ns) MSGPACK_DETAIL_PP_IIF(MSGPACK_DETAIL_PP_IS_NS_ENABLED(ns)) \
|
||||
(namespace ns{}; using namespace ns; namespace ns, \
|
||||
namespace ns)
|
||||
|
||||
#else // __cplusplus < 201103L
|
||||
|
||||
#define MSGPACK_API_VERSION_NAMESPACE(ns) MSGPACK_DETAIL_PP_IIF(MSGPACK_DETAIL_PP_IS_NS_ENABLED(ns)) \
|
||||
(inline namespace ns, namespace ns)
|
||||
|
||||
#endif // __cplusplus < 201103L
|
||||
|
||||
#endif // MSGPACK_VERSIONING_HPP
|
||||
|
||||
@ -270,14 +270,8 @@ public:
|
||||
m_tail = m_array;
|
||||
}
|
||||
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
private:
|
||||
vrefbuffer(const vrefbuffer&);
|
||||
vrefbuffer& operator=(const vrefbuffer&);
|
||||
#else // defined(MSGPACK_USE_CPP03)
|
||||
vrefbuffer(const vrefbuffer&) = delete;
|
||||
vrefbuffer& operator=(const vrefbuffer&) = delete;
|
||||
#endif // defined(MSGPACK_USE_CPP03)
|
||||
|
||||
private:
|
||||
iovec* m_tail;
|
||||
|
||||
@ -151,14 +151,8 @@ private:
|
||||
|
||||
return true;
|
||||
}
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
private:
|
||||
zbuffer(const zbuffer&);
|
||||
zbuffer& operator=(const zbuffer&);
|
||||
#else // defined(MSGPACK_USE_CPP03)
|
||||
zbuffer(const zbuffer&) = delete;
|
||||
zbuffer& operator=(const zbuffer&) = delete;
|
||||
#endif // defined(MSGPACK_USE_CPP03)
|
||||
|
||||
private:
|
||||
z_stream m_stream;
|
||||
|
||||
@ -19,11 +19,6 @@
|
||||
#define MSGPACK_ZONE_HPP
|
||||
|
||||
#include "rpc/msgpack/cpp_config.hpp"
|
||||
|
||||
#if defined(MSGPACK_USE_CPP03)
|
||||
#include "detail/cpp03_zone.hpp"
|
||||
#else // MSGPACK_USE_CPP03
|
||||
#include "detail/cpp11_zone.hpp"
|
||||
#endif // MSGPACK_USE_CPP03
|
||||
|
||||
#endif // MSGPACK_ZONE_HPP
|
||||
|
||||
Loading…
Reference in New Issue
Block a user