00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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;
00102 size_t _data_size;
00103 ID3_Flags _flags;
00104 const Info* _info;
00105 bool _changed;
00106 }
00107 ;
00108
00109 #endif