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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
00019  *   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 using namespace std;
00031 
00032 #include "taglib.h"
00033 
00034 namespace TagLib {
00035 
00037 
00044   template <class Key, class T> class Map
00045   {
00046   public:
00047 #ifndef DO_NOT_DOCUMENT
00048 #ifdef WANT_CLASS_INSTANTIATION_OF_MAP
00049     // Some STL implementations get snippy over the use of the
00050     // class keyword to distinguish different templates; Sun Studio
00051     // in particular finds multiple specializations in certain rare
00052     // cases and complains about that. GCC doesn't seem to mind,
00053     // and uses the typedefs further below without the class keyword.
00054     // Not all the specializations of Map can use the class keyword
00055     // (when T is not actually a class type), so don't apply this
00056     // generally.
00057     typedef typename std::map<class Key, class T>::iterator Iterator;
00058     typedef typename std::map<class Key, class T>::const_iterator ConstIterator;
00059 #else
00060     typedef typename std::map<Key, T>::iterator Iterator;
00061     typedef typename std::map<Key, T>::const_iterator ConstIterator;
00062 #endif
00063 #endif
00064 
00068     Map();
00069 
00075     Map(const Map<Key, T> &m);
00076 
00080     virtual ~Map();
00081 
00086     Iterator begin();
00087 
00092     ConstIterator begin() const;
00093 
00098     Iterator end();
00099 
00104     ConstIterator end() const;
00105 
00110     Map<Key, T> &insert(const Key &key, const T &value);
00111 
00116     Map<Key, T> &clear();
00117 
00123     uint size() const;
00124 
00130     bool isEmpty() const;
00131 
00135     Iterator find(const Key &key);
00136 
00140     ConstIterator find(const Key &key) const;
00141 
00145     bool contains(const Key &key) const;
00146 
00150     Map<Key, T> &erase(Iterator it);
00151 
00155     Map<Key, T> &erase(const Key &key);
00156 
00162     const T &operator[](const Key &key) const;
00163 
00169     T &operator[](const Key &key);
00170 
00176     Map<Key, T> &operator=(const Map<Key, T> &m);
00177 
00178   protected:
00179     /*
00180      * If this List is being shared via implicit sharing, do a deep copy of the
00181      * data and separate from the shared members.  This should be called by all
00182      * non-const subclass members.
00183      */
00184     void detach();
00185 
00186   private:
00187 #ifndef DO_NOT_DOCUMENT
00188     template <class KeyP, class TP> class MapPrivate;
00189     MapPrivate<Key, T> *d;
00190 #endif
00191   };
00192 
00193 }
00194 
00195 // Since GCC doesn't support the "export" keyword, we have to include the
00196 // implementation.
00197 
00198 #include "tmap.tcc"
00199 
00200 #endif