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 Tag;
00033     class FrameFactory;
00034 
00036 
00046     class Frame
00047     {
00048       friend class Tag;
00049       friend class FrameFactory;
00050 
00051     public:
00055       virtual ~Frame();
00056 
00061       ByteVector frameID() const;
00062 
00066       uint size() const;
00067 
00076       static uint headerSize(); // BIC: remove and make non-static
00077 
00083       static uint headerSize(uint version); // BIC: remove and make non-static
00084 
00091       void setData(const ByteVector &data);
00092 
00102       virtual void setText(const String &text);
00103 
00109       virtual String toString() const = 0;
00110 
00114       ByteVector render() const;
00115 
00120       static ByteVector textDelimiter(String::Type t);
00121 
00122     protected:
00123       class Header;
00124 
00132       explicit Frame(const ByteVector &data);
00133 
00140       Frame(Header *h);
00141 
00145       Header *header() const;
00146 
00154       void setHeader(Header *h, bool deleteCurrent = true);
00155 
00160       void parse(const ByteVector &data);
00161 
00167       virtual void parseFields(const ByteVector &data) = 0;
00168 
00173       virtual ByteVector renderFields() const = 0;
00174 
00180       ByteVector fieldData(const ByteVector &frameData) const;
00181 
00182     private:
00183       Frame(const Frame &);
00184       Frame &operator=(const Frame &);
00185 
00186       class FramePrivate;
00187       friend class FramePrivate;
00188       FramePrivate *d;
00189     };
00190 
00192 
00205     class Frame::Header
00206     {
00207     public:
00216       Header(const ByteVector &data, bool synchSafeInts);
00217 
00225       explicit Header(const ByteVector &data, uint version = 4);
00226 
00230       virtual ~Header();
00231 
00238       void setData(const ByteVector &data, bool synchSafeInts);
00239 
00244       void setData(const ByteVector &data, uint version = 4);
00245 
00250       ByteVector frameID() const;
00251 
00260       void setFrameID(const ByteVector &id);
00261 
00266       uint frameSize() const;
00267 
00271       void setFrameSize(uint size);
00272 
00277       uint version() const;
00278 
00287       static uint size();
00288 
00295       static uint size(uint version);
00296 
00306       bool tagAlterPreservation() const;
00307 
00319       void setTagAlterPreservation(bool discard);
00320 
00326       bool fileAlterPreservation() const;
00327 
00333       bool readOnly() const;
00334 
00340       bool groupingIdentity() const;
00341 
00347       bool compression() const;
00348 
00354       bool encryption() const;
00355 
00361       bool unsycronisation() const;
00362 
00366       bool dataLengthIndicator() const;
00367 
00371       ByteVector render() const;
00372 
00376       bool frameAlterPreservation() const;
00377 
00378     private:
00379       Header(const Header &);
00380       Header &operator=(const Header &);
00381 
00382       class HeaderPrivate;
00383       HeaderPrivate *d;
00384     };
00385 
00386   }
00387 }
00388 
00389 #endif