Added TagLib (with AUTORS and COPYING files)
[someplayer] / src / taglib / mpeg / id3v2 / frames / commentsframe.h
1 /***************************************************************************
2     copyright            : (C) 2002 - 2008 by Scott Wheeler
3     email                : wheeler@kde.org
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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
19  *   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_COMMENTSFRAME_H
27 #define TAGLIB_COMMENTSFRAME_H
28
29 #include "id3v2frame.h"
30 #include "taglib_export.h"
31
32 namespace TagLib {
33
34   namespace ID3v2 {
35
36     //! An implementation of ID3v2 comments
37
38     /*!
39      * This implements the ID3v2 comment format.  An ID3v2 comment concists of
40      * a language encoding, a description and a single text field.
41      */
42
43     class TAGLIB_EXPORT CommentsFrame : public Frame
44     {
45       friend class FrameFactory;
46
47     public:
48       /*!
49        * Construct an empty comment frame that will use the text encoding
50        * \a encoding.
51        */
52       explicit CommentsFrame(String::Type encoding = String::Latin1);
53
54       /*!
55        * Construct a comment based on the data in \a data.
56        */
57       explicit CommentsFrame(const ByteVector &data);
58
59       /*!
60        * Destroys this CommentFrame instance.
61        */
62       virtual ~CommentsFrame();
63
64       /*!
65        * Returns the text of this comment.
66        *
67        * \see text()
68        */
69       virtual String toString() const;
70
71       /*!
72        * Returns the language encoding as a 3 byte encoding as specified by
73        * <a href="http://en.wikipedia.org/wiki/ISO_639">ISO-639-2</a>.
74        *
75        * \note Most taggers simply ignore this value.
76        *
77        * \see setLanguage()
78        */
79       ByteVector language() const;
80
81       /*!
82        * Returns the description of this comment.
83        *
84        * \note Most taggers simply ignore this value.
85        *
86        * \see setDescription()
87        */
88       String description() const;
89
90       /*!
91        * Returns the text of this comment.
92        *
93        * \see setText()
94        */
95       String text() const;
96
97       /*!
98        * Set the language using the 3 byte language code from
99        * <a href="http://en.wikipedia.org/wiki/ISO_639">ISO-639-2</a> to
100        * \a languageCode.
101        *
102        * \see language()
103        */
104       void setLanguage(const ByteVector &languageCode);
105
106       /*!
107        * Sets the description of the comment to \a s.
108        *
109        * \see decription()
110        */
111       void setDescription(const String &s);
112
113       /*!
114        * Sets the text portion of the comment to \a s.
115        *
116        * \see text()
117        */
118       virtual void setText(const String &s);
119
120       /*!
121        * Returns the text encoding that will be used in rendering this frame.
122        * This defaults to the type that was either specified in the constructor
123        * or read from the frame when parsed.
124        *
125        * \see setTextEncoding()
126        * \see render()
127        */
128       String::Type textEncoding() const;
129
130       /*!
131        * Sets the text encoding to be used when rendering this frame to
132        * \a encoding.
133        *
134        * \see textEncoding()
135        * \see render()
136        */
137       void setTextEncoding(String::Type encoding);
138
139       /*!
140        * Comments each have a unique description.  This searches for a comment
141        * frame with the decription \a d and returns a pointer to it.  If no
142        * frame is found that matches the given description null is returned.
143        *
144        * \see description()
145        */
146       static CommentsFrame *findByDescription(const Tag *tag, const String &d);
147
148     protected:
149       // Reimplementations.
150
151       virtual void parseFields(const ByteVector &data);
152       virtual ByteVector renderFields() const;
153
154     private:
155       /*!
156        * The constructor used by the FrameFactory.
157        */
158       CommentsFrame(const ByteVector &data, Header *h);
159       CommentsFrame(const CommentsFrame &);
160       CommentsFrame &operator=(const CommentsFrame &);
161
162       class CommentsFramePrivate;
163       CommentsFramePrivate *d;
164     };
165
166   }
167 }
168 #endif