xref: /MusicPlayer2/MusicPlayer2/taglib/asfattribute.h (revision 2661106a96494c0a7dfab38bf1ae7b9565882443)
1 /**************************************************************************
2     copyright            : (C) 2005-2007 by Lukáš Lalinský
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_ASFATTRIBUTE_H
27 #define TAGLIB_ASFATTRIBUTE_H
28 
29 #include "tstring.h"
30 #include "tbytevector.h"
31 #include "taglib_export.h"
32 #include "asfpicture.h"
33 
34 namespace TagLib
35 {
36 
37   namespace ASF
38   {
39 
40     class File;
41     class Picture;
42 
43     class TAGLIB_EXPORT Attribute
44     {
45     public:
46 
47       /*!
48        * Enum of types an Attribute can have.
49        */
50       enum AttributeTypes {
51         UnicodeType = 0,
52         BytesType   = 1,
53         BoolType    = 2,
54         DWordType   = 3,
55         QWordType   = 4,
56         WordType    = 5,
57         GuidType    = 6
58       };
59 
60       /*!
61        * Constructs an empty attribute.
62        */
63       Attribute();
64 
65       /*!
66        * Constructs an attribute with \a key and a UnicodeType \a value.
67        */
68       Attribute(const String &value);
69 
70       /*!
71        * Constructs an attribute with \a key and a BytesType \a value.
72        */
73       Attribute(const ByteVector &value);
74 
75       /*!
76        * Constructs an attribute with \a key and a Picture \a value.
77        *
78        * This attribute is compatible with the ID3 frame, APIC. The ID3 specification for the APIC frame stipulates that,
79        * while there may be any number of APIC frames associated with a file,
80        * only one may be of type 1 and only one may be of type 2.
81        *
82        * The specification also states that the description of the picture can be no longer than 64 characters, but can be empty.
83        * WM/Picture attributes added with TagLib::ASF are not automatically validated to conform to ID3 specifications.
84        * You must add code in your application to perform validations if you want to maintain complete compatibility with ID3.
85        */
86       Attribute(const Picture &value);
87 
88       /*!
89        * Constructs an attribute with \a key and a DWordType \a value.
90        */
91       Attribute(unsigned int value);
92 
93       /*!
94        * Constructs an attribute with \a key and a QWordType \a value.
95        */
96       Attribute(unsigned long long value);
97 
98       /*!
99        * Constructs an attribute with \a key and a WordType \a value.
100        */
101       Attribute(unsigned short value);
102 
103       /*!
104        * Constructs an attribute with \a key and a BoolType \a value.
105        */
106       Attribute(bool value);
107 
108       /*!
109        * Construct an attribute as a copy of \a other.
110        */
111       Attribute(const Attribute &item);
112 
113       /*!
114        * Copies the contents of \a other into this item.
115        */
116       Attribute &operator=(const Attribute &other);
117 
118       /*!
119        * Exchanges the content of the Attribute by the content of \a other.
120        */
121       void swap(Attribute &other);
122 
123       /*!
124        * Destroys the attribute.
125        */
126       virtual ~Attribute();
127 
128       /*!
129        * Returns type of the value.
130        */
131       AttributeTypes type() const;
132 
133       /*!
134        * Returns the BoolType \a value.
135        */
136       unsigned short toBool() const;
137 
138       /*!
139        * Returns the WordType \a value.
140        */
141       unsigned short toUShort() const;
142 
143       /*!
144        * Returns the DWordType \a value.
145        */
146       unsigned int toUInt() const;
147 
148       /*!
149        * Returns the QWordType \a value.
150        */
151       unsigned long long toULongLong() const;
152 
153       /*!
154        * Returns the UnicodeType \a value.
155        */
156       String toString() const;
157 
158       /*!
159        * Returns the BytesType \a value.
160        */
161       ByteVector toByteVector() const;
162 
163       /*!
164        * Returns the Picture \a value.
165        */
166       Picture toPicture() const;
167 
168       /*!
169        * Returns the language number, or 0 is no stream number was set.
170        */
171       int language() const;
172 
173       /*!
174        * Sets the language number.
175        */
176       void setLanguage(int value);
177 
178       /*!
179        * Returns the stream number, or 0 is no stream number was set.
180        */
181       int stream() const;
182 
183       /*!
184        * Sets the stream number.
185        */
186       void setStream(int value);
187 
188 #ifndef DO_NOT_DOCUMENT
189       /* THIS IS PRIVATE, DON'T TOUCH IT! */
190       String parse(ASF::File &file, int kind = 0);
191 #endif
192 
193       //! Returns the size of the stored data
194       int dataSize() const;
195 
196     private:
197       friend class File;
198 
199       ByteVector render(const String &name, int kind = 0) const;
200 
201       class AttributePrivate;
202       AttributePrivate *d;
203     };
204   }
205 
206 }
207 
208 #endif
209