id3lib
3.8.3
|
00001 // -*- C++ -*- 00002 // $Id: tag.h,v 1.63 2003/03/02 13:35:59 t1mpy Exp $ 00003 00004 // id3lib: a software 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_TAG_H_ 00030 #define _ID3LIB_TAG_H_ 00031 00032 #include <id3/id3lib_frame.h> 00033 #include <id3/field.h> 00034 #include <id3/utils.h>//for ID3_PATH_LENGTH 00035 00036 class ID3_Reader; 00037 class ID3_Writer; 00038 class ID3_TagImpl; 00039 class ID3_Tag; 00040 00041 class ID3_CPP_EXPORT ID3_Tag 00042 { 00043 ID3_TagImpl* _impl; 00044 char _tmp_filename[ID3_PATH_LENGTH]; 00045 public: 00046 00047 class Iterator 00048 { 00049 public: 00050 virtual ID3_Frame* GetNext() = 0; 00051 }; 00052 00053 class ConstIterator 00054 { 00055 public: 00056 virtual const ID3_Frame* GetNext() = 0; 00057 }; 00058 00059 public: 00060 00061 ID3_Tag(const char *name = NULL); 00062 ID3_Tag(const ID3_Tag &tag); 00063 virtual ~ID3_Tag(); 00064 00065 void Clear(); 00066 bool HasChanged() const; 00067 size_t Size() const; 00068 00069 bool SetUnsync(bool); 00070 bool SetExtendedHeader(bool); 00071 bool SetExperimental(bool); 00072 00073 bool GetUnsync() const; 00074 bool GetExtendedHeader() const; 00075 bool GetExperimental() const; 00076 00077 bool SetPadding(bool); 00078 00079 void AddFrame(const ID3_Frame&); 00080 void AddFrame(const ID3_Frame*); 00081 bool AttachFrame(ID3_Frame*); 00082 ID3_Frame* RemoveFrame(const ID3_Frame *); 00083 00084 size_t Parse(const uchar*, size_t); 00085 bool Parse(ID3_Reader& reader); 00086 size_t Render(uchar*, ID3_TagType = ID3TT_ID3V2) const; 00087 size_t Render(ID3_Writer&, ID3_TagType = ID3TT_ID3V2) const; 00088 00089 size_t Link(const char *fileInfo, flags_t = (flags_t) ID3TT_ALL); 00090 size_t Link(ID3_Reader &reader, flags_t = (flags_t) ID3TT_ALL); 00091 flags_t Update(flags_t = (flags_t) ID3TT_ALL); 00092 flags_t Strip(flags_t = (flags_t) ID3TT_ALL); 00093 00094 size_t GetPrependedBytes() const; 00095 size_t GetAppendedBytes() const; 00096 size_t GetFileSize() const; 00097 const char* GetFileName() const; 00098 00099 ID3_Frame* Find(ID3_FrameID) const; 00100 ID3_Frame* Find(ID3_FrameID, ID3_FieldID, uint32) const; 00101 ID3_Frame* Find(ID3_FrameID, ID3_FieldID, const char*) const; 00102 ID3_Frame* Find(ID3_FrameID, ID3_FieldID, const unicode_t*) const; 00103 00104 size_t NumFrames() const; 00105 00106 const Mp3_Headerinfo* GetMp3HeaderInfo() const; 00107 00108 Iterator* CreateIterator(); 00109 ConstIterator* CreateIterator() const; 00110 00111 ID3_Tag& operator=( const ID3_Tag & ); 00112 00113 bool HasTagType(ID3_TagType tt) const; 00114 ID3_V2Spec GetSpec() const; 00115 bool SetSpec(ID3_V2Spec); 00116 00117 static size_t IsV2Tag(const uchar*); 00118 static size_t IsV2Tag(ID3_Reader&); 00119 00120 /* Deprecated! */ 00121 void AddNewFrame(ID3_Frame* f); 00122 size_t Link(const char *fileInfo, bool parseID3v1, bool parseLyrics3); 00123 void SetCompression(bool); 00124 void AddFrames(const ID3_Frame *, size_t); 00125 bool HasLyrics() const; 00126 bool HasV2Tag() const; 00127 bool HasV1Tag() const; 00128 size_t Parse(const uchar header[ID3_TAGHEADERSIZE], const uchar *buffer); 00129 //ID3_Frame* operator[](size_t) const; 00130 //ID3_Frame* GetFrameNum(size_t) const; 00131 00132 ID3_Tag& operator<<(const ID3_Frame &); 00133 ID3_Tag& operator<<(const ID3_Frame *); 00134 }; 00135 00136 // deprecated! 00137 int32 ID3_C_EXPORT ID3_IsTagHeader(const uchar header[ID3_TAGHEADERSIZE]); 00138 00139 00140 #endif /* _ID3LIB_TAG_H_ */ 00141