id3v2frame.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_ID3V2FRAME_H
27 #define TAGLIB_ID3V2FRAME_H
28 
29 #include "tstring.h"
30 #include "tbytevector.h"
31 #include "taglib_export.h"
32 
33 namespace TagLib {
34 
35  class StringList;
36  class PropertyMap;
37 
38  namespace ID3v2 {
39 
40  class Tag;
41  class FrameFactory;
42 
44 
55  {
56  friend class Tag;
57  friend class FrameFactory;
58 
59  public:
60 
66  static Frame *createTextualFrame(const String &key, const StringList &values);
67 
71  virtual ~Frame();
72 
78 
82  unsigned int size() const;
83 
92  static unsigned int headerSize(); // BIC: remove and make non-static
93 
99  static unsigned int headerSize(unsigned int version); // BIC: remove and make non-static
100 
107  void setData(const ByteVector &data);
108 
118  virtual void setText(const String &text);
119 
125  virtual String toString() const = 0;
126 
131 
137 
143  static const String instrumentPrefix;
148  static const String commentPrefix;
153  static const String lyricsPrefix;
158  static const String urlPrefix;
159 
160  protected:
161  class Header;
162 
170  explicit Frame(const ByteVector &data);
171 
179 
183  Header *header() const;
184 
192  void setHeader(Header *h, bool deleteCurrent = true);
193 
198  void parse(const ByteVector &data);
199 
205  virtual void parseFields(const ByteVector &data) = 0;
206 
211  virtual ByteVector renderFields() const = 0;
212 
218  ByteVector fieldData(const ByteVector &frameData) const;
219 
227  int *positon = 0);
228 
233  // BIC: remove and make non-static
234  static String::Type checkEncoding(const StringList &fields,
235  String::Type encoding);
236 
243  // BIC: remove and make non-static
244  static String::Type checkEncoding(const StringList &fields,
245  String::Type encoding, unsigned int version);
246 
254  String::Type encoding) const;
255 
256 
264 
269  static ByteVector keyToFrameID(const String &);
270 
275  static String frameIDToKey(const ByteVector &);
276 
280  static String keyToTXXX(const String &);
281 
285  static String txxxToKey(const String &);
286 
300  static void splitProperties(const PropertyMap &original, PropertyMap &singleFrameProperties,
301  PropertyMap &tiplProperties, PropertyMap &tmclProperties);
302 
303  private:
304  Frame(const Frame &);
305  Frame &operator=(const Frame &);
306 
307  class FramePrivate;
308  friend class FramePrivate;
309  FramePrivate *d;
310  };
311 
313 
326  class TAGLIB_EXPORT Frame::Header
327  {
328  public:
337  Header(const ByteVector &data, bool synchSafeInts);
338 
346  explicit Header(const ByteVector &data, unsigned int version = 4);
347 
351  virtual ~Header();
352 
359  void setData(const ByteVector &data, bool synchSafeInts);
360 
365  void setData(const ByteVector &data, unsigned int version = 4);
366 
372 
381  void setFrameID(const ByteVector &id);
382 
387  unsigned int frameSize() const;
388 
392  void setFrameSize(unsigned int size);
393 
398  unsigned int version() const;
399 
404  void setVersion(unsigned int version);
405 
414  static unsigned int size();
415 
422  static unsigned int size(unsigned int version);
423 
433  bool tagAlterPreservation() const;
434 
446  void setTagAlterPreservation(bool discard);
447 
453  bool fileAlterPreservation() const;
454 
460  bool readOnly() const;
461 
467  bool groupingIdentity() const;
468 
474  bool compression() const;
475 
481  bool encryption() const;
482 
483 #ifndef DO_NOT_DOCUMENT
484  bool unsycronisation() const;
485 #endif
486 
490  bool unsynchronisation() const;
491 
495  bool dataLengthIndicator() const;
496 
501 
506 
507  private:
508  Header(const Header &);
509  Header &operator=(const Header &);
510 
511  class HeaderPrivate;
512  HeaderPrivate *d;
513  };
514 
515  }
516 }
517 
518 #endif
A byte vector.
Definition: tbytevector.h:46
A factory for creating ID3v2 frames during parsing.
Definition: id3v2framefactory.h:66
ID3v2 frame implementation.
Definition: id3v2frame.h:55
bool encryption() const
void parse(const ByteVector &data)
bool dataLengthIndicator() const
Header(const ByteVector &data, bool synchSafeInts)
static const String lyricsPrefix
Definition: id3v2frame.h:153
bool unsynchronisation() const
static String::Type checkEncoding(const StringList &fields, String::Type encoding)
String::Type checkTextEncoding(const StringList &fields, String::Type encoding) const
void setData(const ByteVector &data, unsigned int version=4)
ByteVector fieldData(const ByteVector &frameData) const
static const String urlPrefix
Definition: id3v2frame.h:158
static String frameIDToKey(const ByteVector &)
bool groupingIdentity() const
Header(const ByteVector &data, unsigned int version=4)
unsigned int size() const
static unsigned int headerSize()
virtual void parseFields(const ByteVector &data)=0
ByteVector render() const
PropertyMap asProperties() const
Frame(const ByteVector &data)
bool fileAlterPreservation() const
void setHeader(Header *h, bool deleteCurrent=true)
bool tagAlterPreservation() const
virtual void setText(const String &text)
void setFrameSize(unsigned int size)
static String txxxToKey(const String &)
void setVersion(unsigned int version)
void setData(const ByteVector &data)
static unsigned int headerSize(unsigned int version)
static ByteVector keyToFrameID(const String &)
bool readOnly() const
Header * header() const
bool compression() const
static ByteVector textDelimiter(String::Type t)
static unsigned int size(unsigned int version)
static const String commentPrefix
Definition: id3v2frame.h:148
static String::Type checkEncoding(const StringList &fields, String::Type encoding, unsigned int version)
static const String instrumentPrefix
Definition: id3v2frame.h:143
void setFrameID(const ByteVector &id)
void setData(const ByteVector &data, bool synchSafeInts)
static String keyToTXXX(const String &)
unsigned int version() const
ByteVector frameID() const
virtual ByteVector renderFields() const =0
virtual String toString() const =0
unsigned int frameSize() const
static void splitProperties(const PropertyMap &original, PropertyMap &singleFrameProperties, PropertyMap &tiplProperties, PropertyMap &tmclProperties)
void setTagAlterPreservation(bool discard)
bool frameAlterPreservation() const
static Frame * createTextualFrame(const String &key, const StringList &values)
static unsigned int size()
String readStringField(const ByteVector &data, String::Type encoding, int *positon=0)
An implementation of ID3v2 headers.
Definition: id3v2header.h:48
The main class in the ID3v2 implementation.
Definition: id3v2tag.h:136
A map for format-independent <key,valuelist> tag representations.
Definition: tpropertymap.h:109
A list of strings.
Definition: tstringlist.h:46
A wide string class suitable for unicode.
Definition: tstring.h:85
Type
Definition: tstring.h:97
A namespace for all TagLib related classes and functions.
Definition: apefile.h:41
#define TAGLIB_EXPORT
Definition: taglib_export.h:40