?? field.cpp
字號(hào):
** \return The size of the field, either in bytes (for binary or integer ** fields) or characters (for strings). **/size_t ID3_FieldImpl::BinSize() const{ if (_fixed_size > 0) { return _fixed_size; } size_t size = this->Size(); if (_type == ID3FTY_TEXTSTRING) { ID3_TextEnc enc = this->GetEncoding(); if (enc == ID3TE_UNICODE && size > 0) { size++; } if (_flags & ID3FF_CSTR) { size++; } if (enc == ID3TE_UNICODE) { size *= 2; } } return size;}size_t ID3_FieldImpl::Size() const{ size_t size = 0; // check to see if we are within the legal limit for this field 0 means // arbitrary length field if (_fixed_size > 0) { size = _fixed_size; } else if (_type == ID3FTY_INTEGER) { size = sizeof(uint32); } else if (_type == ID3FTY_TEXTSTRING) { size = _text.size(); } else { size = _binary.size(); } return size;}bool ID3_FieldImpl::Parse(ID3_Reader& reader){ bool success = false; switch (this->GetType()) { case ID3FTY_INTEGER: { success = this->ParseInteger(reader); break; } case ID3FTY_BINARY: { success = this->ParseBinary(reader); break; } case ID3FTY_TEXTSTRING: { success = this->ParseText(reader); break; } default: { ID3D_WARNING( "ID3_FieldImpl::Parse(): unknown field type" ); break; } } return success;}ID3_FrameDef* ID3_FindFrameDef(ID3_FrameID id){ ID3_FrameDef *info = NULL; for (size_t cur = 0; ID3_FrameDefs[cur].eID != ID3FID_NOFRAME; ++cur) { if (ID3_FrameDefs[cur].eID == id) { info = &ID3_FrameDefs[cur]; break; } } return info;}ID3_FrameIDID3_FindFrameID(const char *id){ ID3_FrameID fid = ID3FID_NOFRAME; const int slen = strlen(id); for (size_t cur = 0; ID3_FrameDefs[cur].eID != ID3FID_NOFRAME; ++cur) { if (((strcmp(ID3_FrameDefs[cur].sShortTextID, id) == 0) && slen == 3) || ((strcmp(ID3_FrameDefs[cur].sLongTextID, id) == 0) && slen == 4)) { fid = ID3_FrameDefs[cur].eID; break; } } return fid;}void ID3_FieldImpl::Render(ID3_Writer& writer) const{ switch (this->GetType()) { case ID3FTY_INTEGER: { RenderInteger(writer); break; } case ID3FTY_BINARY: { RenderBinary(writer); break; } case ID3FTY_TEXTSTRING: { RenderText(writer); break; } default: { ID3D_WARNING ( "ID3D_FieldImpl::Render(): unknown field type" ); break; } }}ID3_Field &ID3_FieldImpl::operator=( const ID3_Field &rhs ){ const ID3_FieldImpl* fld = (const ID3_FieldImpl*) &rhs; if (this != &rhs && this->GetType() == fld->GetType()) { switch (fld->GetType()) { case ID3FTY_INTEGER: { this->SetInteger(fld->GetInteger()); break; } case ID3FTY_TEXTSTRING: { this->SetEncoding(fld->GetEncoding()); this->SetText(fld->GetText()); break; } case ID3FTY_BINARY: { this->SetBinary(fld->GetBinary()); break; } default: { break; } } } return *this;}bool ID3_FieldImpl::SetEncoding(ID3_TextEnc enc){ bool changed = this->IsEncodable() && (enc != this->GetEncoding()) && (ID3TE_NONE < enc && enc < ID3TE_NUMENCODINGS); if (changed) { _text = convert(_text, _enc, enc); _enc = enc; _changed = true; } return changed;}/** \class ID3_FrameInfo field.h id3/field.h ** \brief Provides information about the frame and field types supported by id3lib ** ** You normally only need (at most) one instance of the ID3_FrameInfo. It ** has no member data -- only methods which provide information about the ** frame types (and their component fields) supported by id3lib as defined ** in field.cpp . ** ** Usage is straightforward. The following function uses ID3_FrameInfo ** to display a summary of all the frames known to id3lib: ** \code ** ** void ShowKnownFrameInfo { ** ID3_FrameInfo myFrameInfo; ** for (int cur = ID3FID_NOFRAME+1; cur <= myFrameInfo.MaxFrameID(); cur ++) ** { ** cout << "Short ID: " << myFrameInfo.ShortName(ID3_FrameID(cur)) << ** " Long ID: " << myFrameInfo.LongName(ID3_FrameID(cur)) << ** " Desription: " << myFrameInfo.Description(ID3_FrameID(cur)) << endl; ** } ** } ** \endcode ** ** Functions are also provided to glean more information about the individual ** fields which make up any given frame type. The following for() loop, ** embedded into the previous for() loop would provide a raw look at such ** information. Realize, of course, that the field type is meaningless ** when printed. Only when it is taken in the context of the ID3_FieldType enum ** does it take on any meaningful significance. ** ** \code ** for (int cur = ID3FID_NOFRAME+1; cur <= fi.MaxFrameID(); cur ++) ** { ** int numfields = fi.NumFields(ID3_FrameID(cur)); ** ** cout << "ID: " << fi.LongName(ID3_FrameID(cur)) << ** " FIELDS: " << numfields << endl; ** for(int i=0;i<numfields;i++) { ** cout << "TYPE: " << fi.FieldType(ID3_FrameID(cur),i) << ** " SIZE: " << fi.FieldSize(ID3_FrameID(cur),i) << ** " FLAGS: " << fi.FieldFlags(ID3_FrameID(cur),i) << endl; ** ** } ** ** cout << endl; ** ** } ** \endcode ** ** @author Cedric Tefft ** @version $Id: field.cpp,v 1.47 2002/11/03 00:41:27 t1mpy Exp $ **/char *ID3_FrameInfo::ShortName(ID3_FrameID frameID){ ID3_FrameDef *pFD = ID3_FindFrameDef(frameID); if (pFD!=NULL) return pFD->sShortTextID; else return NULL;}char *ID3_FrameInfo::LongName(ID3_FrameID frameID){ ID3_FrameDef *pFD = ID3_FindFrameDef(frameID); if (pFD!=NULL) return pFD->sLongTextID; else return NULL;}const char *ID3_FrameInfo::Description(ID3_FrameID frameID){ ID3_FrameDef *pFD = ID3_FindFrameDef(frameID); if (pFD!=NULL) return pFD->sDescription; else return NULL;}int ID3_FrameInfo::MaxFrameID(){ return ID3FID_LASTFRAMEID-1;}int ID3_FrameInfo::NumFields(ID3_FrameID frameID){ int fieldnum=0; ID3_FrameDef *pFD = ID3_FindFrameDef(frameID); if (pFD!=NULL) { while (pFD->aeFieldDefs[fieldnum]._id != ID3FN_NOFIELD) { ++fieldnum; } } return fieldnum;}ID3_FieldType ID3_FrameInfo::FieldType(ID3_FrameID frameID, int fieldnum){ ID3_FrameDef *pFD = ID3_FindFrameDef(frameID); if (pFD!=NULL) return (pFD->aeFieldDefs[fieldnum]._type); else return ID3FTY_NONE;}size_t ID3_FrameInfo::FieldSize(ID3_FrameID frameID, int fieldnum){ ID3_FrameDef *pFD = ID3_FindFrameDef(frameID); if (pFD!=NULL) return (pFD->aeFieldDefs[fieldnum]._fixed_size); else return 0;}flags_t ID3_FrameInfo::FieldFlags(ID3_FrameID frameID, int fieldnum){ ID3_FrameDef *pFD = ID3_FindFrameDef(frameID); if (pFD!=NULL) return (pFD->aeFieldDefs[fieldnum]._flags); else return 0;}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -