id3v2frame.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef TAGLIB_ID3V2FRAME_H
00027 #define TAGLIB_ID3V2FRAME_H
00028
00029 #include "tstring.h"
00030 #include "tbytevector.h"
00031 #include "taglib_export.h"
00032
00033 namespace TagLib {
00034
00035 class StringList;
00036 class PropertyMap;
00037
00038 namespace ID3v2 {
00039
00040 class Tag;
00041 class FrameFactory;
00042
00044
00054 class TAGLIB_EXPORT Frame
00055 {
00056 friend class Tag;
00057 friend class FrameFactory;
00058
00059 public:
00060
00066 static Frame *createTextualFrame(const String &key, const StringList &values);
00067
00071 virtual ~Frame();
00072
00077 ByteVector frameID() const;
00078
00082 unsigned int size() const;
00083
00092 static unsigned int headerSize();
00093
00099 static unsigned int headerSize(unsigned int version);
00100
00107 void setData(const ByteVector &data);
00108
00118 virtual void setText(const String &text);
00119
00125 virtual String toString() const = 0;
00126
00130 ByteVector render() const;
00131
00136 static ByteVector textDelimiter(String::Type t);
00137
00143 static const String instrumentPrefix;
00148 static const String commentPrefix;
00153 static const String lyricsPrefix;
00158 static const String urlPrefix;
00159
00160 protected:
00161 class Header;
00162
00170 explicit Frame(const ByteVector &data);
00171
00178 Frame(Header *h);
00179
00183 Header *header() const;
00184
00192 void setHeader(Header *h, bool deleteCurrent = true);
00193
00198 void parse(const ByteVector &data);
00199
00205 virtual void parseFields(const ByteVector &data) = 0;
00206
00211 virtual ByteVector renderFields() const = 0;
00212
00218 ByteVector fieldData(const ByteVector &frameData) const;
00219
00226 String readStringField(const ByteVector &data, String::Type encoding,
00227 int *positon = 0);
00228
00233
00234 static String::Type checkEncoding(const StringList &fields,
00235 String::Type encoding);
00236
00243
00244 static String::Type checkEncoding(const StringList &fields,
00245 String::Type encoding, unsigned int version);
00246
00253 String::Type checkTextEncoding(const StringList &fields,
00254 String::Type encoding) const;
00255
00256
00263 PropertyMap asProperties() const;
00264
00269 static ByteVector keyToFrameID(const String &);
00270
00275 static String frameIDToKey(const ByteVector &);
00276
00280 static String keyToTXXX(const String &);
00281
00285 static String txxxToKey(const String &);
00286
00300 static void splitProperties(const PropertyMap &original, PropertyMap &singleFrameProperties,
00301 PropertyMap &tiplProperties, PropertyMap &tmclProperties);
00302
00303 private:
00304 Frame(const Frame &);
00305 Frame &operator=(const Frame &);
00306
00307 class FramePrivate;
00308 friend class FramePrivate;
00309 FramePrivate *d;
00310 };
00311
00313
00326 class TAGLIB_EXPORT Frame::Header
00327 {
00328 public:
00337 Header(const ByteVector &data, bool synchSafeInts);
00338
00346 explicit Header(const ByteVector &data, unsigned int version = 4);
00347
00351 virtual ~Header();
00352
00359 void setData(const ByteVector &data, bool synchSafeInts);
00360
00365 void setData(const ByteVector &data, unsigned int version = 4);
00366
00371 ByteVector frameID() const;
00372
00381 void setFrameID(const ByteVector &id);
00382
00387 unsigned int frameSize() const;
00388
00392 void setFrameSize(unsigned int size);
00393
00398 unsigned int version() const;
00399
00404 void setVersion(unsigned int version);
00405
00414 static unsigned int size();
00415
00422 static unsigned int size(unsigned int version);
00423
00433 bool tagAlterPreservation() const;
00434
00446 void setTagAlterPreservation(bool discard);
00447
00453 bool fileAlterPreservation() const;
00454
00460 bool readOnly() const;
00461
00467 bool groupingIdentity() const;
00468
00474 bool compression() const;
00475
00481 bool encryption() const;
00482
00483 #ifndef DO_NOT_DOCUMENT
00484 bool unsycronisation() const;
00485 #endif
00486
00490 bool unsynchronisation() const;
00491
00495 bool dataLengthIndicator() const;
00496
00500 ByteVector render() const;
00501
00505 bool frameAlterPreservation() const;
00506
00507 private:
00508 Header(const Header &);
00509 Header &operator=(const Header &);
00510
00511 class HeaderPrivate;
00512 HeaderPrivate *d;
00513 };
00514
00515 }
00516 }
00517
00518 #endif