id3v2frame.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     copyright            : (C) 2002 - 2008 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  *   Alternatively, this file is available under the Mozilla Public        *
00022  *   License Version 1.1.  You may obtain a copy of the License at         *
00023  *   http://www.mozilla.org/MPL/                                           *
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 
00037   namespace ID3v2 {
00038 
00039     class Tag;
00040     class FrameFactory;
00041 
00043 
00053     class TAGLIB_EXPORT Frame
00054     {
00055       friend class Tag;
00056       friend class FrameFactory;
00057 
00058     public:
00062       virtual ~Frame();
00063 
00068       ByteVector frameID() const;
00069 
00073       uint size() const;
00074 
00083       static uint headerSize(); // BIC: remove and make non-static
00084 
00090       static uint headerSize(uint version); // BIC: remove and make non-static
00091 
00098       void setData(const ByteVector &data);
00099 
00109       virtual void setText(const String &text);
00110 
00116       virtual String toString() const = 0;
00117 
00121       ByteVector render() const;
00122 
00127       static ByteVector textDelimiter(String::Type t);
00128 
00129     protected:
00130       class Header;
00131 
00139       explicit Frame(const ByteVector &data);
00140 
00147       Frame(Header *h);
00148 
00152       Header *header() const;
00153 
00161       void setHeader(Header *h, bool deleteCurrent = true);
00162 
00167       void parse(const ByteVector &data);
00168 
00174       virtual void parseFields(const ByteVector &data) = 0;
00175 
00180       virtual ByteVector renderFields() const = 0;
00181 
00187       ByteVector fieldData(const ByteVector &frameData) const;
00188 
00195       String readStringField(const ByteVector &data, String::Type encoding,
00196                              int *positon = 0);
00197 
00202       static String::Type checkEncoding(const StringList &fields,
00203                                         String::Type encoding);
00204 
00205     private:
00206       Frame(const Frame &);
00207       Frame &operator=(const Frame &);
00208 
00209       class FramePrivate;
00210       friend class FramePrivate;
00211       FramePrivate *d;
00212     };
00213 
00215 
00228     class TAGLIB_EXPORT Frame::Header
00229     {
00230     public:
00239       Header(const ByteVector &data, bool synchSafeInts);
00240 
00248       explicit Header(const ByteVector &data, uint version = 4);
00249 
00253       virtual ~Header();
00254 
00261       void setData(const ByteVector &data, bool synchSafeInts);
00262 
00267       void setData(const ByteVector &data, uint version = 4);
00268 
00273       ByteVector frameID() const;
00274 
00283       void setFrameID(const ByteVector &id);
00284 
00289       uint frameSize() const;
00290 
00294       void setFrameSize(uint size);
00295 
00300       uint version() const;
00301 
00310       static uint size();
00311 
00318       static uint size(uint version);
00319 
00329       bool tagAlterPreservation() const;
00330 
00342       void setTagAlterPreservation(bool discard);
00343 
00349       bool fileAlterPreservation() const;
00350 
00356       bool readOnly() const;
00357 
00363       bool groupingIdentity() const;
00364 
00370       bool compression() const;
00371 
00377       bool encryption() const;
00378 
00379 #ifndef DO_NOT_DOCUMENT
00380       bool unsycronisation() const;
00381 #endif
00382 
00386       bool unsynchronisation() const;
00387 
00391       bool dataLengthIndicator() const;
00392 
00396       ByteVector render() const;
00397 
00401       bool frameAlterPreservation() const;
00402 
00403     private:
00404       Header(const Header &);
00405       Header &operator=(const Header &);
00406 
00407       class HeaderPrivate;
00408       HeaderPrivate *d;
00409     };
00410 
00411   }
00412 }
00413 
00414 #endif