src/frame_impl.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: frame_impl.h,v 1.6 2002/08/10 10:50:31 t1mpy Exp $
00003 
00004 // id3lib: a C++ library for creating and manipulating id3v1/v2 tags
00005 // Copyright 1999, 2000  Scott Thomas Haug
00006 // Copyright 2002 Thijmen Klok (thijmen@id3lib.org)
00007 
00008 // This library is free software; you can redistribute it and/or modify it
00009 // under the terms of the GNU Library General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or (at your
00011 // option) any later version.
00012 //
00013 // This library is distributed in the hope that it will be useful, but WITHOUT
00014 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00015 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00016 // License for more details.
00017 //
00018 // You should have received a copy of the GNU Library General Public License
00019 // along with this library; if not, write to the Free Software Foundation,
00020 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00021 
00022 // The id3lib authors encourage improvements and optimisations to be sent to
00023 // the id3lib coordinator.  Please see the README file for details on where to
00024 // send such submissions.  See the AUTHORS file for a list of people who have
00025 // contributed to id3lib.  See the ChangeLog file for a list of changes to
00026 // id3lib.  These files are distributed with id3lib at
00027 // http://download.sourceforge.net/id3lib/
00028 
00029 #ifndef _ID3LIB_FRAME_IMPL_H_
00030 #define _ID3LIB_FRAME_IMPL_H_
00031 
00032 #include <vector>
00033 #ifndef HAVE_BITSET
00034 #include "id3/id3lib_bitset"
00035 #else
00036 #include <bitset>
00037 #endif
00038 #include "id3/id3lib_frame.h"
00039 #include "header_frame.h"
00040 
00041 class ID3_FrameImpl
00042 {
00043   typedef std::bitset<ID3FN_LASTFIELDID> Bitset;
00044   typedef std::vector<ID3_Field *> Fields;
00045 public:
00046   typedef Fields::iterator iterator;
00047   typedef Fields::const_iterator const_iterator;
00048 public:
00049   ID3_FrameImpl(ID3_FrameID id = ID3FID_NOFRAME);
00050   ID3_FrameImpl(const ID3_FrameHeader&);
00051   ID3_FrameImpl(const ID3_Frame&);
00052 
00054   virtual ~ID3_FrameImpl();
00055   
00056   void        Clear();
00057 
00058   bool        SetID(ID3_FrameID id);
00059   ID3_FrameID GetID() const { return _hdr.GetFrameID(); }
00060   
00061   ID3_Field*  GetField(ID3_FieldID name) const;
00062 
00063   size_t      NumFields() const;
00064   
00065   const char* GetDescription() const;
00066   static const char* GetDescription(ID3_FrameID);
00067 
00068   const char* GetTextID() const { return _hdr.GetTextID(); }
00069 
00070   ID3_FrameImpl&  operator=(const ID3_Frame &);
00071   bool        HasChanged() const;
00072   bool        Parse(ID3_Reader&);
00073   void        Render(ID3_Writer&) const;
00074   size_t      Size();
00075   bool        Contains(ID3_FieldID fld) const
00076   { return _bitset.test(fld); }
00077   bool        SetSpec(ID3_V2Spec);
00078   ID3_V2Spec  GetSpec() const;
00079 
00085   bool        SetCompression(bool b)  { return _hdr.SetCompression(b); }
00094   bool        GetCompression() const  { return _hdr.GetCompression(); }
00095   size_t      GetDataSize() const { return _hdr.GetDataSize(); }
00096 
00097   bool SetEncryptionID(uchar id)
00098   {
00099     bool changed = id != _encryption_id;
00100     _encryption_id = id;
00101     _changed = _changed || changed;
00102     _hdr.SetEncryption(true);
00103     return changed;
00104   }
00105   uchar GetEncryptionID() const { return _encryption_id; }
00106   bool SetGroupingID(uchar id)
00107   {
00108     bool changed = id != _grouping_id;
00109     _grouping_id = id;
00110     _changed = _changed || changed;
00111     _hdr.SetGrouping(true);
00112     return changed;
00113   }
00114   uchar GetGroupingID() const { return _grouping_id; }
00115 
00116   iterator         begin()       { return _fields.begin(); }
00117   iterator         end()         { return _fields.end(); }
00118   const_iterator   begin() const { return _fields.begin(); }
00119   const_iterator   end()   const { return _fields.end(); }
00120   
00121 protected:
00122   bool        _SetID(ID3_FrameID);
00123   bool        _ClearFields();
00124   void        _InitFields();
00125   void        _InitFieldBits();
00126   void        _UpdateFieldDeps();
00127 
00128 private:
00129   mutable bool        _changed;    // frame changed since last parse/render?
00130   Bitset      _bitset;             // which fields are present?
00131   Fields      _fields;
00132   ID3_FrameHeader _hdr;            // 
00133   uchar       _encryption_id;      // encryption id
00134   uchar       _grouping_id;        // grouping id
00135 }
00136 ;
00137 
00138 #endif /* _ID3LIB_FRAME_IMPL_H_ */

Generated on Mon Aug 20 17:48:46 2007 for id3lib by  doxygen 1.5.2