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., 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_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 
00150     uint size() const;
00151     bool isEmpty() const;
00152 
00156     Iterator find(const T &value);
00157 
00161     ConstIterator find(const T &value) const;
00162 
00166     bool contains(const T &value) const;
00167 
00171     Iterator erase(Iterator it);
00172 
00176     const T &front() const;
00177 
00181     T &front();
00182 
00186     const T &back() const;
00187 
00191     T &back();
00192 
00201     void setAutoDelete(bool autoDelete);
00202 
00208     T &operator[](uint i);
00209 
00215     const T &operator[](uint i) const;
00216 
00222     List<T> &operator=(const List<T> &l);
00223 
00228     bool operator==(const List<T> &l) const;
00229 
00230   protected:
00231     /*
00232      * If this List is being shared via implicit sharing, do a deep copy of the
00233      * data and separate from the shared members.  This should be called by all
00234      * non-const subclass members.
00235      */
00236     void detach();
00237 
00238   private:
00239 #ifndef DO_NOT_DOCUMENT
00240     template <class TP> class ListPrivate;
00241     ListPrivate<T> *d;
00242 #endif
00243   };
00244 
00245 }
00246 
00247 // Since GCC doesn't support the "export" keyword, we have to include the
00248 // implementation.
00249 
00250 #include "tlist.tcc"
00251 
00252 #endif