proton/map.hpp

Go to the documentation of this file.
00001 #ifndef PROTON_MAP_HPP
00002 #define PROTON_MAP_HPP
00003 
00004 /*
00005  *
00006  * Licensed to the Apache Software Foundation (ASF) under one
00007  * or more contributor license agreements.  See the NOTICE file
00008  * distributed with this work for additional information
00009  * regarding copyright ownership.  The ASF licenses this file
00010  * to you under the Apache License, Version 2.0 (the
00011  * "License"); you may not use this file except in compliance
00012  * with the License.  You may obtain a copy of the License at
00013  *
00014  *   http://www.apache.org/licenses/LICENSE-2.0
00015  *
00016  * Unless required by applicable law or agreed to in writing,
00017  * software distributed under the License is distributed on an
00018  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
00019  * KIND, either express or implied.  See the License for the
00020  * specific language governing permissions and limitations
00021  * under the License.
00022  *
00023  */
00024 
00025 #include "./value.hpp"
00026 #include "./internal/pn_unique_ptr.hpp"
00027 
00028 #include <cstddef>
00029 
00032 
00033 namespace proton {
00034 
00035 namespace codec {
00036 class decoder;
00037 class encoder;
00038 }
00039 
00040 template <class K, class T>
00041 class map_type_impl;
00042 
00043 template <class K, class T>
00044 class map;
00045 
00047 template <class K, class T>
00048 PN_CPP_EXTERN proton::codec::decoder& operator>>(proton::codec::decoder& d, map<K,T>& m);
00050 template <class K, class T>
00051 PN_CPP_EXTERN proton::codec::encoder& operator<<(proton::codec::encoder& e, const map<K,T>& m);
00053 template <class K, class T>
00054 PN_CPP_EXTERN void swap(map<K,T>&, map<K,T>&);
00055 
00066 template <class K, class T>
00067 class PN_CPP_CLASS_EXTERN map {
00068     template <class M, class U=void>
00069         struct assignable_map :
00070             public internal::enable_if<codec::is_encodable_map<M,K,T>::value, U> {};
00071 
00072  public:
00074     PN_CPP_EXTERN map();
00075 
00077     PN_CPP_EXTERN map(const map&);
00078 
00080     PN_CPP_EXTERN map& operator=(const map&);
00081 
00082 #if PN_CPP_HAS_RVALUE_REFERENCES
00084     PN_CPP_EXTERN map(map&&);
00085 
00087     PN_CPP_EXTERN map& operator=(map&&);
00088 #endif
00089     PN_CPP_EXTERN ~map();
00090 
00093     template <class M>
00094     typename assignable_map<M, map&>::type operator=(const M& x) { value(x); return *this; }
00095 
00100     PN_CPP_EXTERN void value(const value& x);
00101 
00103     PN_CPP_EXTERN proton::value& value();
00104 
00106     PN_CPP_EXTERN const proton::value& value() const;
00107 
00110     PN_CPP_EXTERN T get(const K& k) const;
00111 
00113     PN_CPP_EXTERN void put(const K& k, const T& v);
00114 
00116     PN_CPP_EXTERN size_t erase(const K& k);
00117 
00119     PN_CPP_EXTERN bool exists(const K& k) const;
00120 
00122     PN_CPP_EXTERN size_t size() const;
00123 
00125     PN_CPP_EXTERN void clear();
00126 
00128     PN_CPP_EXTERN bool empty() const;
00129 
00131     explicit map(pn_data_t*);
00132     void reset(pn_data_t*);
00134 
00135   private:
00136     typedef map_type_impl<K,T> map_type;
00137     mutable internal::pn_unique_ptr<map_type> map_;
00138     mutable proton::value value_;
00139 
00140     map_type& cache() const;
00141     proton::value& flush() const;
00142 
00144   friend PN_CPP_EXTERN proton::codec::decoder& operator>> <>(proton::codec::decoder&, map&);
00145   friend PN_CPP_EXTERN proton::codec::encoder& operator<< <>(proton::codec::encoder&, const map&);
00146   friend PN_CPP_EXTERN void swap<>(map&, map&);
00148 };
00149 
00150 } // proton
00151 
00152 #endif // PROTON_MAP_HPP

Generated on 1 Jun 2020 for Qpid Proton C++ by  doxygen 1.6.1