id3v2tag.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_ID3V2TAG_H
27 #define TAGLIB_ID3V2TAG_H
28 
29 #include "tag.h"
30 #include "tbytevector.h"
31 #include "tstring.h"
32 #include "tlist.h"
33 #include "tmap.h"
34 #include "taglib_export.h"
35 
36 #include "id3v2framefactory.h"
37 
38 namespace TagLib {
39 
40  class File;
41 
43 
51  namespace ID3v2 {
52 
53  class Header;
54  class ExtendedHeader;
55  class Footer;
56 
57  typedef List<Frame *> FrameList;
59 
61 
78  {
79  public:
81  virtual ~Latin1StringHandler();
82 
87  virtual String parse(const ByteVector &data) const;
88  };
89 
91 
136  {
137  public:
143  Tag();
144 
157  Tag(File *file, long tagOffset,
158  const FrameFactory *factory = FrameFactory::instance());
159 
163  virtual ~Tag();
164 
165  // Reimplementations.
166 
167  virtual String title() const;
168  virtual String artist() const;
169  virtual String album() const;
170  virtual String comment() const;
171  virtual String genre() const;
172  virtual uint year() const;
173  virtual uint track() const;
174 
175  virtual void setTitle(const String &s);
176  virtual void setArtist(const String &s);
177  virtual void setAlbum(const String &s);
178  virtual void setComment(const String &s);
179  virtual void setGenre(const String &s);
180  virtual void setYear(uint i);
181  virtual void setTrack(uint i);
182 
183  virtual bool isEmpty() const;
184 
188  Header *header() const;
189 
194  ExtendedHeader *extendedHeader() const;
195 
204  Footer *footer() const;
205 
240  const FrameListMap &frameListMap() const;
241 
252  const FrameList &frameList() const;
253 
265  const FrameList &frameList(const ByteVector &frameID) const;
266 
274  void addFrame(Frame *frame);
275 
283  void removeFrame(Frame *frame, bool del = true);
284 
291  void removeFrames(const ByteVector &id);
292 
322  PropertyMap properties() const;
323 
335  void removeUnsupportedProperties(const StringList &properties);
336 
341  PropertyMap setProperties(const PropertyMap &);
342 
346  ByteVector render() const;
347 
354  // BIC: combine with the above method
355  ByteVector render(int version) const;
356 
363  static Latin1StringHandler const *latin1StringHandler();
364 
376  static void setLatin1StringHandler(const Latin1StringHandler *handler);
377 
378  protected:
385  void read();
386 
391  void parse(const ByteVector &data);
392 
397  void setTextFrame(const ByteVector &id, const String &value);
398 
399  void downgradeFrames(FrameList *existingFrames, FrameList *newFrames) const;
400 
401  private:
402  Tag(const Tag &);
403  Tag &operator=(const Tag &);
404 
405  class TagPrivate;
406  TagPrivate *d;
407  };
408 
409  }
410 }
411 
412 #endif