src/header.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: header.h,v 1.3 2002/07/31 13:20:49 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_HEADER_H_
00030 #define _ID3LIB_HEADER_H_
00031 
00032 #include "id3/globals.h" //has <stdlib.h> "id3/sized_types.h"
00033 #include "flags.h"
00034 
00035 class ID3_Reader;
00036 class ID3_Writer;
00037 
00038 class ID3_Header
00039 {
00040 public:
00041   struct Info
00042   {
00043     uchar      frame_bytes_id;
00044     uchar      frame_bytes_size;
00045     uchar      frame_bytes_flags;
00046     bool       is_extended;
00047     size_t     extended_bytes; //including the extended header, so everything!
00048     bool       is_experimental;
00049   };
00050 
00051   ID3_Header() 
00052     : _spec (ID3V2_UNKNOWN),
00053       _data_size (0),
00054       _changed (false)
00055   { 
00056     this->Clear();
00057     _changed = false;
00058   }
00059   virtual ~ID3_Header() { ; }
00060   
00061   virtual bool       SetSpec(ID3_V2Spec);
00062   /*   */ ID3_V2Spec GetSpec() const { return _spec; }
00063 
00064   /*   */ bool       SetDataSize(size_t size)
00065   { 
00066     bool changed = size != _data_size; 
00067     _changed = _changed || changed;
00068     _data_size = size;
00069     return changed;
00070   }
00071   /*   */ size_t     GetDataSize() const { return _data_size; }
00072   
00073   virtual bool       Clear()
00074   {
00075     bool changed = this->SetDataSize(0);
00076     if (this->GetSpec() == ID3V2_UNKNOWN)
00077     {
00078       this->SetSpec(ID3V2_LATEST);
00079       changed = true;
00080     }
00081     changed = _flags.clear() || changed;
00082     _changed = changed || _changed;
00083     return changed;
00084   }
00085   virtual size_t     Size() const = 0;
00086   
00087   virtual void       Render(ID3_Writer&) const = 0;
00088   virtual bool       Parse(ID3_Reader&) = 0;
00089 
00090   ID3_Header &operator=( const ID3_Header &rhs)
00091   { 
00092     if (this != &rhs)
00093     { 
00094       this->SetSpec(rhs.GetSpec());
00095       this->SetDataSize(rhs.GetSpec());
00096       this->_flags = rhs._flags;
00097     }
00098     return *this;
00099   }
00100 
00101 protected:
00102   ID3_V2Spec      _spec;             // which version of the spec 
00103   size_t          _data_size;        // how big is the data?
00104   ID3_Flags       _flags;            // header flags
00105   Info*     _info;             // header info w.r.t. id3v2 spec
00106   bool            _changed;          // has the header changed since parsing
00107 }
00108 ;
00109 
00110 #endif /* _ID3LIB_HEADER_H */

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