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
63 : _impl(new ID3_FrameImpl(id))
64{
65}
66
68 : _impl(new ID3_FrameImpl(frame))
69{
70}
71
73{
74 delete _impl;
75}
76
83{
84 _impl->Clear();
85}
86
95{
96 return _impl->GetID();
97}
98
117{
118 return _impl->SetID(id);
119}
120
122{
123 return _impl->SetSpec(spec);
124}
125
127{
128 return _impl->GetSpec();
129}
130
143{
144 return *this->GetField(fieldName);
145}
146
148{
149 return _impl->GetField(fieldName);
150}
151
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
165{
166 return _impl->Size();
167}
168
169
171{
172 return _impl->HasChanged();
173}
174
176{
177 if (this != &rFrame)
178 {
179 *_impl = rFrame;
180 }
181 return *this;
182}
183
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
200{
201 return _impl->Parse(reader);
202}
203
204void ID3_Frame::Render(ID3_Writer& writer) const
205{
206 _impl->Render(writer);
207}
208
210{
211 return _impl->Contains(id);
212}
213
220{
221 return _impl->SetCompression(b);
222}
223
233{
234 return _impl->GetCompression();
235}
236
238{
239 return _impl->GetDataSize();
240}
241
243{
244 return _impl->SetEncryptionID(id);
245}
246
248{
249 return _impl->GetEncryptionID();
250}
251
253{
254 return _impl->SetGroupingID(id);
255}
256
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
311{
312 return new IteratorImpl(*_impl);
313}
314
317{
318 return new ConstIteratorImpl(*_impl);
319}
320
The representative class of an ID3v2 field.
Definition field.h:37
The representative class of an id3v2 frame.
bool Contains(ID3_FieldID fld) const
Definition frame.cpp:209
size_t Size()
Definition frame.cpp:164
ID3_FrameID GetID() const
Returns the type of frame that the object represents.
Definition frame.cpp:94
ID3_Field * GetField(ID3_FieldID name) const
Definition frame.cpp:147
ID3_Field & Field(ID3_FieldID name) const
Returns a pointer to the frame's internal field indicated by the parameter.
Definition frame.cpp:142
bool Parse(ID3_Reader &)
Definition frame.cpp:199
bool GetCompression() const
Returns whether or not the compression flag is set.
Definition frame.cpp:232
void Render(ID3_Writer &) const
Definition frame.cpp:204
uchar GetGroupingID() const
Definition frame.cpp:257
bool SetGroupingID(uchar id)
Definition frame.cpp:252
bool SetSpec(ID3_V2Spec)
Definition frame.cpp:121
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
bool HasChanged() const
Definition frame.cpp:170
ID3_Frame & operator=(const ID3_Frame &)
Definition frame.cpp:175
size_t GetDataSize() const
Definition frame.cpp:237
Iterator * CreateIterator()
Definition frame.cpp:310
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_Frame(ID3_FrameID id=ID3FID_NOFRAME)
Default constructor; accepts as a default parameter the type of frame to create.
Definition frame.cpp:62
ID3_V2Spec GetSpec() const
Definition frame.cpp:126
bool SetEncryptionID(uchar id)
Definition frame.cpp:242
virtual ~ID3_Frame()
Definition frame.cpp:72
bool SetCompression(bool b)
Sets the compression flag within the frame.
Definition frame.cpp:219
const char * GetDescription() const
Definition frame.cpp:189
const char * GetTextID() const
Definition frame.cpp:194
uchar GetEncryptionID() const
Definition frame.cpp:247
size_t NumFields() const
Definition frame.cpp:152
bool Parse(ID3_Reader &)
size_t GetDataSize() const
Definition frame_impl.h:95
ID3_FrameID GetID() const
Definition frame_impl.h:59
bool SetGroupingID(uchar id)
Definition frame_impl.h:106
bool HasChanged() const
uchar GetGroupingID() const
Definition frame_impl.h:114
bool GetCompression() const
Returns whether or not the compression flag is set.
Definition frame_impl.h:94
uchar GetEncryptionID() const
Definition frame_impl.h:105
bool SetSpec(ID3_V2Spec)
size_t NumFields() const
const char * GetTextID() const
Definition frame_impl.h:68
ID3_V2Spec GetSpec() const
bool SetCompression(bool b)
Sets the compression flag within the frame.
Definition frame_impl.h:85
Fields::iterator iterator
Definition frame_impl.h:46
void Render(ID3_Writer &) const
bool SetEncryptionID(uchar id)
Definition frame_impl.h:97
ID3_Field * GetField(ID3_FieldID name) const
const char * GetDescription() const
Fields::const_iterator const_iterator
Definition frame_impl.h:47
bool Contains(ID3_FieldID fld) const
Definition frame_impl.h:75
bool SetID(ID3_FrameID id)
#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

Generated for id3lib by doxygen 1.10.0