TagLib  1.13.1
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  friend class TableOfContentsFrame;
59  friend class ChapterFrame;
60 
61  public:
62 
68  static Frame *createTextualFrame(const String &key, const StringList &values);
69 
73  virtual ~Frame();
74 
79  ByteVector frameID() const;
80 
84  unsigned int size() const;
85 
94  static unsigned int headerSize(); // BIC: make non-static
95 
101  // BIC: remove
102  static unsigned int headerSize(unsigned int version);
103 
110  void setData(const ByteVector &data);
111 
121  virtual void setText(const String &text);
122 
128  virtual String toString() const = 0;
129 
133  ByteVector render() const;
134 
139  static ByteVector textDelimiter(String::Type t);
140 
146  static const String instrumentPrefix;
151  static const String commentPrefix;
156  static const String lyricsPrefix;
161  static const String urlPrefix;
162 
163  protected:
164  class Header;
165 
173  explicit Frame(const ByteVector &data);
174 
181  Frame(Header *h);
182 
186  Header *header() const;
187 
195  void setHeader(Header *h, bool deleteCurrent = true);
196 
201  void parse(const ByteVector &data);
202 
208  virtual void parseFields(const ByteVector &data) = 0;
209 
214  virtual ByteVector renderFields() const = 0;
215 
221  ByteVector fieldData(const ByteVector &frameData) const;
222 
229  String readStringField(const ByteVector &data, String::Type encoding,
230  int *position = 0);
231 
236  // BIC: remove and make non-static
237  static String::Type checkEncoding(const StringList &fields,
238  String::Type encoding);
239 
246  // BIC: remove and make non-static
247  static String::Type checkEncoding(const StringList &fields,
248  String::Type encoding, unsigned int version);
249 
256  String::Type checkTextEncoding(const StringList &fields,
257  String::Type encoding) const;
258 
259 
266  PropertyMap asProperties() const;
267 
272  static ByteVector keyToFrameID(const String &);
273 
278  static String frameIDToKey(const ByteVector &);
279 
283  static String keyToTXXX(const String &);
284 
288  static String txxxToKey(const String &);
289 
303  static void splitProperties(const PropertyMap &original, PropertyMap &singleFrameProperties,
304  PropertyMap &tiplProperties, PropertyMap &tmclProperties);
305 
306  private:
307  Frame(const Frame &);
308  Frame &operator=(const Frame &);
309 
310  class FramePrivate;
311  friend class FramePrivate;
312  FramePrivate *d;
313  };
314 
316 
329  class TAGLIB_EXPORT Frame::Header
330  {
331  public:
340  TAGLIB_DEPRECATED Header(const ByteVector &data, bool synchSafeInts);
341 
349  explicit Header(const ByteVector &data, unsigned int version = 4);
350 
354  virtual ~Header();
355 
362  TAGLIB_DEPRECATED void setData(const ByteVector &data, bool synchSafeInts);
363 
368  void setData(const ByteVector &data, unsigned int version = 4);
369 
374  ByteVector frameID() const;
375 
384  void setFrameID(const ByteVector &id);
385 
390  unsigned int frameSize() const;
391 
395  void setFrameSize(unsigned int size);
396 
401  unsigned int version() const;
402 
407  void setVersion(unsigned int version);
408 
417  // BIC: make non-static
418  static unsigned int size();
419 
426  // BIC: remove
427  static unsigned int size(unsigned int version);
428 
438  bool tagAlterPreservation() const;
439 
451  void setTagAlterPreservation(bool discard);
452 
458  bool fileAlterPreservation() const;
459 
465  bool readOnly() const;
466 
472  bool groupingIdentity() const;
473 
479  bool compression() const;
480 
486  bool encryption() const;
487 
488 #ifndef DO_NOT_DOCUMENT
489  bool unsycronisation() const;
490 #endif
491 
495  bool unsynchronisation() const;
496 
500  bool dataLengthIndicator() const;
501 
505  ByteVector render() const;
506 
510  TAGLIB_DEPRECATED bool frameAlterPreservation() const;
511 
512  private:
513  Header(const Header &);
514  Header &operator=(const Header &);
515 
516  class HeaderPrivate;
517  HeaderPrivate *d;
518  };
519 
520  } // namespace ID3v2
521 } // namespace TagLib
522 
523 #endif
A map for format-independent <key,valuelist> tag representations.
Definition: tpropertymap.h:118
An implementation of ID3v2 headers.
Definition: id3v2header.h:48
static const String instrumentPrefix
Definition: id3v2frame.h:146
A wide string class suitable for unicode.
Definition: tstring.h:84
A byte vector.
Definition: tbytevector.h:45
A factory for creating ID3v2 frames during parsing.
Definition: id3v2framefactory.h:65
#define TAGLIB_DEPRECATED
Definition: taglib.h:54
A list of strings.
Definition: tstringlist.h:45
An implementation of ID3v2 chapter frames.
Definition: chapterframe.h:44
ID3v2 frame implementation.
Definition: id3v2frame.h:54
#define TAGLIB_EXPORT
Definition: taglib_export.h:40
An implementation of ID3v2 table of contents frames.
Definition: tableofcontentsframe.h:45
static const String urlPrefix
Definition: id3v2frame.h:161
The main class in the ID3v2 implementation.
Definition: id3v2tag.h:127
static const String lyricsPrefix
Definition: id3v2frame.h:156
Type
Definition: tstring.h:97
A namespace for all TagLib related classes and functions.
Definition: apefile.h:41
static const String commentPrefix
Definition: id3v2frame.h:151