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 00173 private: 00174 Frame(const Frame &); 00175 Frame &operator=(const Frame &); 00176 00177 class FramePrivate; 00178 FramePrivate *d; 00179 }; 00180 00182 00195 class Frame::Header 00196 { 00197 public: 00206 Header(const ByteVector &data, bool synchSafeInts); 00207 00215 explicit Header(const ByteVector &data, uint version = 4); 00216 00220 virtual ~Header(); 00221 00228 void setData(const ByteVector &data, bool synchSafeInts); 00229 00234 void setData(const ByteVector &data, uint version = 4); 00235 00240 ByteVector frameID() const; 00241 00250 void setFrameID(const ByteVector &id); 00251 00256 uint frameSize() const; 00257 00261 void setFrameSize(uint size); 00262 00267 uint version() const; 00268 00277 static uint size(); 00278 00285 static uint size(uint version); 00286 00290 ByteVector render() const; 00291 00292 private: 00293 Header(const Header &); 00294 Header &operator=(const Header &); 00295 00296 class HeaderPrivate; 00297 HeaderPrivate *d; 00298 }; 00299 00300 } 00301 } 00302 00303 #endif