tlist.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_LIST_H
27 #define TAGLIB_LIST_H
28 
29 #include "taglib.h"
30 
31 #include <list>
32 
33 namespace TagLib {
34 
36 
53  template <class T> class List
54  {
55  public:
56 #ifndef DO_NOT_DOCUMENT
57  typedef typename std::list<T>::iterator Iterator;
58  typedef typename std::list<T>::const_iterator ConstIterator;
59 #endif
60 
64  List();
65 
71  List(const List<T> &l);
72 
77  virtual ~List();
78 
83  Iterator begin();
84 
89  ConstIterator begin() const;
90 
95  Iterator end();
96 
101  ConstIterator end() const;
102 
106  Iterator insert(Iterator it, const T &value);
107 
113  List<T> &sortedInsert(const T &value, bool unique = false);
114 
119  List<T> &append(const T &item);
120 
125  List<T> &append(const List<T> &l);
126 
131  List<T> &prepend(const T &item);
132 
137  List<T> &prepend(const List<T> &l);
138 
145  List<T> &clear();
146 
150  uint size() const;
151  bool isEmpty() const;
152 
156  Iterator find(const T &value);
157 
161  ConstIterator find(const T &value) const;
162 
166  bool contains(const T &value) const;
167 
171  Iterator erase(Iterator it);
172 
176  const T &front() const;
177 
181  T &front();
182 
186  const T &back() const;
187 
191  T &back();
192 
201  void setAutoDelete(bool autoDelete);
202 
208  T &operator[](uint i);
209 
215  const T &operator[](uint i) const;
216 
222  List<T> &operator=(const List<T> &l);
223 
228  bool operator==(const List<T> &l) const;
229 
233  bool operator!=(const List<T> &l) const;
234 
235  protected:
236  /*
237  * If this List is being shared via implicit sharing, do a deep copy of the
238  * data and separate from the shared members. This should be called by all
239  * non-const subclass members.
240  */
241  void detach();
242 
243  private:
244 #ifndef DO_NOT_DOCUMENT
245  template <class TP> class ListPrivate;
246  ListPrivate<T> *d;
247 #endif
248  };
249 
250 }
251 
252 // Since GCC doesn't support the "export" keyword, we have to include the
253 // implementation.
254 
255 #include "tlist.tcc"
256 
257 #endif