id3lib 3.8.3

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

frame.cpp
Go to the documentation of this file.
1 // $Id: frame.cpp,v 1.35 2002/08/10 10:42:42 t1mpy Exp $
2
3 // id3lib: a C++ library for creating and manipulating id3v1/v2 tags
4 // Copyright 1999, 2000 Scott Thomas Haug
5 // Copyright 2002 Thijmen Klok (thijmen@id3lib.org)
6
7 // This library is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU Library General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or (at your
10 // option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU Library General Public License
18 // along with this library; if not, write to the Free Software Foundation,
19 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
21 // The id3lib authors encourage improvements and optimisations to be sent to
22 // the id3lib coordinator. Please see the README file for details on where to
23 // send such submissions. See the AUTHORS file for a list of people who have
24 // contributed to id3lib. See the ChangeLog file for a list of changes to
25 // id3lib. These files are distributed with id3lib at
26 // http://download.sourceforge.net/id3lib/
27
28 #if defined HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31
32 //#include "frame.h"
33 #include "readers.h"
34 #include "frame_impl.h"
35
62 ID3_Frame::ID3_Frame(ID3_FrameID id)
63 : _impl(new ID3_FrameImpl(id))
64 {
65 }
66
67 ID3_Frame::ID3_Frame(const ID3_Frame& frame)
68 : _impl(new ID3_FrameImpl(frame))
69 {
70 }
71
72 ID3_Frame::~ID3_Frame()
73 {
74 delete _impl;
75 }
76
82 void ID3_Frame::Clear()
83 {
84 _impl->Clear();
85 }
86
94 ID3_FrameID ID3_Frame::GetID() const
95 {
96 return _impl->GetID();
97 }
98
116 bool ID3_Frame::SetID(ID3_FrameID id)
117 {
118 return _impl->SetID(id);
119 }
120
121 bool ID3_Frame::SetSpec(ID3_V2Spec spec)
122 {
123 return _impl->SetSpec(spec);
124 }
125
126 ID3_V2Spec ID3_Frame::GetSpec() const
127 {
128 return _impl->GetSpec();
129 }
130
142 ID3_Field& ID3_Frame::Field(ID3_FieldID fieldName) const
143 {
144 return *this->GetField(fieldName);
145 }
146
147 ID3_Field* ID3_Frame::GetField(ID3_FieldID fieldName) const
148 {
149 return _impl->GetField(fieldName);
150 }
151
152 size_t ID3_Frame::NumFields() const
153 {
154 return _impl->NumFields();
155 }
156
157 /*
158 ID3_Field* ID3_Frame::GetFieldNum(size_t index) const
159 {
160 return _impl->GetFieldNum(index);
161 }
162 */
163
164 size_t ID3_Frame::Size()
165 {
166 return _impl->Size();
167 }
168
169
170 bool ID3_Frame::HasChanged() const
171 {
172 return _impl->HasChanged();
173 }
174
175 ID3_Frame& ID3_Frame::operator=( const ID3_Frame &rFrame )
176 {
177 if (this != &rFrame)
178 {
179 *_impl = rFrame;
180 }
181 return *this;
182 }
183
184 const char* ID3_Frame::GetDescription(ID3_FrameID id)
185 {
186 return ID3_FrameImpl::GetDescription(id);
187 }
188
189 const char* ID3_Frame::GetDescription() const
190 {
191 return _impl->GetDescription();
192 }
193
194 const char* ID3_Frame::GetTextID() const
195 {
196 return _impl->GetTextID();
197 }
198
199 bool ID3_Frame::Parse(ID3_Reader& reader)
200 {
201 return _impl->Parse(reader);
202 }
203
204 void ID3_Frame::Render(ID3_Writer& writer) const
205 {
206 _impl->Render(writer);
207 }
208
209 bool ID3_Frame::Contains(ID3_FieldID id) const
210 {
211 return _impl->Contains(id);
212 }
213
219 bool ID3_Frame::SetCompression(bool b)
220 {
221 return _impl->SetCompression(b);
222 }
223
232 bool ID3_Frame::GetCompression() const
233 {
234 return _impl->GetCompression();
235 }
236
237 size_t ID3_Frame::GetDataSize() const
238 {
239 return _impl->GetDataSize();
240 }
241
242 bool ID3_Frame::SetEncryptionID(uchar id)
243 {
244 return _impl->SetEncryptionID(id);
245 }
246
247 uchar ID3_Frame::GetEncryptionID() const
248 {
249 return _impl->GetEncryptionID();
250 }
251
252 bool ID3_Frame::SetGroupingID(uchar id)
253 {
254 return _impl->SetGroupingID(id);
255 }
256
257 uchar ID3_Frame::GetGroupingID() const
258 {
259 return _impl->GetGroupingID();
260 }
261
262 namespace
263 {
264 class IteratorImpl : public ID3_Frame::Iterator
265 {
266 ID3_FrameImpl::iterator _cur;
267 ID3_FrameImpl::iterator _end;
268 public:
269 IteratorImpl(ID3_FrameImpl& frame)
270 : _cur(frame.begin()), _end(frame.end())
271 {
272 }
273
274 ID3_Field* GetNext()
275 {
276 ID3_Field* next = NULL;
277 while (next == NULL && _cur != _end)
278 {
279 next = *_cur;
280 ++_cur;
281 }
282 return next;
283 }
284 };
285
286
287 class ConstIteratorImpl : public ID3_Frame::ConstIterator
288 {
289 ID3_FrameImpl::const_iterator _cur;
290 ID3_FrameImpl::const_iterator _end;
291 public:
292 ConstIteratorImpl(ID3_FrameImpl& frame)
293 : _cur(frame.begin()), _end(frame.end())
294 {
295 }
296 const ID3_Field* GetNext()
297 {
298 ID3_Field* next = NULL;
299 while (next == NULL && _cur != _end)
300 {
301 next = *_cur;
302 ++_cur;
303 }
304 return next;
305 }
306 };
307 }
308
309 ID3_Frame::Iterator*
310 ID3_Frame::CreateIterator()
311 {
312 return new IteratorImpl(*_impl);
313 }
314
315 ID3_Frame::ConstIterator*
316 ID3_Frame::CreateIterator() const
317 {
318 return new ConstIteratorImpl(*_impl);
319 }
320
ID3_Frame::Contains
bool Contains(ID3_FieldID fld) const
Definition: frame.cpp:209
ID3_FrameImpl::GetCompression
bool GetCompression() const
Returns whether or not the compression flag is set.
Definition: frame_impl.h:94
ID3_FrameImpl::GetGroupingID
uchar GetGroupingID() const
Definition: frame_impl.h:114
ID3_FrameImpl::GetEncryptionID
uchar GetEncryptionID() const
Definition: frame_impl.h:105
ID3_FrameImpl::GetTextID
const char * GetTextID() const
Definition: frame_impl.h:68
ID3_FrameImpl::NumFields
size_t NumFields() const
Definition: frame_impl.cpp:167
ID3_FrameImpl::iterator
Fields::iterator iterator
Definition: frame_impl.h:46
ID3_FrameImpl::GetDataSize
size_t GetDataSize() const
Definition: frame_impl.h:95
ID3_Frame::GetTextID
const char * GetTextID() const
Definition: frame.cpp:194
ID3_FrameImpl
Definition: frame_impl.h:41
ID3_Frame::NumFields
size_t NumFields() const
Definition: frame.cpp:152
ID3_FrameImpl::SetEncryptionID
bool SetEncryptionID(uchar id)
Definition: frame_impl.h:97
ID3_Frame::GetField
ID3_Field * GetField(ID3_FieldID name) const
Definition: frame.cpp:147
ID3_Frame::Field
ID3_Field & Field(ID3_FieldID name) const
Returns a pointer to the frame&#39;s internal field indicated by the parameter.
Definition: frame.cpp:142
ID3_Frame::Iterator::GetNext
virtual ID3_Field * GetNext()=0
ID3_Frame::operator=
ID3_Frame & operator=(const ID3_Frame &)
Definition: frame.cpp:175
ID3_Frame::GetID
ID3_FrameID GetID() const
Returns the type of frame that the object represents.
Definition: frame.cpp:94
ID3_Frame::Clear
void Clear()
Clears the frame of all data and resets the frame such that it can take on the form of any id3v2 fram...
Definition: frame.cpp:82
ID3_FrameID
ID3_FrameID
Enumeration of the different types of frames recognized by id3lib.
Definition: globals.h:229
uchar
unsigned char uchar
Definition: globals.h:114
ID3_Frame::GetGroupingID
uchar GetGroupingID() const
Definition: frame.cpp:257
ID3_FrameImpl::SetGroupingID
bool SetGroupingID(uchar id)
Definition: frame_impl.h:106
ID3_Frame::SetCompression
bool SetCompression(bool b)
Sets the compression flag within the frame.
Definition: frame.cpp:219
ID3_Frame::GetSpec
ID3_V2Spec GetSpec() const
Definition: frame.cpp:126
ID3_Frame::ID3_Frame
ID3_Frame(ID3_FrameID id=ID3FID_NOFRAME)
Default constructor; accepts as a default parameter the type of frame to create.
Definition: frame.cpp:62
ID3_Frame::Size
size_t Size()
Definition: frame.cpp:164
ID3_Frame::Iterator
Definition: id3lib_frame.h:43
ID3_FrameImpl::SetID
bool SetID(ID3_FrameID id)
Definition: frame_impl.cpp:121
ID3_Reader
Definition: reader.h:33
ID3_Frame::SetSpec
bool SetSpec(ID3_V2Spec)
Definition: frame.cpp:121
ID3_FrameImpl::GetID
ID3_FrameID GetID() const
Definition: frame_impl.h:59
ID3_V2Spec
ID3_V2Spec
Definition: globals.h:161
ID3_FrameImpl::HasChanged
bool HasChanged() const
Definition: frame_impl.cpp:207
ID3_Frame::HasChanged
bool HasChanged() const
Definition: frame.cpp:170
ID3_FrameImpl::Clear
void Clear()
Definition: frame_impl.cpp:89
ID3_Frame::~ID3_Frame
virtual ~ID3_Frame()
Definition: frame.cpp:72
ID3_Frame::CreateIterator
Iterator * CreateIterator()
Definition: frame.cpp:310
ID3_Frame
The representative class of an id3v2 frame.
Definition: id3lib_frame.h:38
ID3_FrameImpl::GetDescription
const char * GetDescription() const
Definition: frame_impl.cpp:258
frame_impl.h
ID3_Frame::SetID
bool SetID(ID3_FrameID id)
Establishes the internal structure of an ID3_FrameImpl object so that it represents the id3v2 frame i...
Definition: frame.cpp:116
ID3_Frame::Parse
bool Parse(ID3_Reader &)
Definition: frame.cpp:199
ID3_FrameImpl::Parse
bool Parse(ID3_Reader &)
Definition: frame_parse.cpp:109
ID3_FrameImpl::SetSpec
bool SetSpec(ID3_V2Spec)
Definition: frame_impl.cpp:140
ID3_Frame::GetCompression
bool GetCompression() const
Returns whether or not the compression flag is set.
Definition: frame.cpp:232
ID3_Frame::SetEncryptionID
bool SetEncryptionID(uchar id)
Definition: frame.cpp:242
NULL
#define NULL
Definition: globals.h:743
ID3_FrameImpl::const_iterator
Fields::const_iterator const_iterator
Definition: frame_impl.h:47
ID3_Field
The representative class of an ID3v2 field.
Definition: field.h:36
ID3_Writer
Definition: writer.h:33
ID3_Frame::ConstIterator::GetNext
virtual const ID3_Field * GetNext()=0
readers.h
ID3_Frame::GetEncryptionID
uchar GetEncryptionID() const
Definition: frame.cpp:247
ID3_FrameImpl::SetCompression
bool SetCompression(bool b)
Sets the compression flag within the frame.
Definition: frame_impl.h:85
ID3_Frame::GetDataSize
size_t GetDataSize() const
Definition: frame.cpp:237
ID3_FrameImpl::Size
size_t Size()
Definition: frame_impl.cpp:172
ID3_FrameImpl::GetSpec
ID3_V2Spec GetSpec() const
Definition: frame_impl.cpp:145
ID3_FrameImpl::Contains
bool Contains(ID3_FieldID fld) const
Definition: frame_impl.h:75
ID3_Frame::GetDescription
const char * GetDescription() const
Definition: frame.cpp:189
ID3_FrameImpl::Render
void Render(ID3_Writer &) const
Definition: frame_render.cpp:71
ID3_Frame::SetGroupingID
bool SetGroupingID(uchar id)
Definition: frame.cpp:252
ID3_Frame::Render
void Render(ID3_Writer &) const
Definition: frame.cpp:204
ID3_FieldID
ID3_FieldID
Enumeration of the different types of fields in a frame.
Definition: globals.h:197
ID3_FrameImpl::GetField
ID3_Field * GetField(ID3_FieldID name) const
Definition: frame_impl.cpp:150
ID3_Frame::ConstIterator
Definition: id3lib_frame.h:49