TagLib  1.13
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
31#include "taglib.h"
32
33namespace TagLib {
34
36
43 template <class Key, class T> class Map
44 {
45 public:
46#ifndef DO_NOT_DOCUMENT
47#ifdef WANT_CLASS_INSTANTIATION_OF_MAP
48 // Some STL implementations get snippy over the use of the
49 // class keyword to distinguish different templates; Sun Studio
50 // in particular finds multiple specializations in certain rare
51 // cases and complains about that. GCC doesn't seem to mind,
52 // and uses the typedefs further below without the class keyword.
53 // Not all the specializations of Map can use the class keyword
54 // (when T is not actually a class type), so don't apply this
55 // generally.
56 typedef typename std::map<class Key, class T>::iterator Iterator;
57 typedef typename std::map<class Key, class T>::const_iterator ConstIterator;
58#else
59 typedef typename std::map<Key, T>::iterator Iterator;
60 typedef typename std::map<Key, T>::const_iterator ConstIterator;
61#endif
62#endif
63
67 Map();
68
74 Map(const Map<Key, T> &m);
75
79 virtual ~Map();
80
85 Iterator begin();
86
91 ConstIterator begin() const;
92
97 Iterator end();
98
103 ConstIterator end() const;
104
109 Map<Key, T> &insert(const Key &key, const T &value);
110
116
122 unsigned int size() const;
123
129 bool isEmpty() const;
130
134 Iterator find(const Key &key);
135
139 ConstIterator find(const Key &key) const;
140
144 bool contains(const Key &key) const;
145
149 Map<Key, T> &erase(Iterator it);
150
154 Map<Key, T> &erase(const Key &key);
155
162 const T value(const Key &key, const T &defaultValue = T()) const;
163
169 const T &operator[](const Key &key) const;
170
176 T &operator[](const Key &key);
177
184
189
190 protected:
191 /*
192 * If this List is being shared via implicit sharing, do a deep copy of the
193 * data and separate from the shared members. This should be called by all
194 * non-const subclass members.
195 */
196 void detach();
197
198 private:
199#ifndef DO_NOT_DOCUMENT
200 template <class KeyP, class TP> class MapPrivate;
201 MapPrivate<Key, T> *d;
202#endif
203 };
204
205}
206
207// Since GCC doesn't support the "export" keyword, we have to include the
208// implementation.
209
210#include "tmap.tcc"
211
212#endif
A generic, implicitly shared map.
Definition: tmap.h:44
bool isEmpty() const
T & operator[](const Key &key)
const T & operator[](const Key &key) const
const T value(const Key &key, const T &defaultValue=T()) 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< Key, T > & clear()
virtual ~Map()
ConstIterator begin() const
void detach()
void swap(Map< Key, T > &m)
Iterator end()
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