⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tag.cpp

📁 更新mp3
💻 CPP
📖 第 1 页 / 共 3 页
字号:
size_t ID3_Tag::GetFileSize() const{  return _impl->GetFileSize();}const char* ID3_Tag::GetFileName() const{  //fix because GetFileName need to return a pointer which keeps to be valid  String fn = _impl->GetFileName();  if (fn.size())  {    memset((char *)_tmp_filename, 0, ID3_PATH_LENGTH);    memmove((char *)_tmp_filename, fn.c_str(), fn.size());    return _tmp_filename; //_impl->GetFileName().c_str();  }  else    return NULL;}/// Finds frame with given frame id  /** Returns a pointer to the next ID3_Frame with the given ID3_FrameID;   ** returns NULL if no such frame found.   **   ** If there are multiple frames in the tag with the same ID (which, for some   ** frames, is allowed), then subsequent calls to Find() will return   ** subsequent frame pointers, wrapping if necessary.   **   ** \code   **   ID3_Frame *myFrame;   **   if (myFrame = myTag.Find(ID3FID_TITLE))   **   {   **     // do something with the frame, like copy   **     // the contents into a buffer, display the   **     // contents in a window, etc.   **     // ...   **   }   ** \endcode   **   ** You may optionally supply to more parameters ot this method, being an   ** ID3_FieldID and a value of some sort.  Depending on the field name/ID you   ** supply, you may supply an integer, a char* or a unicode_t* as the third   ** parameter.  If you supply an ID3_FrameID, you must also supply a data   ** value to compare against.   **   ** This method will then return the first frame that has a matching frame   ** ID, and which has a field with the same name as that which you supplied   ** in the second parameter, whose calue matches that which you supplied as   ** the third parameter.  For example:   **   ** \code   **   ID3_Frame *myFrame;   **   if (myFrame = myTag.Find(ID3FID_TITLE, ID3FN_TEXT, "Nirvana"))   **   {   **     // found it, do something with it.   **     // ...   **   }   ** \endcode   **   ** This example will return the first TITLE frame and whose TEXT field is   ** 'Nirvana'.  Currently there is no provision for things like 'contains',   ** 'greater than', or 'less than'.  If there happens to be more than one of   ** these frames, subsequent calls to the Find() method will return   ** subsequent frames and will wrap around to the beginning.   **   ** Another example...   **   ** \code   **   ID3_Frame *myFrame;   **   if (myFrame = myTag.Find(ID3FID_COMMENT, ID3FN_TEXTENC, ID3TE_UNICODE))   **   {   **     // found it, do something with it.   **     // ...   **   }   ** \endcode   **   ** This returns the first COMMENT frame that uses Unicode as its text   ** encdoing.   **   ** @name   Find   ** @param  id The ID of the frame that is to be located   ** @return A pointer to the first frame found that has the given frame id,   **         or NULL if no such frame.   **/ID3_Frame* ID3_Tag::Find(ID3_FrameID id) const{  return _impl->Find(id);}/// Finds frame with given frame id, fld id, and integer dataID3_Frame* ID3_Tag::Find(ID3_FrameID id, ID3_FieldID fld, uint32 data) const{  return _impl->Find(id, fld, data);}/// Finds frame with given frame id, fld id, and ascii dataID3_Frame* ID3_Tag::Find(ID3_FrameID id, ID3_FieldID fld, const char* data) const{  String str(data);  return _impl->Find(id, fld, str);}/// Finds frame with given frame id, fld id, and unicode dataID3_Frame* ID3_Tag::Find(ID3_FrameID id, ID3_FieldID fld, const unicode_t* data) const{  WString str = toWString(data, ucslen(data));  return _impl->Find(id, fld, str);}/** Returns the number of frames present in the tag object. ** ** This includes only those frames that id3lib recognises.  This is used as ** the upper bound on calls to the GetFrame() and operator[]() methods. ** ** \return The number of frames present in the tag object. **/size_t ID3_Tag::NumFrames() const{  return _impl->NumFrames();}/** Returns a pointer to the frame with the given index; returns NULL if ** there is no such frame at that index. ** ** Optionally, operator[](size_t) can be used as an alternative to this ** method.  Indexing is 0-based (that is, the first frame is number 0, and the ** last frame in a tag that holds n frames is n-1). ** ** If you wish to have a more comlex searching facility, then at least for ** now you will have to devise it yourself and implement it useing these ** methods. ** ** @param nIndex The index of the frame that is to be retrieved ** @return A pointer to the requested frame, or NULL if no such frame. **//*ID3_Frame* ID3_Tag::GetFrameNum(size_t num) const{  const size_t numFrames = this->NumFrames();  if (num >= numFrames)  {    return NULL;  }  ID3_Frame* frame = NULL;  size_t curNum = 0;  // search from the cursor to the end  for (ID3_TagImpl::const_iterator cur = _impl->begin(); cur != _impl->end(); ++cur)  {    if (curNum++ == num)    {      frame = *cur;      break;    }  }  return frame;}*//** Returns a pointer to the frame with the given index; returns NULL if ** there is no such frame at that index. ** ** @name operator[] ** @param index The index of the frame that is to be retrieved ** @return A pointer to the requested frame, or NULL if no such frame. ** @see #GetFrameNum **//*ID3_Frame* ID3_Tag::operator[](size_t index) const{  return this->GetFrameNum(index);}*/ID3_Tag& ID3_Tag::operator=( const ID3_Tag &rTag ){  if (this != &rTag)  {    *_impl = rTag;  }  return *this;}bool ID3_Tag::HasTagType(ID3_TagType tt) const{  return _impl->HasTagType(tt);}ID3_V2Spec ID3_Tag::GetSpec() const{  return _impl->GetSpec();}bool ID3_Tag::SetSpec(ID3_V2Spec spec){  return _impl->SetSpec(spec);}/** Analyses a buffer to determine if we have a valid ID3v2 tag header. ** If so, return the total number of bytes (including the header) to ** read so we get all of the tag **/size_t ID3_Tag::IsV2Tag(const uchar* const data){  ID3_MemoryReader mr(data, ID3_TagHeader::SIZE);  return ID3_TagImpl::IsV2Tag(mr);}size_t ID3_Tag::IsV2Tag(ID3_Reader& reader){  return ID3_TagImpl::IsV2Tag(reader);}/// Deprecatedvoid ID3_Tag::AddNewFrame(ID3_Frame* f){  _impl->AttachFrame(f);}/** Copies an array of frames to the tag. ** ** This method copies each frame in an array to the tag.  As in ** AddFrame, the tag adds a copy of the frame, and it assumes responsiblity ** for freeing the frames' memory when the tag goes out of scope. ** ** \code **   ID3_Frame myFrames[10]; **   myTag.AddFrames(myFrames, 10); ** \endcode ** ** \sa ID3_Frame ** \sa ID3_Frame#AddFrame ** \param pNewFrames A pointer to an array of frames to be added to the tag. ** \param nFrames The number of frames in the array pNewFrames. **/void ID3_Tag::AddFrames(const ID3_Frame *frames, size_t numFrames){  for (int i = numFrames - 1; i >= 0; i--)  {    this->AddFrame(frames[i]);  }}size_t ID3_Tag::Link(const char *fileInfo, bool parseID3v1, bool parseLyrics3){  return _impl->Link(fileInfo, parseID3v1, parseLyrics3);}void ID3_Tag::SetCompression(bool b){  ;}bool ID3_Tag::HasLyrics() const{  return this->HasTagType(ID3TT_LYRICS);}bool ID3_Tag::HasV2Tag()  const{  return this->HasTagType(ID3TT_ID3V2);}bool ID3_Tag::HasV1Tag()  const{  return this->HasTagType(ID3TT_ID3V1);}/** Copies a frame to the tag.  The frame parameter can thus safely be deleted ** or allowed to go out of scope. ** ** Operator<< supports the addition of a pointer to a frame object, or ** the frame object itself. ** ** \code **   ID3_Frame *pFrame, frame; **   p_frame = &frame; **   myTag << pFrame; **   myTag << frame; ** \endcode ** ** Both these methods copy the given frame to the tag---the tag creates its ** own copy of the frame. ** ** \name operator<< ** \param frame The frame to be added to the tag. **/ID3_Tag& ID3_Tag::operator<<(const ID3_Frame& frame){  this->AddFrame(frame);  return *this;}ID3_Tag& ID3_Tag::operator<<(const ID3_Frame* frame){  if (frame)  {    this->AddFrame(frame);  }  return *this;}int32 ID3_IsTagHeader(const uchar data[ID3_TAGHEADERSIZE]){  size_t size = ID3_Tag::IsV2Tag(data);  if (!size)  {    return -1;  }  return size - ID3_TagHeader::SIZE;}namespace{  class IteratorImpl : public ID3_Tag::Iterator  {    ID3_TagImpl::iterator _cur;    ID3_TagImpl::iterator _end;  public:    IteratorImpl(ID3_TagImpl& tag)      : _cur(tag.begin()), _end(tag.end())    {    }    ID3_Frame* GetNext()    {      ID3_Frame* next = NULL;      while (next == NULL && _cur != _end)      {        next = *_cur;        ++_cur;      }      return next;    }  };  class ConstIteratorImpl : public ID3_Tag::ConstIterator  {    ID3_TagImpl::const_iterator _cur;    ID3_TagImpl::const_iterator _end;  public:    ConstIteratorImpl(ID3_TagImpl& tag)      : _cur(tag.begin()), _end(tag.end())    {    }    const ID3_Frame* GetNext()    {      ID3_Frame* next = NULL;      while (next == NULL && _cur != _end)      {        next = *_cur;        ++_cur;      }      return next;    }  };}ID3_Tag::Iterator*ID3_Tag::CreateIterator(){  return new IteratorImpl(*_impl);}ID3_Tag::ConstIterator*ID3_Tag::CreateIterator() const{  return new ConstIteratorImpl(*_impl);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -