id3lib 3.8.3
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
51
62ID3_Frame::ID3_Frame(ID3_FrameID id)
63 : _impl(new ID3_FrameImpl(id))
64{
65}
66
67ID3_Frame::ID3_Frame(const ID3_Frame& frame)
68 : _impl(new ID3_FrameImpl(frame))
69{
70}
71
72ID3_Frame::~ID3_Frame()
73{
74 delete _impl;
75}
76
82void ID3_Frame::Clear()
83{
84 _impl->Clear();
85}
86
94ID3_FrameID ID3_Frame::GetID() const
95{
96 return _impl->GetID();
97}
98
116bool ID3_Frame::SetID(ID3_FrameID id)
117{
118 return _impl->SetID(id);
119}
120
121bool ID3_Frame::SetSpec(ID3_V2Spec spec)
122{
123 return _impl->SetSpec(spec);
124}
125
126ID3_V2Spec ID3_Frame::GetSpec() const
127{
128 return _impl->GetSpec();
129}
130
142ID3_Field& ID3_Frame::Field(ID3_FieldID fieldName) const
143{
144 return *this->GetField(fieldName);
145}
146
147ID3_Field* ID3_Frame::GetField(ID3_FieldID fieldName) const
148{
149 return _impl->GetField(fieldName);
150}
151
152size_t ID3_Frame::NumFields() const
153{
154 return _impl->NumFields();
155}
156
157/*
158ID3_Field* ID3_Frame::GetFieldNum(size_t index) const
159{
160 return _impl->GetFieldNum(index);
161}
162*/
163
164size_t ID3_Frame::Size()
165{
166 return _impl->Size();
167}
168
169
170bool ID3_Frame::HasChanged() const
171{
172 return _impl->HasChanged();
173}
174
175ID3_Frame& ID3_Frame::operator=( const ID3_Frame &rFrame )
176{
177 if (this != &rFrame)
178 {
179 *_impl = rFrame;
180 }
181 return *this;
182}
183
184const char* ID3_Frame::GetDescription(ID3_FrameID id)
185{
187}
188
189const char* ID3_Frame::GetDescription() const
190{
191 return _impl->GetDescription();
192}
193
194const char* ID3_Frame::GetTextID() const
195{
196 return _impl->GetTextID();
197}
198
199bool ID3_Frame::Parse(ID3_Reader& reader)
200{
201 return _impl->Parse(reader);
202}
203
204void ID3_Frame::Render(ID3_Writer& writer) const
205{
206 _impl->Render(writer);
207}
208
209bool ID3_Frame::Contains(ID3_FieldID id) const
210{
211 return _impl->Contains(id);
212}
213
219bool ID3_Frame::SetCompression(bool b)
220{
221 return _impl->SetCompression(b);
222}
223
232bool ID3_Frame::GetCompression() const
233{
234 return _impl->GetCompression();
235}
236
237size_t ID3_Frame::GetDataSize() const
238{
239 return _impl->GetDataSize();
240}
241
242bool ID3_Frame::SetEncryptionID(uchar id)
243{
244 return _impl->SetEncryptionID(id);
245}
246
247uchar ID3_Frame::GetEncryptionID() const
248{
249 return _impl->GetEncryptionID();
250}
251
252bool ID3_Frame::SetGroupingID(uchar id)
253{
254 return _impl->SetGroupingID(id);
255}
256
257uchar ID3_Frame::GetGroupingID() const
258{
259 return _impl->GetGroupingID();
260}
261
262namespace
263{
264 class IteratorImpl : public ID3_Frame::Iterator
265 {
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 {
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
309ID3_Frame::Iterator*
310ID3_Frame::CreateIterator()
311{
312 return new IteratorImpl(*_impl);
313}
314
315ID3_Frame::ConstIterator*
316ID3_Frame::CreateIterator() const
317{
318 return new ConstIteratorImpl(*_impl);
319}
320
The representative class of an ID3v2 field.
Definition field.h:37
virtual size_t Size() const =0
Returns the size of a field.
The representative class of an id3v2 frame.
Fields::iterator iterator
Definition frame_impl.h:46
const char * GetDescription() const
Fields::const_iterator const_iterator
Definition frame_impl.h:47
#define NULL
Definition globals.h:743
ID3_FieldID
Enumeration of the different types of fields in a frame.
Definition globals.h:198
ID3_V2Spec
Definition globals.h:162
unsigned char uchar
Definition globals.h:114
ID3_FrameID
Enumeration of the different types of frames recognized by id3lib.
Definition globals.h:230