![]() |
|
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., 51 Franklin Street, Fifth Floor, Boston, MA * 00019 * 02110-1301 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_ID3V2TAG_H 00027 #define TAGLIB_ID3V2TAG_H 00028 00029 #include "tag.h" 00030 #include "tbytevector.h" 00031 #include "tstring.h" 00032 #include "tlist.h" 00033 #include "tmap.h" 00034 #include "taglib_export.h" 00035 00036 #include "id3v2framefactory.h" 00037 00038 namespace TagLib { 00039 00040 class File; 00041 00043 00051 namespace ID3v2 { 00052 00053 class Header; 00054 class ExtendedHeader; 00055 class Footer; 00056 00057 typedef List<Frame *> FrameList; 00058 typedef Map<ByteVector, FrameList> FrameListMap; 00059 00061 00077 class TAGLIB_EXPORT Latin1StringHandler 00078 { 00079 public: 00080 Latin1StringHandler(); 00081 virtual ~Latin1StringHandler(); 00082 00087 virtual String parse(const ByteVector &data) const; 00088 }; 00089 00091 00135 class TAGLIB_EXPORT Tag : public TagLib::Tag 00136 { 00137 public: 00143 Tag(); 00144 00157 Tag(File *file, long tagOffset, 00158 const FrameFactory *factory = FrameFactory::instance()); 00159 00163 virtual ~Tag(); 00164 00165 // Reimplementations. 00166 00167 virtual String title() const; 00168 virtual String artist() const; 00169 virtual String album() const; 00170 virtual String comment() const; 00171 virtual String genre() const; 00172 virtual uint year() const; 00173 virtual uint track() const; 00174 00175 virtual void setTitle(const String &s); 00176 virtual void setArtist(const String &s); 00177 virtual void setAlbum(const String &s); 00178 virtual void setComment(const String &s); 00179 virtual void setGenre(const String &s); 00180 virtual void setYear(uint i); 00181 virtual void setTrack(uint i); 00182 00183 virtual bool isEmpty() const; 00184 00188 Header *header() const; 00189 00194 ExtendedHeader *extendedHeader() const; 00195 00204 Footer *footer() const; 00205 00240 const FrameListMap &frameListMap() const; 00241 00252 const FrameList &frameList() const; 00253 00265 const FrameList &frameList(const ByteVector &frameID) const; 00266 00274 void addFrame(Frame *frame); 00275 00283 void removeFrame(Frame *frame, bool del = true); 00284 00291 void removeFrames(const ByteVector &id); 00292 00322 PropertyMap properties() const; 00323 00335 void removeUnsupportedProperties(const StringList &properties); 00336 00341 PropertyMap setProperties(const PropertyMap &); 00342 00346 ByteVector render() const; 00347 00354 // BIC: combine with the above method 00355 ByteVector render(int version) const; 00356 00363 static Latin1StringHandler const *latin1StringHandler(); 00364 00376 static void setLatin1StringHandler(const Latin1StringHandler *handler); 00377 00378 protected: 00385 void read(); 00386 00391 void parse(const ByteVector &data); 00392 00397 void setTextFrame(const ByteVector &id, const String &value); 00398 00399 void downgradeFrames(FrameList *existingFrames, FrameList *newFrames) const; 00400 00401 private: 00402 Tag(const Tag &); 00403 Tag &operator=(const Tag &); 00404 00405 class TagPrivate; 00406 TagPrivate *d; 00407 }; 00408 00409 } 00410 } 00411 00412 #endif