TagLib API Documentation
tmap.h
Go to the documentation of this file.
1/***************************************************************************
2 copyright : (C) 2002 - 2008 by Scott Wheeler
3 email : wheeler@kde.org
4 ***************************************************************************/
5
6/***************************************************************************
7 * This library is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU Lesser General Public License version *
9 * 2.1 as published by the Free Software Foundation. *
10 * *
11 * This library is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * Lesser General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with this library; if not, write to the Free Software *
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA *
19 * 02110-1301 USA *
20 * *
21 * Alternatively, this file is available under the Mozilla Public *
22 * License Version 1.1. You may obtain a copy of the License at *
23 * http://www.mozilla.org/MPL/ *
24 ***************************************************************************/
25
26#ifndef TAGLIB_MAP_H
27#define TAGLIB_MAP_H
28
29#include <map>
30#include <memory>
31#include <initializer_list>
32#include <utility>
33
34namespace TagLib {
35
37
44 template <class Key, class T> class Map
45 {
46 public:
47#ifndef DO_NOT_DOCUMENT
48#ifdef WANT_CLASS_INSTANTIATION_OF_MAP
49 // Some STL implementations get snippy over the use of the
50 // class keyword to distinguish different templates; Sun Studio
51 // in particular finds multiple specializations in certain rare
52 // cases and complains about that. GCC doesn't seem to mind,
53 // and uses the typedefs further below without the class keyword.
54 // Not all the specializations of Map can use the class keyword
55 // (when T is not actually a class type), so don't apply this
56 // generally.
57 using Iterator = typename std::map<class Key, class T>::iterator;
58 using ConstIterator = typename std::map<class Key, class T>::const_iterator;
59#else
60 using Iterator = typename std::map<Key, T>::iterator;
61 using ConstIterator = typename std::map<Key, T>::const_iterator;
62#endif
63#endif
64
68 Map();
69
75 Map(const Map<Key, T> &m);
76
80 Map(std::initializer_list<std::pair<const Key, T>> init);
81
86
91 Iterator begin();
92
97 ConstIterator begin() const;
98
103 ConstIterator cbegin() const;
104
109 Iterator end();
110
115 ConstIterator end() const;
116
121 ConstIterator cend() const;
122
127 Map<Key, T> &insert(const Key &key, const T &value);
128
134
140 unsigned int size() const;
141
147 bool isEmpty() const;
148
152 Iterator find(const Key &key);
153
157 ConstIterator find(const Key &key) const;
158
162 bool contains(const Key &key) const;
163
171 Map<Key, T> &erase(Iterator it);
172
176 Map<Key, T> &erase(const Key &key);
177
184 T value(const Key &key, const T &defaultValue = T()) const;
185
191 const T &operator[](const Key &key) const;
192
198 T &operator[](const Key &key);
199
206
210 Map<Key, T> &operator=(std::initializer_list<std::pair<const Key, T>> init);
211
215 void swap(Map<Key, T> &m) noexcept;
216
221 bool operator==(const Map<Key, T> &m) const;
222
226 bool operator!=(const Map<Key, T> &m) const;
227
228 protected:
234 void detach();
235
236 private:
237#ifndef DO_NOT_DOCUMENT
238 template <class KeyP, class TP> class MapPrivate;
239 std::shared_ptr<MapPrivate<Key, T>> d;
240#endif
241 };
242
243} // namespace TagLib
244
245// Since GCC doesn't support the "export" keyword, we have to include the
246// implementation.
247
248#include "tmap.tcc"
249
250#endif
A generic, implicitly shared map.
Definition: tmap.h:45
bool isEmpty() const
T value(const Key &key, const T &defaultValue=T()) const
T & operator[](const Key &key)
const T & operator[](const Key &key) const
ConstIterator cend() const
void swap(Map< Key, T > &m) noexcept
bool operator==(const Map< Key, T > &m) const
bool operator!=(const Map< Key, T > &m) const
Map< Key, T > & erase(const Key &key)
Iterator begin()
Map< Key, T > & insert(const Key &key, const T &value)
Iterator find(const Key &key)
ConstIterator find(const Key &key) const
unsigned int size() const
bool contains(const Key &key) const
ConstIterator end() const
Map< Key, T > & operator=(const Map< Key, T > &m)
Map(std::initializer_list< std::pair< const Key, T > > init)
Map< Key, T > & clear()
ConstIterator begin() const
Map< Key, T > & operator=(std::initializer_list< std::pair< const Key, T > > init)
void detach()
Iterator end()
ConstIterator cbegin() const
Map(const Map< Key, T > &m)
Map< Key, T > & erase(Iterator it)
A namespace for all TagLib related classes and functions.
Definition: apefile.h:41