xref: /MusicPlayer2/MusicPlayer2/taglib/unsynchronizedlyricsframe.h (revision 2661106a96494c0a7dfab38bf1ae7b9565882443)
1*2661106aSZhong Yang /***************************************************************************
2*2661106aSZhong Yang     copyright            : (C) 2002 - 2008 by Scott Wheeler
3*2661106aSZhong Yang     email                : [email protected]
4*2661106aSZhong Yang     copyright            : (C) 2006 by Urs Fleisch
5*2661106aSZhong Yang     email                : [email protected]
6*2661106aSZhong Yang  ***************************************************************************/
7*2661106aSZhong Yang 
8*2661106aSZhong Yang /***************************************************************************
9*2661106aSZhong Yang  *   This library is free software; you can redistribute it and/or modify  *
10*2661106aSZhong Yang  *   it  under the terms of the GNU Lesser General Public License version  *
11*2661106aSZhong Yang  *   2.1 as published by the Free Software Foundation.                     *
12*2661106aSZhong Yang  *                                                                         *
13*2661106aSZhong Yang  *   This library is distributed in the hope that it will be useful, but   *
14*2661106aSZhong Yang  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
15*2661106aSZhong Yang  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
16*2661106aSZhong Yang  *   Lesser General Public License for more details.                       *
17*2661106aSZhong Yang  *                                                                         *
18*2661106aSZhong Yang  *   You should have received a copy of the GNU Lesser General Public      *
19*2661106aSZhong Yang  *   License along with this library; if not, write to the Free Software   *
20*2661106aSZhong Yang  *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA         *
21*2661106aSZhong Yang  *   02110-1301  USA                                                       *
22*2661106aSZhong Yang  *                                                                         *
23*2661106aSZhong Yang  *   Alternatively, this file is available under the Mozilla Public        *
24*2661106aSZhong Yang  *   License Version 1.1.  You may obtain a copy of the License at         *
25*2661106aSZhong Yang  *   http://www.mozilla.org/MPL/                                           *
26*2661106aSZhong Yang  ***************************************************************************/
27*2661106aSZhong Yang 
28*2661106aSZhong Yang #ifndef TAGLIB_UNSYNCHRONIZEDLYRICSFRAME_H
29*2661106aSZhong Yang #define TAGLIB_UNSYNCHRONIZEDLYRICSFRAME_H
30*2661106aSZhong Yang 
31*2661106aSZhong Yang #include "id3v2frame.h"
32*2661106aSZhong Yang 
33*2661106aSZhong Yang namespace TagLib {
34*2661106aSZhong Yang 
35*2661106aSZhong Yang   namespace ID3v2 {
36*2661106aSZhong Yang 
37*2661106aSZhong Yang     //! ID3v2 unsynchronized lyrics frame
38*2661106aSZhong Yang     /*!
39*2661106aSZhong Yang      * An implementation of ID3v2 unsynchronized lyrics.
40*2661106aSZhong Yang      */
41*2661106aSZhong Yang     class TAGLIB_EXPORT UnsynchronizedLyricsFrame : public Frame
42*2661106aSZhong Yang     {
43*2661106aSZhong Yang       friend class FrameFactory;
44*2661106aSZhong Yang 
45*2661106aSZhong Yang     public:
46*2661106aSZhong Yang       /*!
47*2661106aSZhong Yang        * Construct an empty unsynchronized lyrics frame that will use the text encoding
48*2661106aSZhong Yang        * \a encoding.
49*2661106aSZhong Yang        */
50*2661106aSZhong Yang       explicit UnsynchronizedLyricsFrame(String::Type encoding = String::Latin1);
51*2661106aSZhong Yang 
52*2661106aSZhong Yang       /*!
53*2661106aSZhong Yang        * Construct a unsynchronized lyrics frame based on the data in \a data.
54*2661106aSZhong Yang        */
55*2661106aSZhong Yang       explicit UnsynchronizedLyricsFrame(const ByteVector &data);
56*2661106aSZhong Yang 
57*2661106aSZhong Yang       /*!
58*2661106aSZhong Yang        * Destroys this UnsynchronizedLyricsFrame instance.
59*2661106aSZhong Yang        */
60*2661106aSZhong Yang       virtual ~UnsynchronizedLyricsFrame();
61*2661106aSZhong Yang 
62*2661106aSZhong Yang       /*!
63*2661106aSZhong Yang        * Returns the text of this unsynchronized lyrics frame.
64*2661106aSZhong Yang        *
65*2661106aSZhong Yang        * \see text()
66*2661106aSZhong Yang        */
67*2661106aSZhong Yang       virtual String toString() const;
68*2661106aSZhong Yang 
69*2661106aSZhong Yang       /*!
70*2661106aSZhong Yang        * Returns the language encoding as a 3 byte encoding as specified by
71*2661106aSZhong Yang        * <a href="http://en.wikipedia.org/wiki/ISO_639">ISO-639-2</a>.
72*2661106aSZhong Yang        *
73*2661106aSZhong Yang        * \note Most taggers simply ignore this value.
74*2661106aSZhong Yang        *
75*2661106aSZhong Yang        * \see setLanguage()
76*2661106aSZhong Yang        */
77*2661106aSZhong Yang       ByteVector language() const;
78*2661106aSZhong Yang 
79*2661106aSZhong Yang       /*!
80*2661106aSZhong Yang        * Returns the description of this unsynchronized lyrics frame.
81*2661106aSZhong Yang        *
82*2661106aSZhong Yang        * \note Most taggers simply ignore this value.
83*2661106aSZhong Yang        *
84*2661106aSZhong Yang        * \see setDescription()
85*2661106aSZhong Yang        */
86*2661106aSZhong Yang       String description() const;
87*2661106aSZhong Yang 
88*2661106aSZhong Yang       /*!
89*2661106aSZhong Yang        * Returns the text of this unsynchronized lyrics frame.
90*2661106aSZhong Yang        *
91*2661106aSZhong Yang        * \see setText()
92*2661106aSZhong Yang        */
93*2661106aSZhong Yang       String text() const;
94*2661106aSZhong Yang 
95*2661106aSZhong Yang       /*!
96*2661106aSZhong Yang        * Set the language using the 3 byte language code from
97*2661106aSZhong Yang        * <a href="http://en.wikipedia.org/wiki/ISO_639">ISO-639-2</a> to
98*2661106aSZhong Yang        * \a languageCode.
99*2661106aSZhong Yang        *
100*2661106aSZhong Yang        * \see language()
101*2661106aSZhong Yang        */
102*2661106aSZhong Yang       void setLanguage(const ByteVector &languageCode);
103*2661106aSZhong Yang 
104*2661106aSZhong Yang       /*!
105*2661106aSZhong Yang        * Sets the description of the unsynchronized lyrics frame to \a s.
106*2661106aSZhong Yang        *
107*2661106aSZhong Yang        * \see description()
108*2661106aSZhong Yang        */
109*2661106aSZhong Yang       void setDescription(const String &s);
110*2661106aSZhong Yang 
111*2661106aSZhong Yang       /*!
112*2661106aSZhong Yang        * Sets the text portion of the unsynchronized lyrics frame to \a s.
113*2661106aSZhong Yang        *
114*2661106aSZhong Yang        * \see text()
115*2661106aSZhong Yang        */
116*2661106aSZhong Yang       virtual void setText(const String &s);
117*2661106aSZhong Yang 
118*2661106aSZhong Yang       /*!
119*2661106aSZhong Yang        * Returns the text encoding that will be used in rendering this frame.
120*2661106aSZhong Yang        * This defaults to the type that was either specified in the constructor
121*2661106aSZhong Yang        * or read from the frame when parsed.
122*2661106aSZhong Yang        *
123*2661106aSZhong Yang        * \see setTextEncoding()
124*2661106aSZhong Yang        * \see render()
125*2661106aSZhong Yang        */
126*2661106aSZhong Yang       String::Type textEncoding() const;
127*2661106aSZhong Yang 
128*2661106aSZhong Yang       /*!
129*2661106aSZhong Yang        * Sets the text encoding to be used when rendering this frame to
130*2661106aSZhong Yang        * \a encoding.
131*2661106aSZhong Yang        *
132*2661106aSZhong Yang        * \see textEncoding()
133*2661106aSZhong Yang        * \see render()
134*2661106aSZhong Yang        */
135*2661106aSZhong Yang       void setTextEncoding(String::Type encoding);
136*2661106aSZhong Yang 
137*2661106aSZhong Yang 
138*2661106aSZhong Yang       /*! Parses this frame as PropertyMap with a single key.
139*2661106aSZhong Yang        * - if description() is empty or "LYRICS", the key will be "LYRICS"
140*2661106aSZhong Yang        * - if description() is not a valid PropertyMap key, the frame will be
141*2661106aSZhong Yang        *   marked unsupported by an entry "USLT/<description>" in the unsupportedData()
142*2661106aSZhong Yang        *   attribute of the returned map.
143*2661106aSZhong Yang        * - otherwise, the key will be "LYRICS:<description>"
144*2661106aSZhong Yang        * - The single value will be the frame's text().
145*2661106aSZhong Yang        * Note that currently the language() field is not supported by the PropertyMap
146*2661106aSZhong Yang        * interface.
147*2661106aSZhong Yang        */
148*2661106aSZhong Yang       PropertyMap asProperties() const;
149*2661106aSZhong Yang 
150*2661106aSZhong Yang       /*!
151*2661106aSZhong Yang        * LyricsFrames each have a unique description.  This searches for a lyrics
152*2661106aSZhong Yang        * frame with the description \a d and returns a pointer to it.  If no
153*2661106aSZhong Yang        * frame is found that matches the given description null is returned.
154*2661106aSZhong Yang        *
155*2661106aSZhong Yang        * \see description()
156*2661106aSZhong Yang        */
157*2661106aSZhong Yang       static UnsynchronizedLyricsFrame *findByDescription(const Tag *tag, const String &d);
158*2661106aSZhong Yang 
159*2661106aSZhong Yang     protected:
160*2661106aSZhong Yang       // Reimplementations.
161*2661106aSZhong Yang 
162*2661106aSZhong Yang       virtual void parseFields(const ByteVector &data);
163*2661106aSZhong Yang       virtual ByteVector renderFields() const;
164*2661106aSZhong Yang 
165*2661106aSZhong Yang     private:
166*2661106aSZhong Yang       /*!
167*2661106aSZhong Yang        * The constructor used by the FrameFactory.
168*2661106aSZhong Yang        */
169*2661106aSZhong Yang       UnsynchronizedLyricsFrame(const ByteVector &data, Header *h);
170*2661106aSZhong Yang       UnsynchronizedLyricsFrame(const UnsynchronizedLyricsFrame &);
171*2661106aSZhong Yang       UnsynchronizedLyricsFrame &operator=(const UnsynchronizedLyricsFrame &);
172*2661106aSZhong Yang 
173*2661106aSZhong Yang       class UnsynchronizedLyricsFramePrivate;
174*2661106aSZhong Yang       UnsynchronizedLyricsFramePrivate *d;
175*2661106aSZhong Yang     };
176*2661106aSZhong Yang 
177*2661106aSZhong Yang   }
178*2661106aSZhong Yang }
179*2661106aSZhong Yang #endif
180