![]() |
|
00001 /*************************************************************************** 00002 copyright : (C) 2002, 2003 by Scott Wheeler 00003 email : wheeler@kde.org 00004 ***************************************************************************/ 00005 00006 /*************************************************************************** 00007 * This library is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU Lesser General Public License version * 00009 * 2.1 as published by the Free Software Foundation. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, but * 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library; if not, write to the Free Software * 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * 00019 * USA * 00020 ***************************************************************************/ 00021 00022 #ifndef TAGLIB_ID3V2FRAME_H 00023 #define TAGLIB_ID3V2FRAME_H 00024 00025 #include <tstring.h> 00026 #include <tbytevector.h> 00027 00028 namespace TagLib { 00029 00030 namespace ID3v2 { 00031 00032 class FrameFactory; 00033 00035 00045 class Frame 00046 { 00047 friend class FrameFactory; 00048 00049 public: 00053 virtual ~Frame(); 00054 00059 ByteVector frameID() const; 00060 00064 uint size() const; 00065 00074 static uint headerSize(); // BIC: remove and make non-static 00075 00081 static uint headerSize(uint version); // BIC: remove and make non-static 00082 00089 void setData(const ByteVector &data); 00090 00100 virtual void setText(const String &text); 00101 00107 virtual String toString() const = 0; 00108 00112 ByteVector render() const; 00113 00118 static ByteVector textDelimiter(String::Type t); 00119 00120 protected: 00121 class Header; 00122 00130 explicit Frame(const ByteVector &data); 00131 00138 Frame(Header *h); 00139 00143 Header *header() const; 00144 00152 void setHeader(Header *h, bool deleteCurrent = true); 00153 00158 void parse(const ByteVector &data); 00159 00165 virtual void parseFields(const ByteVector &data) = 0; 00166 00171 virtual ByteVector renderFields() const = 0; 00172 00178 ByteVector fieldData(const ByteVector &frameData) const; 00179 00180 private: 00181 Frame(const Frame &); 00182 Frame &operator=(const Frame &); 00183 00184 class FramePrivate; 00185 FramePrivate *d; 00186 }; 00187 00189 00202 class Frame::Header 00203 { 00204 public: 00213 Header(const ByteVector &data, bool synchSafeInts); 00214 00222 explicit Header(const ByteVector &data, uint version = 4); 00223 00227 virtual ~Header(); 00228 00235 void setData(const ByteVector &data, bool synchSafeInts); 00236 00241 void setData(const ByteVector &data, uint version = 4); 00242 00247 ByteVector frameID() const; 00248 00257 void setFrameID(const ByteVector &id); 00258 00263 uint frameSize() const; 00264 00268 void setFrameSize(uint size); 00269 00274 uint version() const; 00275 00284 static uint size(); 00285 00292 static uint size(uint version); 00293 00299 bool tagAlterPreservation() const; 00300 00306 bool fileAlterPreservation() const; 00307 00313 bool readOnly() const; 00314 00320 bool groupingIdentity() const; 00321 00327 bool compression() const; 00328 00334 bool encryption() const; 00335 00341 bool unsycronisation() const; 00342 00346 bool dataLengthIndicator() const; 00347 00351 ByteVector render() const; 00352 00356 bool frameAlterPreservation() const; 00357 00358 private: 00359 Header(const Header &); 00360 Header &operator=(const Header &); 00361 00362 class HeaderPrivate; 00363 HeaderPrivate *d; 00364 }; 00365 00366 } 00367 } 00368 00369 #endif