Added TagLib (with AUTORS and COPYING files)
[someplayer] / src / taglib / wavpack / wavpackfile.h
1 /***************************************************************************
2     copyright            : (C) 2006 by Lukáš Lalinský
3     email                : lalinsky@gmail.com
4
5     copyright            : (C) 2004 by Allan Sandfeld Jensen
6     email                : kde@carewolf.org
7                            (original MPC implementation)
8  ***************************************************************************/
9
10 /***************************************************************************
11  *   This library is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU Lesser General Public License version   *
13  *   2.1 as published by the Free Software Foundation.                     *
14  *                                                                         *
15  *   This library is distributed in the hope that it will be useful, but   *
16  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
17  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
18  *   Lesser General Public License for more details.                       *
19  *                                                                         *
20  *   You should have received a copy of the GNU Lesser General Public      *
21  *   License along with this library; if not, write to the Free Software   *
22  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
23  *   USA                                                                   *
24  *                                                                         *
25  *   Alternatively, this file is available under the Mozilla Public        *
26  *   License Version 1.1.  You may obtain a copy of the License at         *
27  *   http://www.mozilla.org/MPL/                                           *
28  ***************************************************************************/
29
30 #ifndef TAGLIB_WVFILE_H
31 #define TAGLIB_WVFILE_H
32
33 #include "tfile.h"
34 #include "taglib_export.h"
35 #include "wavpackproperties.h"
36
37 namespace TagLib {
38
39   class Tag;
40
41   namespace ID3v1 { class Tag; }
42   namespace APE { class Tag; }
43
44   //! An implementation of WavPack metadata
45
46   /*!
47    * This is implementation of WavPack metadata.
48    *
49    * This supports ID3v1 and APE (v1 and v2) style comments as well as reading stream
50    * properties from the file.
51    */
52
53   namespace WavPack {
54
55     //! An implementation of TagLib::File with WavPack specific methods
56
57     /*!
58      * This implements and provides an interface for WavPack files to the
59      * TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
60      * the abstract TagLib::File API as well as providing some additional
61      * information specific to WavPack files.
62      */
63
64     class TAGLIB_EXPORT File : public TagLib::File
65     {
66     public:
67       /*!
68        * This set of flags is used for various operations and is suitable for
69        * being OR-ed together.
70        */
71       enum TagTypes {
72         //! Empty set.  Matches no tag types.
73         NoTags  = 0x0000,
74         //! Matches ID3v1 tags.
75         ID3v1   = 0x0001,
76         //! Matches APE tags.
77         APE     = 0x0002,
78         //! Matches all tag types.
79         AllTags = 0xffff
80       };
81
82       /*!
83        * Contructs an WavPack file from \a file.  If \a readProperties is true the
84        * file's audio properties will also be read using \a propertiesStyle.  If
85        * false, \a propertiesStyle is ignored.
86        */
87       File(FileName file, bool readProperties = true,
88            Properties::ReadStyle propertiesStyle = Properties::Average);
89
90       /*!
91        * Destroys this instance of the File.
92        */
93       virtual ~File();
94
95       /*!
96        * Returns the Tag for this file.  This will be an APE tag, an ID3v1 tag
97        * or a combination of the two.
98        */
99       virtual TagLib::Tag *tag() const;
100
101       /*!
102        * Returns the MPC::Properties for this file.  If no audio properties
103        * were read then this will return a null pointer.
104        */
105       virtual Properties *audioProperties() const;
106
107       /*!
108        * Saves the file.
109        */
110       virtual bool save();
111
112       /*!
113        * Returns a pointer to the ID3v1 tag of the file.
114        *
115        * If \a create is false (the default) this will return a null pointer
116        * if there is no valid ID3v1 tag.  If \a create is true it will create
117        * an ID3v1 tag if one does not exist. If there is already an APE tag, the
118        * new ID3v1 tag will be placed after it.
119        *
120        * \note The Tag <b>is still</b> owned by the APE::File and should not be
121        * deleted by the user.  It will be deleted when the file (object) is
122        * destroyed.
123        */
124       ID3v1::Tag *ID3v1Tag(bool create = false);
125
126       /*!
127        * Returns a pointer to the APE tag of the file.
128        *
129        * If \a create is false (the default) this will return a null pointer
130        * if there is no valid APE tag.  If \a create is true it will create
131        * a APE tag if one does not exist.
132        *
133        * \note The Tag <b>is still</b> owned by the APE::File and should not be
134        * deleted by the user.  It will be deleted when the file (object) is
135        * destroyed.
136        */
137       APE::Tag *APETag(bool create = false);
138
139       /*!
140        * This will remove the tags that match the OR-ed together TagTypes from the
141        * file.  By default it removes all tags.
142        *
143        * \note This will also invalidate pointers to the tags
144        * as their memory will be freed.
145        * \note In order to make the removal permanent save() still needs to be called
146        */
147       void strip(int tags = AllTags);
148
149     private:
150       File(const File &);
151       File &operator=(const File &);
152
153       void read(bool readProperties, Properties::ReadStyle propertiesStyle);
154       void scan();
155       long findID3v1();
156       long findAPE();
157
158       class FilePrivate;
159       FilePrivate *d;
160     };
161   }
162 }
163
164 #endif