10#ifndef MSGPACK_V1_TYPE_MAP_HPP
11#define MSGPACK_V1_TYPE_MAP_HPP
29template <
typename K,
typename V,
typename Compare,
typename Alloc>
31#if !defined(MSGPACK_USE_CPP03)
32 using std::vector<std::pair<K, V>,
Alloc>::vector;
37 template <
typename K,
typename V,
typename Compare,
typename Alloc>
38 struct pair_first_less {
39 bool operator() (
const std::pair<K, V>&
x,
const std::pair<K, V>&
y)
const
48#if !defined(MSGPACK_USE_CPP03)
50template <
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> {
57 v.reserve(
o.via.map.size);
61 v.emplace_back(
p->key.as<
K>(),
p->val.as<
V>());
63 std::sort(
v.begin(),
v.end(), type::detail::pair_first_less<K, V, Compare, Alloc>());
70template <
typename K,
typename V,
typename Compare,
typename Alloc>
71struct convert<type::assoc_vector<K, V, Compare, Alloc> > {
74 v.resize(
o.via.map.size);
75 if (
o.via.map.size != 0) {
78 std::pair<K, V>*
it(&
v.front());
80 p->key.convert(
it->first);
81 p->val.convert(
it->second);
83 std::sort(
v.begin(),
v.end(), type::detail::pair_first_less<K, V, Compare, Alloc>());
89template <
typename K,
typename V,
typename Compare,
typename Alloc>
90struct pack<type::assoc_vector<K, V, Compare, Alloc> > {
91 template <
typename Stream>
104template <
typename K,
typename V,
typename Compare,
typename Alloc>
107 o.type = msgpack::type::MAP;
117 o.via.map.size = size;
129#if !defined(MSGPACK_USE_CPP03)
131template <
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;
141 v.emplace(
p->key.as<
K>(),
p->val.as<
V>());
149template <
typename K,
typename V,
typename Compare,
typename Alloc>
150struct convert<std::map<K, V, Compare, Alloc> > {
155 std::map<K, V, Compare, Alloc>
tmp;
159#if MSGPACK_CPP_VERSION >= 201103L
160 p->val.convert(
tmp[std::move(key)]);
162 p->val.convert(
tmp[key]);
165#if MSGPACK_CPP_VERSION >= 201103L
174template <
typename K,
typename V,
typename Compare,
typename Alloc>
175struct 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());
189template <
typename K,
typename V,
typename Compare,
typename Alloc>
192 o.type = msgpack::type::MAP;
203 o.via.map.size = size;
204 typename std::map<K, V, Compare, Alloc>::const_iterator
it(
v.begin());
206#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
207#pragma GCC diagnostic push
208#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
212#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
213#pragma GCC diagnostic pop
222#if !defined(MSGPACK_USE_CPP03)
224template <
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;
234 v.emplace(
p->key.as<
K>(),
p->val.as<
V>());
242template <
typename K,
typename V,
typename Compare,
typename Alloc>
248 std::multimap<K, V, Compare, Alloc>
tmp;
250 std::pair<K, V> value;
251 p->key.convert(value.first);
252 p->val.convert(value.second);
253#if MSGPACK_CPP_VERSION >= 201103L
254 tmp.insert(std::move(value));
259#if MSGPACK_CPP_VERSION >= 201103L
268template <
typename K,
typename V,
typename Compare,
typename Alloc>
270 template <
typename Stream>
274 for (
typename std::multimap<K, V, Compare, Alloc>::const_iterator
it(
v.begin()),
it_end(
v.end());
283template <
typename K,
typename V,
typename Compare,
typename Alloc>
286 o.type = msgpack::type::MAP;
296 o.via.map.size = size;
297 typename std::multimap<K, V, Compare, Alloc>::const_iterator
it(
v.begin());
The class template that supports continuous packing.
Definition pack.hpp:33
Definition object_fwd.hpp:231
Definition adaptor_base.hpp:15
uint32_t checked_get_container_size(T size)
Definition check_container_size.hpp:55
void convert(T &v, msgpack::object const &o)
Definition object.hpp:1178
std::map< K, V, Compare, Alloc > operator()(msgpack::object const &o) const
Definition map.hpp:135
std::multimap< K, V, Compare, Alloc > operator()(msgpack::object const &o) const
Definition map.hpp:228
type::assoc_vector< K, V, Compare, Alloc > operator()(msgpack::object const &o) const
Definition map.hpp:54
Definition object_fwd_decl.hpp:61
msgpack::object const & operator()(msgpack::object const &o, std::map< K, V, Compare, Alloc > &v) const
Definition map.hpp:151
msgpack::object const & operator()(msgpack::object const &o, std::multimap< K, V, Compare, Alloc > &v) const
Definition map.hpp:244
msgpack::object const & operator()(msgpack::object const &o, type::assoc_vector< K, V, Compare, Alloc > &v) const
Definition map.hpp:72
Definition adaptor_base.hpp:27
void operator()(msgpack::object::with_zone &o, const std::map< K, V, Compare, Alloc > &v) const
Definition map.hpp:191
void operator()(msgpack::object::with_zone &o, const std::multimap< K, V, Compare, Alloc > &v) const
Definition map.hpp:285
void operator()(msgpack::object::with_zone &o, const type::assoc_vector< K, V, Compare, Alloc > &v) const
Definition map.hpp:106
Definition adaptor_base.hpp:43
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const std::map< K, V, Compare, Alloc > &v) const
Definition map.hpp:177
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const std::multimap< K, V, Compare, Alloc > &v) const
Definition map.hpp:271
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:32
Object class that corresponding to MessagePack format object.
Definition object_fwd.hpp:75
#define MSGPACK_NULLPTR
Definition cpp_config_decl.hpp:85
#define MSGPACK_ZONE_ALIGNOF(type)
Definition cpp03_zone_decl.hpp:30
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition versioning.hpp:66