xref: /MusicPlayer2/MusicPlayer2/taglib/id3v2header.h (revision 2661106a96494c0a7dfab38bf1ae7b9565882443)
1 /***************************************************************************
2     copyright            : (C) 2002 - 2008 by Scott Wheeler
3     email                : [email protected]
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., 51 Franklin Street, Fifth Floor, Boston, MA         *
19  *   02110-1301  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_ID3V2HEADER_H
27 #define TAGLIB_ID3V2HEADER_H
28 
29 #include "tbytevector.h"
30 #include "taglib_export.h"
31 #include "id3v2.h"
32 
33 namespace TagLib {
34 
35   namespace ID3v2 {
36 
37     //! An implementation of ID3v2 headers
38 
39     /*!
40      * This class implements ID3v2 headers.  It attempts to follow, both
41      * semantically and programmatically, the structure specified in
42      * the ID3v2 standard.  The API is based on the properties of ID3v2 headers
43      * specified there.  If any of the terms used in this documentation are
44      * unclear please check the specification in the linked section.
45      * (Structure, <a href="id3v2-structure.html#3.1">3.1</a>)
46      */
47 
48     class TAGLIB_EXPORT Header
49     {
50     public:
51       /*!
52        * Constructs an empty ID3v2 header.
53        */
54       Header();
55 
56       /*!
57        * Constructs an ID3v2 header based on \a data.  parse() is called
58        * immediately.
59        */
60       Header(const ByteVector &data);
61 
62       /*!
63        * Destroys the header.
64        */
65       virtual ~Header();
66 
67       /*!
68        * Returns the major version number.  (Note: This is the 4, not the 2 in
69        * ID3v2.4.0.  The 2 is implied.)
70        */
71       unsigned int majorVersion() const;
72 
73       /*!
74        * Set the the major version number to \a version.  (Note: This is
75        * the 4, not the 2 in ID3v2.4.0.  The 2 is implied.)
76        * \see majorVersion()
77        *
78        * \note This is used by the internal parser; this will not change the
79        * version which is written and in general should not be called by API
80        * users.
81        */
82       void setMajorVersion(unsigned int version);
83 
84       /*!
85        * Returns the revision number.  (Note: This is the 0, not the 4 in
86        * ID3v2.4.0.  The 2 is implied.)
87        */
88       unsigned int revisionNumber() const;
89 
90       /*!
91        * Returns true if unsynchronisation has been applied to all frames.
92        */
93       bool unsynchronisation() const;
94 
95       /*!
96        * Returns true if an extended header is present in the tag.
97        */
98       bool extendedHeader() const;
99 
100       /*!
101        * Returns true if the experimental indicator flag is set.
102        */
103       bool experimentalIndicator() const;
104 
105       /*!
106        * Returns true if a footer is present in the tag.
107        */
108       bool footerPresent() const;
109       /*!
110        * Returns the tag size in bytes.  This is the size of the frame content.
111        * The size of the \e entire tag will be this plus the header size (10
112        * bytes) and, if present, the footer size (potentially another 10 bytes).
113        *
114        * \note This is the value as read from the header to which TagLib attempts
115        * to provide an API to; it was not a design decision on the part of TagLib
116        * to not include the mentioned portions of the tag in the \e size.
117        *
118        * \see completeTagSize()
119        */
120       unsigned int tagSize() const;
121 
122       /*!
123        * Returns the tag size, including the header and, if present, the footer
124        * size.
125        *
126        * \see tagSize()
127        */
128       unsigned int completeTagSize() const;
129 
130       /*!
131        * Set the tag size to \a s.
132        * \see tagSize()
133        */
134       void setTagSize(unsigned int s);
135 
136       /*!
137        * Returns the size of the header.  Presently this is always 10 bytes.
138        */
139       static unsigned int size();
140 
141       /*!
142        * Returns the string used to identify and ID3v2 tag inside of a file.
143        * Presently this is always "ID3".
144        */
145       static ByteVector fileIdentifier();
146 
147       /*!
148        * Sets the data that will be used as the header.  10 bytes, starting from
149        * the beginning of \a data are used.
150        */
151       void setData(const ByteVector &data);
152 
153       /*!
154        * Renders the Header back to binary format.
155        */
156       ByteVector render() const;
157 
158     protected:
159       /*!
160        * Called by setData() to parse the header data.  It makes this information
161        * available through the public API.
162        */
163       void parse(const ByteVector &data);
164 
165     private:
166       Header(const Header &);
167       Header &operator=(const Header &);
168 
169       class HeaderPrivate;
170       HeaderPrivate *d;
171     };
172 
173   }
174 }
175 
176 #endif
177