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 
37  namespace ID3v2 {
38 
39  class Tag;
40  class FrameFactory;
41 
43 
54  {
55  friend class Tag;
56  friend class FrameFactory;
57 
58  public:
62  virtual ~Frame();
63 
68  ByteVector frameID() const;
69 
73  uint size() const;
74 
83  static uint headerSize(); // BIC: remove and make non-static
84 
90  static uint headerSize(uint version); // BIC: remove and make non-static
91 
98  void setData(const ByteVector &data);
99 
109  virtual void setText(const String &text);
110 
116  virtual String toString() const = 0;
117 
121  ByteVector render() const;
122 
127  static ByteVector textDelimiter(String::Type t);
128 
129  protected:
130  class Header;
131 
139  explicit Frame(const ByteVector &data);
140 
147  Frame(Header *h);
148 
152  Header *header() const;
153 
161  void setHeader(Header *h, bool deleteCurrent = true);
162 
167  void parse(const ByteVector &data);
168 
174  virtual void parseFields(const ByteVector &data) = 0;
175 
180  virtual ByteVector renderFields() const = 0;
181 
187  ByteVector fieldData(const ByteVector &frameData) const;
188 
195  String readStringField(const ByteVector &data, String::Type encoding,
196  int *positon = 0);
197 
202  static String::Type checkEncoding(const StringList &fields,
203  String::Type encoding);
204 
205  private:
206  Frame(const Frame &);
207  Frame &operator=(const Frame &);
208 
209  class FramePrivate;
210  friend class FramePrivate;
211  FramePrivate *d;
212  };
213 
215 
228  class TAGLIB_EXPORT Frame::Header
229  {
230  public:
239  Header(const ByteVector &data, bool synchSafeInts);
240 
248  explicit Header(const ByteVector &data, uint version = 4);
249 
253  virtual ~Header();
254 
261  void setData(const ByteVector &data, bool synchSafeInts);
262 
267  void setData(const ByteVector &data, uint version = 4);
268 
273  ByteVector frameID() const;
274 
283  void setFrameID(const ByteVector &id);
284 
289  uint frameSize() const;
290 
294  void setFrameSize(uint size);
295 
300  uint version() const;
301 
310  static uint size();
311 
318  static uint size(uint version);
319 
329  bool tagAlterPreservation() const;
330 
342  void setTagAlterPreservation(bool discard);
343 
349  bool fileAlterPreservation() const;
350 
356  bool readOnly() const;
357 
363  bool groupingIdentity() const;
364 
370  bool compression() const;
371 
377  bool encryption() const;
378 
379 #ifndef DO_NOT_DOCUMENT
380  bool unsycronisation() const;
381 #endif
382 
386  bool unsynchronisation() const;
387 
391  bool dataLengthIndicator() const;
392 
396  ByteVector render() const;
397 
401  bool frameAlterPreservation() const;
402 
403  private:
404  Header(const Header &);
405  Header &operator=(const Header &);
406 
407  class HeaderPrivate;
408  HeaderPrivate *d;
409  };
410 
411  }
412 }
413 
414 #endif