tlist.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_LIST_H
00027 #define TAGLIB_LIST_H
00028 
00029 #include "taglib.h"
00030 
00031 #include <list>
00032 
00033 namespace TagLib {
00034 
00036 
00053   template <class T> class List
00054   {
00055   public:
00056 #ifndef DO_NOT_DOCUMENT
00057     typedef typename std::list<T>::iterator Iterator;
00058     typedef typename std::list<T>::const_iterator ConstIterator;
00059 #endif
00060 
00064     List();
00065 
00071     List(const List<T> &l);
00072 
00077     virtual ~List();
00078 
00083     Iterator begin();
00084 
00089     ConstIterator begin() const;
00090 
00095     Iterator end();
00096 
00101     ConstIterator end() const;
00102 
00106     Iterator insert(Iterator it, const T &value);
00107 
00113     List<T> &sortedInsert(const T &value, bool unique = false);
00114 
00119     List<T> &append(const T &item);
00120 
00125     List<T> &append(const List<T> &l);
00126 
00131     List<T> &prepend(const T &item);
00132 
00137     List<T> &prepend(const List<T> &l);
00138 
00145     List<T> &clear();
00146 
00152     unsigned int size() const;
00153 
00159     bool isEmpty() const;
00160 
00164     Iterator find(const T &value);
00165 
00169     ConstIterator find(const T &value) const;
00170 
00174     bool contains(const T &value) const;
00175 
00179     Iterator erase(Iterator it);
00180 
00184     const T &front() const;
00185 
00189     T &front();
00190 
00194     const T &back() const;
00195 
00199     T &back();
00200 
00209     void setAutoDelete(bool autoDelete);
00210 
00216     T &operator[](unsigned int i);
00217 
00223     const T &operator[](unsigned int i) const;
00224 
00230     List<T> &operator=(const List<T> &l);
00231 
00236     bool operator==(const List<T> &l) const;
00237 
00241     bool operator!=(const List<T> &l) const;
00242 
00243   protected:
00244     /*
00245      * If this List is being shared via implicit sharing, do a deep copy of the
00246      * data and separate from the shared members.  This should be called by all
00247      * non-const subclass members.
00248      */
00249     void detach();
00250 
00251   private:
00252 #ifndef DO_NOT_DOCUMENT
00253     template <class TP> class ListPrivate;
00254     ListPrivate<T> *d;
00255 #endif
00256   };
00257 
00258 }
00259 
00260 // Since GCC doesn't support the "export" keyword, we have to include the
00261 // implementation.
00262 
00263 #include "tlist.tcc"
00264 
00265 #endif