Qpid Proton C++  0.17.0
cached_map.hpp
1 #ifndef PROTON_CPP_CACHED_MAP_H
2 #define PROTON_CPP_CACHED_MAP_H
3 
4 /*
5  *
6  * Licensed to the Apache Software Foundation (ASF) under one
7  * or more contributor license agreements. See the NOTICE file
8  * distributed with this work for additional information
9  * regarding copyright ownership. The ASF licenses this file
10  * to you under the Apache License, Version 2.0 (the
11  * "License"); you may not use this file except in compliance
12  * with the License. You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing,
17  * software distributed under the License is distributed on an
18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19  * KIND, either express or implied. See the License for the
20  * specific language governing permissions and limitations
21  * under the License.
22  *
23  */
24 
25 #include "./config.hpp"
26 #include "./export.hpp"
27 #include "./pn_unique_ptr.hpp"
28 
29 #include <cstddef>
30 
31 namespace proton {
32 
33 namespace codec {
34 class decoder;
35 class encoder;
36 }
37 
38 namespace internal {
39 
40 template <class key_type, class value_type>
41 class map_type_impl;
42 
46 template <class K, class V>
47 class cached_map;
48 
49 template <class K, class V>
50 PN_CPP_EXTERN proton::codec::decoder& operator>>(proton::codec::decoder& d, cached_map<K,V>& m);
51 template <class K, class V>
52 PN_CPP_EXTERN proton::codec::encoder& operator<<(proton::codec::encoder& e, const cached_map<K,V>& m);
53 
54 template <class key_type, class value_type>
55 class PN_CPP_CLASS_EXTERN cached_map {
56  typedef map_type_impl<key_type, value_type> map_type;
57 
58  public:
59  PN_CPP_EXTERN cached_map();
60  PN_CPP_EXTERN cached_map(const cached_map& cm);
61  PN_CPP_EXTERN cached_map& operator=(const cached_map& cm);
62 #if PN_CPP_HAS_RVALUE_REFERENCES
63  PN_CPP_EXTERN cached_map(cached_map&&);
64  PN_CPP_EXTERN cached_map& operator=(cached_map&&);
65 #endif
66  PN_CPP_EXTERN ~cached_map();
67 
68  PN_CPP_EXTERN value_type get(const key_type& k) const;
69  PN_CPP_EXTERN void put(const key_type& k, const value_type& v);
70  PN_CPP_EXTERN size_t erase(const key_type& k);
71  PN_CPP_EXTERN bool exists(const key_type& k) const;
72  PN_CPP_EXTERN size_t size();
73  PN_CPP_EXTERN void clear();
74  PN_CPP_EXTERN bool empty();
75 
77  private:
78  pn_unique_ptr<map_type> map_;
79 
80  void make_cached_map();
81 
82  friend PN_CPP_EXTERN proton::codec::decoder& operator>> <>(proton::codec::decoder& d, cached_map<key_type, value_type>& m);
83  friend PN_CPP_EXTERN proton::codec::encoder& operator<< <>(proton::codec::encoder& e, const cached_map<key_type, value_type>& m);
85 };
86 
87 
88 }
89 }
90 
91 #endif // PROTON_CPP_CACHED_MAP_H
Experimental - Stream-like encoder from C++ values to AMQP bytes.
Definition: encoder.hpp:47
internal::enable_if< internal::is_unknown_integer< T >::value, decoder & >::type operator>>(decoder &d, T &i)
operator>> for integer types that are not covered by the standard overrides.
Definition: decoder.hpp:203
The main Proton namespace.
Definition: annotation_key.hpp:30
Experimental - Stream-like decoder from AMQP bytes to C++ values.
Definition: decoder.hpp:53