10#ifndef MSGPACK_V1_TYPE_MAP_HPP
11#define MSGPACK_V1_TYPE_MAP_HPP
27template <
typename K,
typename V,
typename Compare,
typename Alloc>
29#if !defined(MSGPACK_USE_CPP03)
30 using std::vector<std::pair<K, V>, Alloc>::vector;
35 template <
typename K,
typename V,
typename Compare,
typename Alloc>
37 bool operator() (
const std::pair<K, V>& x,
const std::pair<K, V>& y)
const
38 {
return Compare()(x.first, y.first); }
46#if !defined(MSGPACK_USE_CPP03)
48template <
typename K,
typename V,
typename Compare,
typename Alloc>
50 type::assoc_vector<K, V, Compare, Alloc>,
51 typename std::enable_if<msgpack::has_as<K>::value || msgpack::has_as<V>::value>::type> {
58 for (; p < pend; ++p) {
59 v.emplace_back(p->
key.
as<K>(), p->
val.
as<V>());
68template <
typename K,
typename V,
typename Compare,
typename Alloc>
69struct convert<type::assoc_vector<K, V, Compare, Alloc> > {
76 std::pair<K, V>* it(&v.front());
77 for (; p < pend; ++p, ++it) {
87template <
typename K,
typename V,
typename Compare,
typename Alloc>
88struct pack<type::assoc_vector<K, V, Compare, Alloc> > {
89 template <
typename Stream>
102template <
typename K,
typename V,
typename Compare,
typename Alloc>
105 o.
type = msgpack::type::MAP;
127#if !defined(MSGPACK_USE_CPP03)
129template <
typename K,
typename V,
typename Compare,
typename Alloc>
131 std::map<K, V, Compare, Alloc>,
132 typename std::enable_if<msgpack::has_as<K>::value || msgpack::has_as<V>::value>::type> {
137 std::map<K, V, Compare, Alloc> v;
138 for (; p != pend; ++p) {
147template <
typename K,
typename V,
typename Compare,
typename Alloc>
148struct convert<std::map<K, V, Compare, Alloc> > {
153 std::map<K, V, Compare, Alloc> tmp;
154 for (; p != pend; ++p) {
157#if __cplusplus >= 201103L
163#if __cplusplus >= 201103L
172template <
typename K,
typename V,
typename Compare,
typename Alloc>
173struct pack<std::map<K, V, Compare, Alloc> > {
174 template <
typename Stream>
178 for (
typename std::map<K, V, Compare, Alloc>::const_iterator it(v.begin()), it_end(v.end());
179 it != it_end; ++it) {
187template <
typename K,
typename V,
typename Compare,
typename Alloc>
190 o.
type = msgpack::type::MAP;
202 typename std::map<K, V, Compare, Alloc>::const_iterator it(v.begin());
204#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
205#pragma GCC diagnostic push
206#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
210#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && !defined(__clang__)
211#pragma GCC diagnostic pop
220#if !defined(MSGPACK_USE_CPP03)
222template <
typename K,
typename V,
typename Compare,
typename Alloc>
224 std::multimap<K, V, Compare, Alloc>,
225 typename std::enable_if<msgpack::has_as<K>::value || msgpack::has_as<V>::value>::type> {
230 std::multimap<K, V, Compare, Alloc> v;
231 for (; p != pend; ++p) {
240template <
typename K,
typename V,
typename Compare,
typename Alloc>
241struct convert<std::multimap<K, V, Compare, Alloc> > {
246 std::multimap<K, V, Compare, Alloc> tmp;
247 for (; p != pend; ++p) {
248 std::pair<K, V> value;
251#if __cplusplus >= 201103L
252 tmp.insert(std::move(value));
257#if __cplusplus >= 201103L
266template <
typename K,
typename V,
typename Compare,
typename Alloc>
267struct pack<std::multimap<K, V, Compare, Alloc> > {
268 template <
typename Stream>
272 for (
typename std::multimap<K, V, Compare, Alloc>::const_iterator it(v.begin()), it_end(v.end());
273 it != it_end; ++it) {
281template <
typename K,
typename V,
typename Compare,
typename Alloc>
284 o.
type = msgpack::type::MAP;
295 typename std::multimap<K, V, Compare, Alloc>::const_iterator it(v.begin());
The class template that supports continuous packing.
Definition pack.hpp:33
packer< Stream > & pack_map(uint32_t n)
Packing map header and size.
Definition pack.hpp:1213
packer< Stream > & pack(const T &v)
Packing function template.
Definition object_fwd.hpp:236
void * allocate_align(size_t size, size_t align=MSGPACK_ZONE_ALIGN)
Definition cpp03_zone.hpp:246
Definition adaptor_base.hpp:15
uint32_t checked_get_container_size(T size)
Definition check_container_size.hpp:55
std::map< K, V, Compare, Alloc > operator()(msgpack::object const &o) const
Definition map.hpp:133
std::multimap< K, V, Compare, Alloc > operator()(msgpack::object const &o) const
Definition map.hpp:226
type::assoc_vector< K, V, Compare, Alloc > operator()(msgpack::object const &o) const
Definition map.hpp:52
Definition object_fwd_decl.hpp:62
msgpack::object const & operator()(msgpack::object const &o, std::map< K, V, Compare, Alloc > &v) const
Definition map.hpp:149
msgpack::object const & operator()(msgpack::object const &o, std::multimap< K, V, Compare, Alloc > &v) const
Definition map.hpp:242
msgpack::object const & operator()(msgpack::object const &o, type::assoc_vector< K, V, Compare, Alloc > &v) const
Definition map.hpp:70
Definition adaptor_base.hpp:27
void operator()(msgpack::object::with_zone &o, const std::map< K, V, Compare, Alloc > &v) const
Definition map.hpp:189
void operator()(msgpack::object::with_zone &o, const std::multimap< K, V, Compare, Alloc > &v) const
Definition map.hpp:283
void operator()(msgpack::object::with_zone &o, const type::assoc_vector< K, V, Compare, Alloc > &v) const
Definition map.hpp:104
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:175
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const std::multimap< K, V, Compare, Alloc > &v) const
Definition map.hpp:269
msgpack::packer< Stream > & operator()(msgpack::packer< Stream > &o, const type::assoc_vector< K, V, Compare, Alloc > &v) const
Definition map.hpp:90
Definition adaptor_base.hpp:32
msgpack::zone & zone
Definition object.hpp:37
msgpack::object val
Definition object.hpp:32
msgpack::object key
Definition object.hpp:31
uint32_t size
Definition object_fwd.hpp:28
msgpack::object_kv * ptr
Definition object_fwd.hpp:29
Object class that corresponding to MessagePack format object.
Definition object_fwd.hpp:75
msgpack::enable_if<!msgpack::is_array< T >::value &&!msgpack::is_pointer< T >::value, T & >::type convert(T &v) const
Convert the object.
Definition object.hpp:1071
std::enable_if< msgpack::has_as< T >::value, T >::type as() const
Get value as T.
Definition object.hpp:1121
union_type via
Definition object_fwd.hpp:93
msgpack::type::object_type type
Definition object_fwd.hpp:92
bool operator()(const std::pair< K, V > &x, const std::pair< K, V > &y) const
Definition map.hpp:37
msgpack::object_map map
Definition object_fwd.hpp:86
#define MSGPACK_NULLPTR
Definition cpp_config_decl.hpp:35
#define MSGPACK_ZONE_ALIGNOF(type)
Definition cpp03_zone_decl.hpp:30
#define MSGPACK_API_VERSION_NAMESPACE(ns)
Definition versioning.hpp:58