infotag.h
Go to the documentation of this file.
00001 /***************************************************************************
00002     copyright            : (C) 2012 by Tsuda Kageyu
00003     email                : tsuda.kageyu@gmail.com
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_INFOTAG_H
00027 #define TAGLIB_INFOTAG_H
00028 
00029 #include "tag.h"
00030 #include "tmap.h"
00031 #include "tstring.h"
00032 #include "tstringlist.h"
00033 #include "tbytevector.h"
00034 #include "taglib_export.h"
00035 
00036 namespace TagLib {
00037 
00038   class File;
00039 
00041   namespace RIFF {
00042   namespace Info {
00043 
00044     typedef Map<ByteVector, String> FieldListMap;
00045 
00047 
00060     class TAGLIB_EXPORT StringHandler
00061     {
00062     public:
00063       StringHandler();
00064       ~StringHandler();
00065 
00070       virtual String parse(const ByteVector &data) const;
00071 
00076       virtual ByteVector render(const String &s) const;
00077     };
00078 
00080 
00088     class TAGLIB_EXPORT Tag : public TagLib::Tag
00089     {
00090     public:
00094       Tag();
00095 
00099       Tag(const ByteVector &data);
00100 
00101       virtual ~Tag();
00102 
00103       // Reimplementations
00104 
00105       virtual String title() const;
00106       virtual String artist() const;
00107       virtual String album() const;
00108       virtual String comment() const;
00109       virtual String genre() const;
00110       virtual unsigned int year() const;
00111       virtual unsigned int track() const;
00112 
00113       virtual void setTitle(const String &s);
00114       virtual void setArtist(const String &s);
00115       virtual void setAlbum(const String &s);
00116       virtual void setComment(const String &s);
00117       virtual void setGenre(const String &s);
00118       virtual void setYear(unsigned int i);
00119       virtual void setTrack(unsigned int i);
00120 
00121       virtual bool isEmpty() const;
00122 
00133       FieldListMap fieldListMap() const;
00134 
00135       /*
00136        * Gets the value of the field with the ID \a id.
00137        */
00138       String fieldText(const ByteVector &id) const;
00139 
00140       /*
00141         * Sets the value of the field with the ID \a id to \a s.
00142         * If the field does not exist, it is created.
00143         * If \s is empty, the field is removed.
00144         *
00145         * \note fieldId must be four-byte long pure ASCII string.  This function
00146         * performs nothing if fieldId is invalid.
00147         */
00148       void setFieldText(const ByteVector &id, const String &s);
00149 
00150       /*
00151        * Removes the field with the ID \a id.
00152        */
00153       void removeField(const ByteVector &id);
00154 
00160       ByteVector render() const;
00161 
00173       static void setStringHandler(const StringHandler *handler);
00174 
00175     protected:
00179       void parse(const ByteVector &data);
00180 
00181 
00182     private:
00183       Tag(const Tag &);
00184       Tag &operator=(const Tag &);
00185 
00186       class TagPrivate;
00187       TagPrivate *d;
00188     };
00189   }}
00190 }
00191 
00192 #endif