Go to the documentation of this file.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_TAG_IMPL_H_
00030 #define _ID3LIB_TAG_IMPL_H_
00031
00032 #include <list>
00033 #include <stdio.h>
00034 #include "tag.h"
00035 #include "header_tag.h"
00036 #include "mp3_header.h"
00037
00038 class ID3_Reader;
00039 class ID3_Writer;
00040
00041 namespace dami
00042 {
00043 namespace id3
00044 {
00045 namespace v1
00046 {
00047 bool parse(ID3_TagImpl&, ID3_Reader&);
00048 void render(ID3_Writer&, const ID3_TagImpl&);
00049 };
00050 namespace v2
00051 {
00052 bool parse(ID3_TagImpl& tag, ID3_Reader& rdr);
00053 void render(ID3_Writer& writer, const ID3_TagImpl& tag);
00054 };
00055 };
00056 namespace lyr3
00057 {
00058 namespace v1
00059 {
00060 bool parse(ID3_TagImpl&, ID3_Reader&);
00061 };
00062 namespace v2
00063 {
00064 bool parse(ID3_TagImpl&, ID3_Reader&);
00065 };
00066 };
00067 namespace mm
00068 {
00069 bool parse(ID3_TagImpl&, ID3_Reader&);
00070 };
00071 };
00072
00073 class ID3_TagImpl
00074 {
00075 typedef std::list<ID3_Frame *> Frames;
00076 public:
00077 typedef Frames::iterator iterator;
00078 typedef Frames::const_iterator const_iterator;
00079 public:
00080 ID3_TagImpl(const char *name = NULL);
00081 ID3_TagImpl(const ID3_Tag &tag);
00082 virtual ~ID3_TagImpl();
00083
00084 void Clear();
00085 bool HasChanged() const;
00086 void SetChanged(bool b) { _changed = b; }
00087 size_t Size() const;
00088
00089 bool SetUnsync(bool);
00090 bool SetExtended(bool);
00091 bool SetExperimental(bool);
00092 bool SetPadding(bool);
00093
00094 bool GetUnsync() const;
00095 bool GetExtended() const;
00096 bool GetExperimental() const;
00097 bool GetFooter() const;
00098
00099 size_t GetExtendedBytes() const;
00100
00101 void AddFrame(const ID3_Frame&);
00102 void AddFrame(const ID3_Frame*);
00103 bool AttachFrame(ID3_Frame*);
00104 ID3_Frame* RemoveFrame(const ID3_Frame *);
00105
00106 size_t Link(const char *fileInfo, flags_t = (flags_t) ID3TT_ALL);
00107 size_t Link(ID3_Reader &reader, flags_t = (flags_t) ID3TT_ALL);
00108 flags_t Update(flags_t = (flags_t) ID3TT_ALL);
00109 flags_t Strip(flags_t = (flags_t) ID3TT_ALL);
00110
00111 size_t GetPrependedBytes() const { return _prepended_bytes; }
00112 size_t GetAppendedBytes() const { return _appended_bytes; }
00113 size_t GetFileSize() const { return _file_size; }
00114 dami::String GetFileName() const { return _file_name; }
00115
00116 ID3_Frame* Find(ID3_FrameID id) const;
00117 ID3_Frame* Find(ID3_FrameID id, ID3_FieldID fld, uint32 data) const;
00118 ID3_Frame* Find(ID3_FrameID id, ID3_FieldID fld, dami::String) const;
00119 ID3_Frame* Find(ID3_FrameID id, ID3_FieldID fld, dami::WString) const;
00120
00121 size_t NumFrames() const { return _frames.size(); }
00122 ID3_TagImpl& operator=( const ID3_Tag & );
00123
00124 bool HasTagType(ID3_TagType tt) const { return _file_tags.test(tt); }
00125 ID3_V2Spec GetSpec() const;
00126 bool SetSpec(ID3_V2Spec);
00127
00128 static size_t IsV2Tag(ID3_Reader&);
00129
00130 const Mp3_Headerinfo* GetMp3HeaderInfo() const { if (_mp3_info) return _mp3_info->GetMp3HeaderInfo(); else return NULL; }
00131
00132 iterator begin() { return _frames.begin(); }
00133 iterator end() { return _frames.end(); }
00134 const_iterator begin() const { return _frames.begin(); }
00135 const_iterator end() const { return _frames.end(); }
00136
00137
00138 void AddNewFrame(ID3_Frame* f) { this->AttachFrame(f); }
00139 size_t Link(const char *fileInfo, bool parseID3v1, bool parseLyrics3);
00140 void SetCompression(bool) { ; }
00141 void AddFrames(const ID3_Frame *, size_t);
00142 bool HasLyrics() const { return this->HasTagType(ID3TT_LYRICS); }
00143 bool HasV2Tag() const { return this->HasTagType(ID3TT_ID3V2); }
00144 bool HasV1Tag() const { return this->HasTagType(ID3TT_ID3V1); }
00145 size_t PaddingSize(size_t) const;
00146
00147 protected:
00148 const_iterator Find(const ID3_Frame *) const;
00149 iterator Find(const ID3_Frame *);
00150
00151 void RenderExtHeader(uchar *);
00152
00153 void ParseFile();
00154 void ParseReader(ID3_Reader &reader);
00155
00156 private:
00157 ID3_TagHeader _hdr;
00158 bool _is_padded;
00159
00160 Frames _frames;
00161
00162 mutable const_iterator _cursor;
00163 mutable bool _changed;
00164
00165
00166 dami::String _file_name;
00167 size_t _file_size;
00168 size_t _prepended_bytes;
00169 size_t _appended_bytes;
00170 bool _is_file_writable;
00171 ID3_Flags _tags_to_parse;
00172 ID3_Flags _file_tags;
00173 Mp3Info *_mp3_info;
00174 };
00175
00176 size_t ID3_GetDataSize(const ID3_TagImpl&);
00177
00178 #endif
00179