Added TagLib (with AUTORS and COPYING files)
[someplayer] / src / taglib / ape / apetag.h
1 /***************************************************************************
2     copyright            : (C) 2004 by Allan Sandfeld Jensen
3     email                : kde@carewolf.org
4  ***************************************************************************/
5
6 /***************************************************************************
7  *   This library is free software; you can redistribute it and/or modify  *
8  *   it under the terms of the GNU Lesser General Public License version   *
9  *   2.1 as published by the Free Software Foundation.                     *
10  *                                                                         *
11  *   This library is distributed in the hope that it will be useful, but   *
12  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
14  *   Lesser General Public License for more details.                       *
15  *                                                                         *
16  *   You should have received a copy of the GNU Lesser General Public      *
17  *   License along with this library; if not, write to the Free Software   *
18  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
19  *   USA                                                                   *
20  *                                                                         *
21  *   Alternatively, this file is available under the Mozilla Public        *
22  *   License Version 1.1.  You may obtain a copy of the License at         *
23  *   http://www.mozilla.org/MPL/                                           *
24  ***************************************************************************/
25
26 #ifndef TAGLIB_APETAG_H
27 #define TAGLIB_APETAG_H
28
29 #include "tag.h"
30 #include "tbytevector.h"
31 #include "tmap.h"
32 #include "tstring.h"
33 #include "taglib_export.h"
34
35 #include "apeitem.h"
36
37 namespace TagLib {
38
39   class File;
40
41   //! An implementation of the APE tagging format
42
43   namespace APE {
44
45     class Footer;
46
47     /*!
48      * A mapping between a list of item names, or keys, and the associated item.
49      *
50      * \see APE::Tag::itemListMap()
51      */
52     typedef Map<const String, Item> ItemListMap;
53
54
55     //! An APE tag implementation
56
57     class TAGLIB_EXPORT Tag : public TagLib::Tag
58     {
59     public:
60       /*!
61        * Create an APE tag with default values.
62        */
63       Tag();
64
65       /*!
66        * Create an APE tag and parse the data in \a file with APE footer at
67        * \a tagOffset.
68        */
69       Tag(File *file, long footerLocation);
70
71       /*!
72        * Destroys this Tag instance.
73        */
74       virtual ~Tag();
75
76       /*!
77        * Renders the in memory values to a ByteVector suitable for writing to
78        * the file.
79        */
80       ByteVector render() const;
81
82       /*!
83        * Returns the string "APETAGEX" suitable for usage in locating the tag in a
84        * file.
85        */
86       static ByteVector fileIdentifier();
87
88       // Reimplementations.
89
90       virtual String title() const;
91       virtual String artist() const;
92       virtual String album() const;
93       virtual String comment() const;
94       virtual String genre() const;
95       virtual uint year() const;
96       virtual uint track() const;
97
98       virtual void setTitle(const String &s);
99       virtual void setArtist(const String &s);
100       virtual void setAlbum(const String &s);
101       virtual void setComment(const String &s);
102       virtual void setGenre(const String &s);
103       virtual void setYear(uint i);
104       virtual void setTrack(uint i);
105
106       /*!
107        * Returns a pointer to the tag's footer.
108        */
109       Footer *footer() const;
110
111       /*!
112        * Returns a reference to the item list map.  This is an ItemListMap of
113        * all of the items in the tag.
114        *
115        * This is the most powerfull structure for accessing the items of the tag.
116        *
117        * \warning You should not modify this data structure directly, instead
118        * use setItem() and removeItem().
119        */
120       const ItemListMap &itemListMap() const;
121
122       /*!
123        * Removes the \a key item from the tag
124        */
125       void removeItem(const String &key);
126
127       /*!
128        * Adds to the item specified by \a key the data \a value.  If \a replace
129        * is true, then all of the other values on the same key will be removed
130        * first.
131        */
132       void addValue(const String &key, const String &value, bool replace = true);
133
134       /*!
135        * Sets the \a key item to the value of \a item. If an item with the \a key is already
136        * present, it will be replaced.
137        */
138       void setItem(const String &key, const Item &item);
139
140     protected:
141
142       /*!
143        * Reads from the file specified in the constructor.
144        */
145       void read();
146
147       /*!
148        * Parses the body of the tag in \a data.
149        */
150       void parse(const ByteVector &data);
151
152     private:
153       Tag(const Tag &);
154       Tag &operator=(const Tag &);
155
156       class TagPrivate;
157       TagPrivate *d;
158     };
159   }
160 }
161
162 #endif