id3lib 3.8.3
|
00001 // -*- C++ -*- 00002 // $Id: header_tag.h,v 1.2 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_TAG_H_ 00030 #define _ID3LIB_HEADER_TAG_H_ 00031 00032 #include "header.h" 00033 00034 class ID3_TagHeader : public ID3_Header 00035 { 00036 public: 00037 00038 enum 00039 { 00040 HEADER_FLAG_UNSYNC = 1 << 7, 00041 HEADER_FLAG_EXTENDED = 1 << 6, 00042 HEADER_FLAG_EXPERIMENTAL = 1 << 5, 00043 HEADER_FLAG_FOOTER = 1 << 4 00044 }; 00045 00046 enum 00047 { 00048 EXT_HEADER_FLAG_BIT1 = 1 << 7, 00049 EXT_HEADER_FLAG_BIT2 = 1 << 6, 00050 EXT_HEADER_FLAG_BIT3 = 1 << 5, 00051 EXT_HEADER_FLAG_BIT4 = 1 << 4 00052 }; 00053 00054 ID3_TagHeader() : ID3_Header() { ; } 00055 virtual ~ID3_TagHeader() { ; } 00056 ID3_TagHeader(const ID3_TagHeader& rhs) : ID3_Header() { *this = rhs; } 00057 00058 bool SetSpec(ID3_V2Spec); 00059 size_t Size() const; 00060 void Render(ID3_Writer&) const; 00061 bool Parse(ID3_Reader&); 00062 void ParseExtended(ID3_Reader&); 00063 ID3_TagHeader& operator=(const ID3_TagHeader&hdr) 00064 { this->ID3_Header::operator=(hdr); return *this; } 00065 00066 bool SetUnsync(bool b) 00067 { 00068 bool changed = _flags.set(HEADER_FLAG_UNSYNC, b); 00069 _changed = _changed || changed; 00070 return changed; 00071 } 00072 bool GetUnsync() const { return _flags.test(HEADER_FLAG_UNSYNC); } 00073 bool SetExtended(bool b) 00074 { 00075 bool changed = _flags.set(HEADER_FLAG_EXTENDED, b); 00076 _changed = _changed || changed; 00077 return changed; 00078 } 00079 bool GetExtended() const { return _flags.test(HEADER_FLAG_EXTENDED); } 00080 bool SetExperimental(bool b) 00081 { 00082 bool changed = _flags.set(HEADER_FLAG_EXPERIMENTAL, b); 00083 _changed = _changed || changed; 00084 return changed; 00085 } 00086 bool GetExperimental() const { return _flags.test(HEADER_FLAG_EXPERIMENTAL); } 00087 bool SetFooter(bool b) 00088 { 00089 bool changed = _flags.set(HEADER_FLAG_FOOTER, b); 00090 _changed = _changed || changed; 00091 return changed; 00092 } 00093 bool GetFooter() const { return _flags.test(HEADER_FLAG_FOOTER); } 00094 00095 // id3v2 tag header signature: $49 44 33 MM mm GG ss ss ss ss 00096 // MM = major version (will never be 0xFF) 00097 // mm = minor version (will never be 0xFF) 00098 // ff = flags byte 00099 // ss = size bytes (less than $80) 00100 static const char* const ID; 00101 enum 00102 { 00103 ID_SIZE = 3, 00104 MAJOR_OFFSET = 3, 00105 MINOR_OFFSET = 4, 00106 FLAGS_OFFSET = 5, 00107 SIZE_OFFSET = 6, 00108 SIZE = 10 // does not include extented headers 00109 }; 00110 00111 }; 00112 00113 #endif /* _ID3LIB_HEADER_TAG_H_ */