Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

src/frame.cpp

Go to the documentation of this file.
00001 // $Id: frame.cpp,v 1.32 2000/10/24 07:00:08 eldamitri Exp $
00002 
00003 // id3lib: a C++ library for creating and manipulating id3v1/v2 tags
00004 // Copyright 1999, 2000  Scott Thomas Haug
00005 
00006 // This library is free software; you can redistribute it and/or modify it
00007 // under the terms of the GNU Library General Public License as published by
00008 // the Free Software Foundation; either version 2 of the License, or (at your
00009 // option) any later version.
00010 //
00011 // This library is distributed in the hope that it will be useful, but WITHOUT
00012 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00013 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00014 // License for more details.
00015 //
00016 // You should have received a copy of the GNU Library General Public License
00017 // along with this library; if not, write to the Free Software Foundation,
00018 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00019 
00020 // The id3lib authors encourage improvements and optimisations to be sent to
00021 // the id3lib coordinator.  Please see the README file for details on where to
00022 // send such submissions.  See the AUTHORS file for a list of people who have
00023 // contributed to id3lib.  See the ChangeLog file for a list of changes to
00024 // id3lib.  These files are distributed with id3lib at
00025 // http://download.sourceforge.net/id3lib/
00026 
00027 #if defined HAVE_CONFIG_H
00028 #include <config.h>
00029 #endif
00030 
00031 #include "frame.h"
00032 #include "readers.h"
00033 #include "frame_impl.h"
00034 
00061 ID3_Frame::ID3_Frame(ID3_FrameID id)
00062   : _impl(new ID3_FrameImpl(id))
00063 {
00064 }
00065 
00066 ID3_Frame::ID3_Frame(const ID3_Frame& frame)
00067   : _impl(new ID3_FrameImpl(frame))
00068 {
00069 }
00070 
00071 ID3_Frame::~ID3_Frame()
00072 {
00073   delete _impl;
00074 }
00075 
00081 void ID3_Frame::Clear()
00082 {
00083   _impl->Clear();
00084 }
00085 
00093 ID3_FrameID ID3_Frame::GetID() const
00094 {
00095   return _impl->GetID();
00096 }
00097 
00115 bool ID3_Frame::SetID(ID3_FrameID id)
00116 {
00117   return _impl->SetID(id);
00118 }
00119 
00120 bool ID3_Frame::SetSpec(ID3_V2Spec spec)
00121 {
00122   return _impl->SetSpec(spec);
00123 }
00124 
00125 ID3_V2Spec ID3_Frame::GetSpec() const
00126 {
00127   return _impl->GetSpec();
00128 }
00129 
00141 ID3_Field& ID3_Frame::Field(ID3_FieldID fieldName) const
00142 {
00143   return *this->GetField(fieldName);
00144 }
00145 
00146 ID3_Field* ID3_Frame::GetField(ID3_FieldID fieldName) const
00147 {
00148   return _impl->GetField(fieldName);
00149 }
00150 
00151 size_t ID3_Frame::NumFields() const
00152 {
00153   return _impl->NumFields();
00154 }
00155 
00156 /*
00157 ID3_Field* ID3_Frame::GetFieldNum(index_t index) const
00158 {
00159   return _impl->GetFieldNum(index);
00160 }
00161 */
00162 
00163 size_t ID3_Frame::Size()
00164 {
00165   return _impl->Size();
00166 }
00167 
00168 
00169 bool ID3_Frame::HasChanged() const
00170 {
00171   return _impl->HasChanged();
00172 }
00173 
00174 ID3_Frame& ID3_Frame::operator=( const ID3_Frame &rFrame )
00175 {
00176   if (this != &rFrame)
00177   {
00178     *_impl = rFrame;
00179   }
00180   return *this;
00181 }
00182 
00183 const char* ID3_Frame::GetDescription(ID3_FrameID id)
00184 {
00185   return ID3_FrameImpl::GetDescription(id);
00186 }
00187 
00188 const char* ID3_Frame::GetDescription() const
00189 {
00190   return _impl->GetDescription();
00191 }
00192 
00193 const char* ID3_Frame::GetTextID() const
00194 {
00195   return _impl->GetTextID();
00196 }
00197 
00198 bool ID3_Frame::Parse(ID3_Reader& reader) 
00199 {
00200   return _impl->Parse(reader);
00201 }
00202 
00203 void ID3_Frame::Render(ID3_Writer& writer) const
00204 {
00205   _impl->Render(writer);
00206 }
00207 
00208 bool ID3_Frame::Contains(ID3_FieldID id) const
00209 {
00210   return _impl->Contains(id);
00211 }
00212 
00218 bool ID3_Frame::SetCompression(bool b)
00219 {
00220   return _impl->SetCompression(b);
00221 }
00222 
00231 bool ID3_Frame::GetCompression() const
00232 {
00233   return _impl->GetCompression();
00234 }
00235 
00236 size_t ID3_Frame::GetDataSize() const
00237 {
00238   return _impl->GetDataSize();
00239 }
00240 
00241 bool ID3_Frame::SetEncryptionID(uchar id)
00242 {
00243   return _impl->SetEncryptionID(id);
00244 }
00245 
00246 uchar ID3_Frame::GetEncryptionID() const
00247 {
00248   return _impl->GetEncryptionID();
00249 }
00250 
00251 bool ID3_Frame::SetGroupingID(uchar id)
00252 {
00253   return _impl->SetGroupingID(id);
00254 }
00255 
00256 uchar ID3_Frame::GetGroupingID() const
00257 {
00258   return _impl->GetGroupingID();
00259 }
00260 
00261 namespace
00262 {
00263   class IteratorImpl : public ID3_Frame::Iterator
00264   {
00265     ID3_FrameImpl::iterator _cur;
00266     ID3_FrameImpl::iterator _end;
00267   public:
00268     IteratorImpl(ID3_FrameImpl& frame)
00269       : _cur(frame.begin()), _end(frame.end())
00270     {
00271     }
00272 
00273     ID3_Field* GetNext() 
00274     { 
00275       ID3_Field* next = NULL;
00276       while (next == NULL && _cur != _end)
00277       {
00278         next = *_cur;
00279         ++_cur;
00280       }
00281       return next;
00282     }
00283   };
00284 
00285   
00286   class ConstIteratorImpl : public ID3_Frame::ConstIterator
00287   {
00288     ID3_FrameImpl::const_iterator _cur;
00289     ID3_FrameImpl::const_iterator _end;
00290   public:
00291     ConstIteratorImpl(ID3_FrameImpl& frame)
00292       : _cur(frame.begin()), _end(frame.end())
00293     {
00294     }
00295     const ID3_Field* GetNext() 
00296     { 
00297       ID3_Field* next = NULL;
00298       while (next == NULL && _cur != _end)
00299       {
00300         next = *_cur;
00301         ++_cur;
00302       }
00303       return next;
00304     }
00305   };
00306 }
00307 
00308 ID3_Frame::Iterator* 
00309 ID3_Frame::CreateIterator()
00310 {
00311   return new IteratorImpl(*_impl);
00312 }
00313 
00314 ID3_Frame::ConstIterator* 
00315 ID3_Frame::CreateIterator() const
00316 {
00317   return new ConstIteratorImpl(*_impl);
00318 }

Generated at Sat Sep 8 15:51:08 2001 for id3lib by doxygen1.2.8 written by Dimitri van Heesch, © 1997-2001