TagLib  2.0.2
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 
57  {
58  friend class Tag;
59 
60  public:
61  class Header;
62 
66  virtual ~Frame();
67 
68  Frame(const Frame &) = delete;
69  Frame &operator=(const Frame &) = delete;
70 
78  ByteVector frameID() const;
79 
83  unsigned int size() const;
84 
88  unsigned int headerSize() const;
89 
96  void setData(const ByteVector &data);
97 
107  virtual void setText(const String &text);
108 
114  virtual String toString() const = 0;
115 
122  virtual StringList toStringList() const;
123 
127  ByteVector render() const;
128 
132  Header *header() const;
133 
138  static ByteVector textDelimiter(String::Type t);
139 
144  static ByteVector keyToFrameID(const String &);
145 
150  static String frameIDToKey(const ByteVector &);
151 
157  static const String instrumentPrefix;
162  static const String commentPrefix;
167  static const String lyricsPrefix;
172  static const String urlPrefix;
173 
174  protected:
182  explicit Frame(const ByteVector &data);
183 
190  Frame(Header *h);
191 
199  void setHeader(Header *h, bool deleteCurrent = true);
200 
205  void parse(const ByteVector &data);
206 
212  virtual void parseFields(const ByteVector &data) = 0;
213 
218  virtual ByteVector renderFields() const = 0;
219 
225  ByteVector fieldData(const ByteVector &frameData) const;
226 
233  String readStringField(const ByteVector &data, String::Type encoding,
234  int *position = nullptr);
235 
242  String::Type checkTextEncoding(const StringList &fields,
243  String::Type encoding) const;
244 
245 
251  virtual PropertyMap asProperties() const;
252 
266  static void splitProperties(const PropertyMap &original, PropertyMap &singleFrameProperties,
267  PropertyMap &tiplProperties, PropertyMap &tmclProperties);
268 
269  private:
270  class FramePrivate;
271  friend class FramePrivate;
273  std::unique_ptr<FramePrivate> d;
274  };
275 
277 
292  class TAGLIB_EXPORT Frame::Header
293  {
294  public:
302  explicit Header(const ByteVector &data, unsigned int version = 4);
303 
307  virtual ~Header();
308 
309  Header(const Header &) = delete;
310  Header &operator=(const Header &) = delete;
311 
316  void setData(const ByteVector &data, unsigned int version = 4);
317 
325  ByteVector frameID() const;
326 
335  void setFrameID(const ByteVector &id);
336 
341  unsigned int frameSize() const;
342 
346  void setFrameSize(unsigned int size);
347 
352  unsigned int version() const;
353 
358  void setVersion(unsigned int version);
359 
363  unsigned int size() const;
364 
374  bool tagAlterPreservation() const;
375 
387  void setTagAlterPreservation(bool preserve);
388 
394  bool fileAlterPreservation() const;
395 
401  bool readOnly() const;
402 
408  bool groupingIdentity() const;
409 
415  bool compression() const;
416 
422  bool encryption() const;
423 
427  bool unsynchronisation() const;
428 
432  bool dataLengthIndicator() const;
433 
437  ByteVector render() const;
438 
439  private:
440  class HeaderPrivate;
442  std::unique_ptr<HeaderPrivate> d;
443  };
444 
445  } // namespace ID3v2
446 } // namespace TagLib
447 
448 #endif
A map for format-independent <key,values> tag representations.
Definition: tpropertymap.h:122
An implementation of ID3v2 headers.
Definition: id3v2header.h:48
static const String instrumentPrefix
Definition: id3v2frame.h:157
A wide string class suitable for unicode.
Definition: tstring.h:82
A byte vector.
Definition: tbytevector.h:45
#define TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE
Definition: taglib_export.h:55
A list of strings.
Definition: tstringlist.h:43
ID3v2 frame implementation.
Definition: id3v2frame.h:56
#define TAGLIB_EXPORT
Definition: taglib_export.h:40
static const String urlPrefix
Definition: id3v2frame.h:172
The main class in the ID3v2 implementation.
Definition: id3v2tag.h:133
static const String lyricsPrefix
Definition: id3v2frame.h:167
Type
Definition: tstring.h:96
A namespace for all TagLib related classes and functions.
Definition: apefile.h:41
static const String commentPrefix
Definition: id3v2frame.h:162