10 #ifndef MSGPACK_TYPE_MAP_HPP 11 #define MSGPACK_TYPE_MAP_HPP 29 template <
typename K,
typename V,
typename Compare = std::less<K>,
typename Alloc = std::allocator<std::pair<K, V> > >
30 class assoc_vector :
public std::vector< std::pair<K, V>, Alloc > {
31 #if !defined(MSGPACK_USE_CPP03) 32 using std::vector<std::pair<K, V>, Alloc>::vector;
33 #endif // !defined(MSGPACK_USE_CPP03) 37 template <
typename K,
typename V,
typename Compare,
typename Alloc>
39 bool operator() (
const std::pair<K, V>& x,
const std::pair<K, V>& y)
const 40 {
return Compare()(x.first, y.first); }
48 #if !defined(MSGPACK_USE_CPP03) 50 template <
typename K,
typename V,
typename Compare,
typename Alloc>
52 type::assoc_vector<K, V, Compare, Alloc>,
53 typename std::enable_if<msgpack::has_as<K>::value && msgpack::has_as<V>::value>::type> {
60 for (; p < pend; ++p) {
61 v.emplace_back(p->
key.
as<K>(), p->
val.
as<V>());
68 #endif // !defined(MSGPACK_USE_CPP03) 70 template <
typename K,
typename V,
typename Compare,
typename Alloc>
71 struct convert<type::assoc_vector<K, V, Compare, Alloc> > {
78 std::pair<K, V>* it(&v.front());
79 for (; p < pend; ++p, ++it) {
89 template <
typename K,
typename V,
typename Compare,
typename Alloc>
90 struct pack<type::assoc_vector<K, V, Compare, Alloc> > {
91 template <
typename Stream>
104 template <
typename K,
typename V,
typename Compare,
typename Alloc>
129 #if !defined(MSGPACK_USE_CPP03) 131 template <
typename K,
typename V,
typename Compare,
typename Alloc>
133 std::map<K, V, Compare, Alloc>,
134 typename std::enable_if<msgpack::has_as<K>::value && msgpack::has_as<V>::value>::type> {
139 std::map<K, V, Compare, Alloc> v;
140 for (; p != pend; ++p) {
147 #endif // !defined(MSGPACK_USE_CPP03) 149 template <
typename K,
typename V,
typename Compare,
typename Alloc>
150 struct convert<std::map<K, V, Compare, Alloc> > {
155 std::map<K, V, Compare, Alloc> tmp;
156 for (; p != pend; ++p) {
159 #if __cplusplus >= 201103L 165 #if __cplusplus >= 201103L 174 template <
typename K,
typename V,
typename Compare,
typename Alloc>
175 struct pack<std::map<K, V, Compare, Alloc> > {
176 template <
typename Stream>
180 for (
typename std::map<K, V, Compare, Alloc>::const_iterator it(v.begin()), it_end(v.end());
181 it != it_end; ++it) {
189 template <
typename K,
typename V,
typename Compare,
typename Alloc>
204 typename std::map<K, V, Compare, Alloc>::const_iterator it(v.begin());
206 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__) 207 #pragma GCC diagnostic push 208 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" 209 #endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__) 212 #if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__) 213 #pragma GCC diagnostic pop 214 #endif // (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__) 222 #if !defined(MSGPACK_USE_CPP03) 224 template <
typename K,
typename V,
typename Compare,
typename Alloc>
226 std::multimap<K, V, Compare, Alloc>,
227 typename std::enable_if<msgpack::has_as<K>::value && msgpack::has_as<V>::value>::type> {
232 std::multimap<K, V, Compare, Alloc> v;
233 for (; p != pend; ++p) {
240 #endif // !defined(MSGPACK_USE_CPP03) 242 template <
typename K,
typename V,
typename Compare,
typename Alloc>
243 struct convert<std::multimap<K, V, Compare, Alloc> > {
248 std::multimap<K, V, Compare, Alloc> tmp;
249 for (; p != pend; ++p) {
250 std::pair<K, V> value;
253 #if __cplusplus >= 201103L 259 #if __cplusplus >= 201103L 268 template <
typename K,
typename V,
typename Compare,
typename Alloc>
269 struct pack<std::multimap<K, V, Compare, Alloc> > {
270 template <
typename Stream>
274 for (
typename std::multimap<K, V, Compare, Alloc>::const_iterator it(v.begin()), it_end(v.end());
275 it != it_end; ++it) {
283 template <
typename K,
typename V,
typename Compare,
typename Alloc>
297 typename std::multimap<K, V, Compare, Alloc>::const_iterator it(v.begin());
316 #endif // MSGPACK_TYPE_MAP_HPP T & convert(T &v) const
Convert the object.
Definition: object.hpp:520
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition: versioning.hpp:58
type::assoc_vector< K, V, Compare, Alloc > operator()(msgpack::object const &o) const
Definition: map.hpp:54
msgpack::object_kv * ptr
Definition: object_fwd.hpp:56
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const std::multimap< K, V, Compare, Alloc > &v) const
Definition: map.hpp:271
void * allocate_align(size_t size, size_t align=MSGPACK_ZONE_ALIGN)
Definition: cpp03_zone.hpp:248
std::map< K, V, Compare, Alloc > operator()(msgpack::object const &o) const
Definition: map.hpp:135
uint32_t checked_get_container_size(T size)
Definition: check_container_size.hpp:55
msgpack::object const & operator()(msgpack::object const &o, std::map< K, V, Compare, Alloc > &v) const
Definition: map.hpp:151
Definition: object_fwd.hpp:82
union_type via
Definition: object_fwd.hpp:123
std::enable_if< msgpack::has_as< T >::value, T >::type as() const
Get value as T.
Definition: object.hpp:558
msgpack::zone & zone
Definition: object_fwd.hpp:262
msgpack::object val
Definition: object_fwd.hpp:257
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const type::assoc_vector< K, V, Compare, Alloc > &v) const
Definition: map.hpp:92
Definition: adaptor_base.hpp:15
Definition: object_fwd.hpp:260
packer< Stream > & pack(const T &v)
Packing function template.
void operator()(msgpack::object::with_zone &o, const std::multimap< K, V, Compare, Alloc > &v) const
Definition: map.hpp:285
Definition: object_fwd.hpp:255
void operator()(msgpack::object::with_zone &o, const std::map< K, V, Compare, Alloc > &v) const
Definition: map.hpp:191
std::multimap< K, V, Compare, Alloc > operator()(msgpack::object const &o) const
Definition: map.hpp:228
Definition: adaptor_base.hpp:45
Definition: object_fwd.hpp:253
Definition: adaptor_base.hpp:34
packer< Stream > & pack_map(uint32_t n)
Packing map header and size.
Definition: pack.hpp:1181
msgpack::object_map map
Definition: object_fwd.hpp:116
void operator()(msgpack::object::with_zone &o, const type::assoc_vector< K, V, Compare, Alloc > &v) const
Definition: map.hpp:106
Object class that corresponding to MessagePack format object.
Definition: object_fwd.hpp:106
msgpack::type::object_type type
Definition: object_fwd.hpp:122
msgpack::object key
Definition: object_fwd.hpp:256
uint32_t size
Definition: object_fwd.hpp:55
Definition: object_fwd.hpp:40
The class template that supports continuous packing.
Definition: adaptor_base.hpp:22
T & move(T &t)
Definition: cpp_config.hpp:52
msgpack::object const & operator()(msgpack::object const &o, type::assoc_vector< K, V, Compare, Alloc > &v) const
Definition: map.hpp:72
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const std::map< K, V, Compare, Alloc > &v) const
Definition: map.hpp:177
Definition: adaptor_base.hpp:29
msgpack::object const & operator()(msgpack::object const &o, std::multimap< K, V, Compare, Alloc > &v) const
Definition: map.hpp:244