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
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;
00130 Bitset _bitset;
00131 Fields _fields;
00132 ID3_FrameHeader _hdr;
00133 uchar _encryption_id;
00134 uchar _grouping_id;
00135 }
00136 ;
00137
00138 #endif