Added TagLib (with AUTORS and COPYING files)
[someplayer] / src / taglib / ape / apefooter.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_APEFOOTER_H
27 #define TAGLIB_APEFOOTER_H
28
29 #include "tbytevector.h"
30 #include "taglib_export.h"
31
32 namespace TagLib {
33
34   namespace APE {
35
36     //! An implementation of APE footers
37
38     /*!
39      * This class implements APE footers (and headers). It attempts to follow, both
40      * semantically and programatically, the structure specified in
41      * the APE v2.0 standard.  The API is based on the properties of APE footer and
42      * headers specified there.
43      */
44
45     class TAGLIB_EXPORT Footer
46     {
47     public:
48       /*!
49        * Constructs an empty APE footer.
50        */
51       Footer();
52
53       /*!
54        * Constructs an APE footer based on \a data.  parse() is called
55        * immediately.
56        */
57       Footer(const ByteVector &data);
58
59       /*!
60        * Destroys the footer.
61        */
62       virtual ~Footer();
63
64       /*!
65        * Returns the version number.  (Note: This is the 1000 or 2000.)
66        */
67       uint version() const;
68
69       /*!
70        * Returns true if a header is present in the tag.
71        */
72       bool headerPresent() const;
73
74       /*!
75        * Returns true if a footer is present in the tag.
76        */
77       bool footerPresent() const;
78
79       /*!
80        * Returns true this is actually the header.
81        */
82       bool isHeader() const;
83
84       /*!
85        * Sets whether the header should be rendered or not
86        */
87       void setHeaderPresent(bool b) const;
88
89       /*!
90        * Returns the number of items in the tag.
91        */
92       uint itemCount() const;
93
94       /*!
95        * Set the item count to \a s.
96        * \see itemCount()
97        */
98       void setItemCount(uint s);
99
100       /*!
101        * Returns the tag size in bytes.  This is the size of the frame content and footer.
102        * The size of the \e entire tag will be this plus the header size, if present.
103        *
104        * \see completeTagSize()
105        */
106       uint tagSize() const;
107
108       /*!
109        * Returns the tag size, including if present, the header
110        * size.
111        *
112        * \see tagSize()
113        */
114       uint completeTagSize() const;
115
116       /*!
117        * Set the tag size to \a s.
118        * \see tagSize()
119        */
120       void setTagSize(uint s);
121
122       /*!
123        * Returns the size of the footer.  Presently this is always 32 bytes.
124        */
125       static uint size();
126
127       /*!
128        * Returns the string used to identify an APE tag inside of a file.
129        * Presently this is always "APETAGEX".
130        */
131       static ByteVector fileIdentifier();
132
133       /*!
134        * Sets the data that will be used as the footer.  32 bytes,
135        * starting from \a data will be used.
136        */
137       void setData(const ByteVector &data);
138
139       /*!
140        * Renders the footer back to binary format.
141        */
142       ByteVector renderFooter() const;
143
144       /*!
145        * Renders the header corresponding to the footer. If headerPresent is
146        * set to false, it returns an empty ByteVector.
147        */
148       ByteVector renderHeader() const;
149
150     protected:
151       /*!
152        * Called by setData() to parse the footer data.  It makes this information
153        * available through the public API.
154        */
155       void parse(const ByteVector &data);
156
157       /*!
158        * Called by renderFooter and renderHeader
159        */
160       ByteVector render(bool isHeader) const;
161
162     private:
163       Footer(const Footer &);
164       Footer &operator=(const Footer &);
165
166       class FooterPrivate;
167       FooterPrivate *d;
168     };
169
170   }
171 }
172
173 #endif