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 uint size() const;
00083
00092 static uint headerSize();
00093
00099 static uint headerSize(uint 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, uint 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
00277
00291 static void splitProperties(const PropertyMap &original, PropertyMap &singleFrameProperties,
00292 PropertyMap &tiplProperties, PropertyMap &tmclProperties);
00293
00294 private:
00295 Frame(const Frame &);
00296 Frame &operator=(const Frame &);
00297
00298 class FramePrivate;
00299 friend class FramePrivate;
00300 FramePrivate *d;
00301 };
00302
00304
00317 class TAGLIB_EXPORT Frame::Header
00318 {
00319 public:
00328 Header(const ByteVector &data, bool synchSafeInts);
00329
00337 explicit Header(const ByteVector &data, uint version = 4);
00338
00342 virtual ~Header();
00343
00350 void setData(const ByteVector &data, bool synchSafeInts);
00351
00356 void setData(const ByteVector &data, uint version = 4);
00357
00362 ByteVector frameID() const;
00363
00372 void setFrameID(const ByteVector &id);
00373
00378 uint frameSize() const;
00379
00383 void setFrameSize(uint size);
00384
00389 uint version() const;
00390
00395 void setVersion(uint version);
00396
00405 static uint size();
00406
00413 static uint size(uint version);
00414
00424 bool tagAlterPreservation() const;
00425
00437 void setTagAlterPreservation(bool discard);
00438
00444 bool fileAlterPreservation() const;
00445
00451 bool readOnly() const;
00452
00458 bool groupingIdentity() const;
00459
00465 bool compression() const;
00466
00472 bool encryption() const;
00473
00474 #ifndef DO_NOT_DOCUMENT
00475 bool unsycronisation() const;
00476 #endif
00477
00481 bool unsynchronisation() const;
00482
00486 bool dataLengthIndicator() const;
00487
00491 ByteVector render() const;
00492
00496 bool frameAlterPreservation() const;
00497
00498 private:
00499 Header(const Header &);
00500 Header &operator=(const Header &);
00501
00502 class HeaderPrivate;
00503 HeaderPrivate *d;
00504 };
00505
00506 }
00507 }
00508
00509 #endif