tmap.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     copyright            : (C) 2002 - 2008 by Scott Wheeler
00003     email                : wheeler@kde.org
00004  ***************************************************************************/
00005 
00006 /***************************************************************************
00007  *   This library is free software; you can redistribute it and/or modify  *
00008  *   it under the terms of the GNU Lesser General Public License version   *
00009  *   2.1 as published by the Free Software Foundation.                     *
00010  *                                                                         *
00011  *   This library is distributed in the hope that it will be useful, but   *
00012  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00014  *   Lesser General Public License for more details.                       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with this library; if not, write to the Free Software   *
00018  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA         *
00019  *   02110-1301  USA                                                       *
00020  *                                                                         *
00021  *   Alternatively, this file is available under the Mozilla Public        *
00022  *   License Version 1.1.  You may obtain a copy of the License at         *
00023  *   http://www.mozilla.org/MPL/                                           *
00024  ***************************************************************************/
00025 
00026 #ifndef TAGLIB_MAP_H
00027 #define TAGLIB_MAP_H
00028 
00029 #include <map>
00030 
00031 #include "taglib.h"
00032 
00033 namespace TagLib {
00034 
00036 
00043   template <class Key, class T> class Map
00044   {
00045   public:
00046 #ifndef DO_NOT_DOCUMENT
00047 #ifdef WANT_CLASS_INSTANTIATION_OF_MAP
00048     // Some STL implementations get snippy over the use of the
00049     // class keyword to distinguish different templates; Sun Studio
00050     // in particular finds multiple specializations in certain rare
00051     // cases and complains about that. GCC doesn't seem to mind,
00052     // and uses the typedefs further below without the class keyword.
00053     // Not all the specializations of Map can use the class keyword
00054     // (when T is not actually a class type), so don't apply this
00055     // generally.
00056     typedef typename std::map<class Key, class T>::iterator Iterator;
00057     typedef typename std::map<class Key, class T>::const_iterator ConstIterator;
00058 #else
00059     typedef typename std::map<Key, T>::iterator Iterator;
00060     typedef typename std::map<Key, T>::const_iterator ConstIterator;
00061 #endif
00062 #endif
00063 
00067     Map();
00068 
00074     Map(const Map<Key, T> &m);
00075 
00079     virtual ~Map();
00080 
00085     Iterator begin();
00086 
00091     ConstIterator begin() const;
00092 
00097     Iterator end();
00098 
00103     ConstIterator end() const;
00104 
00109     Map<Key, T> &insert(const Key &key, const T &value);
00110 
00115     Map<Key, T> &clear();
00116 
00122     uint size() const;
00123 
00129     bool isEmpty() const;
00130 
00134     Iterator find(const Key &key);
00135 
00139     ConstIterator find(const Key &key) const;
00140 
00144     bool contains(const Key &key) const;
00145 
00149     Map<Key, T> &erase(Iterator it);
00150 
00154     Map<Key, T> &erase(const Key &key);
00155 
00161     const T &operator[](const Key &key) const;
00162 
00168     T &operator[](const Key &key);
00169 
00175     Map<Key, T> &operator=(const Map<Key, T> &m);
00176 
00177   protected:
00178     /*
00179      * If this List is being shared via implicit sharing, do a deep copy of the
00180      * data and separate from the shared members.  This should be called by all
00181      * non-const subclass members.
00182      */
00183     void detach();
00184 
00185   private:
00186 #ifndef DO_NOT_DOCUMENT
00187     template <class KeyP, class TP> class MapPrivate;
00188     MapPrivate<Key, T> *d;
00189 #endif
00190   };
00191 
00192 }
00193 
00194 // Since GCC doesn't support the "export" keyword, we have to include the
00195 // implementation.
00196 
00197 #include "tmap.tcc"
00198 
00199 #endif