/libtunepimp-0.5.3/plugins/wv/wvfile.h
C Header | 160 lines | 40 code | 25 blank | 95 comment | 0 complexity | 7396379b27acf88b3f1dd6ddba93d683 MD5 | raw file
Possible License(s): LGPL-2.1, LGPL-3.0, GPL-2.0, LGPL-2.0
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
26#ifndef TAGLIB_WVFILE_H
27#define TAGLIB_WVFILE_H
28
29#include "tfile.h"
30
31#include "wvproperties.h"
32
33namespace TagLib {
34
35 class Tag;
36
37 namespace ID3v1 { class Tag; }
38 namespace APE { class Tag; }
39
40 //! An implementation of WavPack metadata
41
42 /*!
43 * This is implementation of WavPack metadata.
44 *
45 * This supports ID3v1 and APE (v1 and v2) style comments as well as reading stream
46 * properties from the file.
47 */
48
49 namespace WavPack {
50
51 //! An implementation of TagLib::File with WavPack specific methods
52
53 /*!
54 * This implements and provides an interface for WavPack files to the
55 * TagLib::Tag and TagLib::AudioProperties interfaces by way of implementing
56 * the abstract TagLib::File API as well as providing some additional
57 * information specific to WavPack files.
58 */
59
60 class File : public TagLib::File
61 {
62 public:
63 /*!
64 * This set of flags is used for various operations and is suitable for
65 * being OR-ed together.
66 */
67 enum TagTypes {
68 //! Empty set. Matches no tag types.
69 NoTags = 0x0000,
70 //! Matches ID3v1 tags.
71 ID3v1 = 0x0001,
72 //! Matches APE tags.
73 APE = 0x0002,
74 //! Matches all tag types.
75 AllTags = 0xffff
76 };
77
78 /*!
79 * Contructs an WavPack file from \a file. If \a readProperties is true the
80 * file's audio properties will also be read using \a propertiesStyle. If
81 * false, \a propertiesStyle is ignored.
82 */
83 File(const char *file, bool readProperties = true,
84 Properties::ReadStyle propertiesStyle = Properties::Average);
85
86 /*!
87 * Destroys this instance of the File.
88 */
89 virtual ~File();
90
91 /*!
92 * Returns the Tag for this file. This will be an APE tag, an ID3v1 tag
93 * or a combination of the two.
94 */
95 virtual TagLib::Tag *tag() const;
96
97 /*!
98 * Returns the MPC::Properties for this file. If no audio properties
99 * were read then this will return a null pointer.
100 */
101 virtual Properties *audioProperties() const;
102
103 /*!
104 * Saves the file.
105 */
106 virtual bool save();
107
108 /*!
109 * Returns a pointer to the ID3v1 tag of the file.
110 *
111 * If \a create is false (the default) this will return a null pointer
112 * if there is no valid ID3v1 tag. If \a create is true it will create
113 * an ID3v1 tag if one does not exist. If there is already an APE tag, the
114 * new ID3v1 tag will be placed after it.
115 *
116 * \note The Tag <b>is still</b> owned by the APE::File and should not be
117 * deleted by the user. It will be deleted when the file (object) is
118 * destroyed.
119 */
120 ID3v1::Tag *ID3v1Tag(bool create = false);
121
122 /*!
123 * Returns a pointer to the APE tag of the file.
124 *
125 * If \a create is false (the default) this will return a null pointer
126 * if there is no valid APE tag. If \a create is true it will create
127 * a APE tag if one does not exist.
128 *
129 * \note The Tag <b>is still</b> owned by the APE::File and should not be
130 * deleted by the user. It will be deleted when the file (object) is
131 * destroyed.
132 */
133 APE::Tag *APETag(bool create = false);
134
135 /*!
136 * This will remove the tags that match the OR-ed together TagTypes from the
137 * file. By default it removes all tags.
138 *
139 * \note This will also invalidate pointers to the tags
140 * as their memory will be freed.
141 * \note In order to make the removal permanent save() still needs to be called
142 */
143 void remove(int tags = AllTags);
144
145 private:
146 File(const File &);
147 File &operator=(const File &);
148
149 void read(bool readProperties, Properties::ReadStyle propertiesStyle);
150 void scan();
151 long findID3v1();
152 long findAPE();
153
154 class FilePrivate;
155 FilePrivate *d;
156 };
157 }
158}
159
160#endif