Loading...
Searching...
No Matches
map.hpp
Go to the documentation of this file.
#ifndef PROTON_MAP_HPP
#define PROTON_MAP_HPP
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*
*/
#include "./value.hpp"
#include <cstddef>
#include <initializer_list>
#include <map>
#include <memory>
namespace proton {
namespace codec {
class decoder;
class encoder;
}
template <class K, class T>
class map_type_impl;
template <class K, class T>
class map;
template <class K, class T>
PN_CPP_EXTERN proton::codec::decoder& operator>>(proton::codec::decoder& d, map<K,T>& m);
template <class K, class T>
PN_CPP_EXTERN proton::codec::encoder& operator<<(proton::codec::encoder& e, const map<K,T>& m);
template <class K, class T>
PN_CPP_EXTERN void swap(map<K,T>&, map<K,T>&);
template <class K, class T>
class PN_CPP_CLASS_EXTERN map {
template <class M, class U=void>
struct assignable_map :
public std::enable_if<codec::is_encodable_map<M,K,T>::value, U> {};
public:
PN_CPP_EXTERN map();
PN_CPP_EXTERN map(const map&);
PN_CPP_EXTERN map& operator=(const map&);
PN_CPP_EXTERN map(const std::map<K, T>&);
PN_CPP_EXTERN map& operator=(const std::map<K, T>&);
PN_CPP_EXTERN map(const std::initializer_list<std::pair<const K, T>>&);
PN_CPP_EXTERN map(map&&);
PN_CPP_EXTERN map& operator=(map&&);
PN_CPP_EXTERN ~map();
template <class M>
typename assignable_map<M, map&>::type operator=(const M& x) { value(x); return *this; }
PN_CPP_EXTERN void value(const value& x);
PN_CPP_EXTERN proton::value& value();
PN_CPP_EXTERN const proton::value& value() const;
PN_CPP_EXTERN T get(const K& k) const;
PN_CPP_EXTERN void put(const K& k, const T& v);
PN_CPP_EXTERN size_t erase(const K& k);
PN_CPP_EXTERN bool exists(const K& k) const;
PN_CPP_EXTERN size_t size() const;
PN_CPP_EXTERN void clear();
PN_CPP_EXTERN bool empty() const;
explicit map(pn_data_t*);
void reset(pn_data_t*);
private:
typedef map_type_impl<K,T> map_type;
mutable std::unique_ptr<map_type> map_;
mutable proton::value value_;
map_type& cache() const;
proton::value& flush() const;
friend PN_CPP_EXTERN proton::codec::decoder& operator>> <>(proton::codec::decoder&, map&);
friend PN_CPP_EXTERN proton::codec::encoder& operator<< <>(proton::codec::encoder&, const map&);
friend PN_CPP_EXTERN void swap<>(map&, map&);
};
} // proton
#endif // PROTON_MAP_HPP
proton::codec::decoder
Unsettled API - A stream-like decoder from AMQP bytes to C++ values.
Definition decoder.hpp:56
proton::codec::encoder
Unsettled API - A stream-like encoder from C++ values to AMQP bytes.
Definition encoder.hpp:50
proton::map
A collection of key-value pairs.
Definition map.hpp:69
proton::map::size
size_t size() const
Get the number of map entries.
proton::map::value
const proton::value & value() const
Access as a proton::value containing an AMQP map.
proton::map::value
proton::value & value()
Access as a proton::value containing an AMQP map.
proton::map::operator=
assignable_map< M, map & >::type operator=(const M &x)
Type-safe assign from a compatible map, for instance std::map<K,T>.
Definition map.hpp:103
proton::map::operator=
map & operator=(map &&)
Move a map.
proton::map::empty
bool empty() const
True if the map has no entries.
proton::map::map
map()
Construct an empty map.
proton::map::map
map(const std::initializer_list< std::pair< const K, T > > &)
Initializer_list constructor.
proton::map::map
map(map &&)
Move a map.
proton::map::erase
size_t erase(const K &k)
Erase the map entry at k.
proton::map::get
T get(const K &k) const
Get the map entry for key k.
proton::map::map
map(const std::map< K, T > &)
Copy a std::map.
proton::map::operator=
map & operator=(const std::map< K, T > &)
Copy a std::map.
proton::map::map
map(const map &)
Copy a map.
proton::map::operator=
map & operator=(const map &)
Copy a map.
proton::map::put
void put(const K &k, const T &v)
Put a map entry for key k.
proton::map::clear
void clear()
Remove all map entries.
proton::map< std::string, scalar >::value
void value(const value &x)
proton::map::exists
bool exists(const K &k) const
True if the map has an entry for k.
proton::value
A holder for any AMQP value, simple or complex.
Definition value.hpp:57
proton::codec
Unsettled API - AMQP data encoding and decoding.
Definition common.hpp:31
proton
The main Proton namespace.
Definition annotation_key.hpp:33
proton::operator>>
proton::codec::decoder & operator>>(proton::codec::decoder &d, map< K, T > &m)
Decode from a proton::map.
proton::operator<<
std::ostream & operator<<(std::ostream &, const binary &)
Print a binary value.
proton::swap
void swap(map< K, T > &, map< K, T > &)
Swap proton::map instances.
value.hpp
A holder for any AMQP value, simple or complex.