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>
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)
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> {
60 for (; p < pend; ++p) {
61 v.emplace_back(p->
key.
as<K>(), p->
val.
as<V>());
70template <
typename K,
typename V,
typename Compare,
typename Alloc>
71struct convert<type::assoc_vector<K, V, Compare, Alloc> > {
78 std::pair<K, V>* it(&v.front());
79 for (; p < pend; ++p, ++it) {
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>
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;
140 for (; p != pend; ++p) {
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;
156 for (; p != pend; ++p) {
159#if MSGPACK_CPP_VERSION >= 201103L
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());
181 it != it_end; ++it) {
189template <
typename K,
typename V,
typename Compare,
typename Alloc>
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;
233 for (; p != pend; ++p) {
242template <
typename K,
typename V,
typename Compare,
typename Alloc>
243struct 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 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>
269struct 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) {
283template <
typename K,
typename V,
typename Compare,
typename Alloc>
297 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:1235
packer< Stream > & pack(const T &v)
Packing function template.
Definition: object_fwd.hpp:231
void * allocate_align(size_t size, size_t align=MSGPACK_ZONE_ALIGN)
Definition: cpp03_zone.hpp:255
std::size_t size(T const &t)
Definition: size_equal_only.hpp:24
@ MAP
Definition: object_fwd_decl.hpp:41
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: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
Definition: object.hpp:35
msgpack::zone & zone
Definition: object.hpp:37
Definition: object.hpp:30
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:1076
std::enable_if< msgpack::has_as< T >::value, T >::type as() const
Get value as T.
Definition: object.hpp:1126
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:39
msgpack::object_map map
Definition: object_fwd.hpp:86
#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