00001 // -*- C++ -*- 00002 // $Id: header.h,v 1.1 2000/10/24 16:13:52 eldamitri Exp $ 00003 00004 // id3lib: a C++ library for creating and manipulating id3v1/v2 tags 00005 // Copyright 1999, 2000 Scott Thomas Haug 00006 00007 // This library is free software; you can redistribute it and/or modify it 00008 // under the terms of the GNU Library General Public License as published by 00009 // the Free Software Foundation; either version 2 of the License, or (at your 00010 // option) any later version. 00011 // 00012 // This library is distributed in the hope that it will be useful, but WITHOUT 00013 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00014 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00015 // License for more details. 00016 // 00017 // You should have received a copy of the GNU Library General Public License 00018 // along with this library; if not, write to the Free Software Foundation, 00019 // Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00020 00021 // The id3lib authors encourage improvements and optimisations to be sent to 00022 // the id3lib coordinator. Please see the README file for details on where to 00023 // send such submissions. See the AUTHORS file for a list of people who have 00024 // contributed to id3lib. See the ChangeLog file for a list of changes to 00025 // id3lib. These files are distributed with id3lib at 00026 // http://download.sourceforge.net/id3lib/ 00027 00028 #ifndef _ID3LIB_HEADER_H_ 00029 #define _ID3LIB_HEADER_H_ 00030 00031 #include "globals.h" 00032 #include "flags.h" 00033 00034 class ID3_Reader; 00035 class ID3_Writer; 00036 00037 class ID3_Header 00038 { 00039 public: 00040 struct Info 00041 { 00042 uchar frame_bytes_id; 00043 uchar frame_bytes_size; 00044 uchar frame_bytes_flags; 00045 bool is_extended; 00046 size_t extended_bytes; 00047 bool is_experimental; 00048 }; 00049 00050 ID3_Header() 00051 : _spec (ID3V2_UNKNOWN), 00052 _data_size (0), 00053 _changed (false) 00054 { 00055 this->Clear(); 00056 _changed = false; 00057 } 00058 virtual ~ID3_Header() { ; } 00059 00060 virtual bool SetSpec(ID3_V2Spec); 00061 /* */ ID3_V2Spec GetSpec() const { return _spec; } 00062 00063 /* */ bool SetDataSize(size_t size) 00064 { 00065 bool changed = size != _data_size; 00066 _changed = _changed || changed; 00067 _data_size = size; 00068 return changed; 00069 } 00070 /* */ size_t GetDataSize() const { return _data_size; } 00071 00072 virtual bool Clear() 00073 { 00074 bool changed = this->SetDataSize(0); 00075 if (this->GetSpec() == ID3V2_UNKNOWN) 00076 { 00077 this->SetSpec(ID3V2_LATEST); 00078 changed = true; 00079 } 00080 changed = _flags.clear() || changed; 00081 _changed = changed || _changed; 00082 return changed; 00083 } 00084 virtual size_t Size() const = 0; 00085 00086 virtual void Render(ID3_Writer&) const = 0; 00087 virtual bool Parse(ID3_Reader&) = 0; 00088 00089 ID3_Header &operator=( const ID3_Header &rhs) 00090 { 00091 if (this != &rhs) 00092 { 00093 this->SetSpec(rhs.GetSpec()); 00094 this->SetDataSize(rhs.GetSpec()); 00095 this->_flags = rhs._flags; 00096 } 00097 return *this; 00098 } 00099 00100 protected: 00101 ID3_V2Spec _spec; // which version of the spec 00102 size_t _data_size; // how big is the data? 00103 ID3_Flags _flags; // header flags 00104 const Info* _info; // header info w.r.t. id3v2 spec 00105 bool _changed; // has the header changed since parsing 00106 } 00107 ; 00108 00109 #endif /* _ID3LIB_HEADER_H */