id3v2frame.h
Go to the documentation of this file.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 00069 static uint headerSize(); 00070 00077 void setData(const ByteVector &data); 00078 00088 virtual void setText(const String &text); 00089 00095 virtual String toString() const = 0; 00096 00100 ByteVector render() const; 00101 00106 static ByteVector textDelimiter(String::Type t); 00107 00108 protected: 00109 class Header; 00110 00118 explicit Frame(const ByteVector &data); 00119 00126 Frame(Header *h); 00127 00131 Header *header() const; 00132 00140 void setHeader(Header *h, bool deleteCurrent = true); 00141 00146 void parse(const ByteVector &data); 00147 00153 virtual void parseFields(const ByteVector &data) = 0; 00154 00159 virtual ByteVector renderFields() const = 0; 00160 00161 private: 00162 Frame(const Frame &); 00163 Frame &operator=(const Frame &); 00164 00165 class FramePrivate; 00166 FramePrivate *d; 00167 }; 00168 00170 00183 class Frame::Header 00184 { 00185 public: 00191 explicit Header(const ByteVector &data, bool synchSafeInts = true); 00192 00196 virtual ~Header(); 00197 00201 void setData(const ByteVector &data, bool synchSafeInts = true); 00202 00207 ByteVector frameID() const; 00208 00217 void setFrameID(const ByteVector &id); 00218 00223 uint frameSize() const; 00224 00228 void setFrameSize(uint size); 00229 00234 static uint size(); 00235 00239 ByteVector render() const; 00240 00241 private: 00242 Header(const Header &); 00243 Header &operator=(const Header &); 00244 00245 class HeaderPrivate; 00246 HeaderPrivate *d; 00247 }; 00248 00249 } 00250 } 00251 00252 #endif