当前位置: 首页>>代码示例>>C++>>正文


C++ id3_tag::Iterator类代码示例

本文整理汇总了C++中id3_tag::Iterator的典型用法代码示例。如果您正苦于以下问题:C++ Iterator类的具体用法?C++ Iterator怎么用?C++ Iterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Iterator类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

//following routine courtesy of John George
size_t ID3_GetPictureDataOfPicType(ID3_Tag* tag, const char* TempPicPath, ID3_PictureType pictype)
{
    if (NULL == tag)
        return 0;
    else
    {
        ID3_Frame* frame = NULL;
        ID3_Tag::Iterator* iter = tag->CreateIterator();

        while (NULL != (frame = iter->GetNext() ))
        {
            if(frame->GetID() == ID3FID_PICTURE)
            {
                if(frame->GetField(ID3FN_PICTURETYPE)->Get() == (uint32)pictype)
                    break;
            }
        }
        delete iter;

        if (frame != NULL)
        {
            ID3_Field* myField = frame->GetField(ID3FN_DATA);
            if (myField != NULL)
            {
                myField->ToFile(TempPicPath);
                return (size_t)myField->Size();
            }
            else return 0;
        }
        else return 0;
    }
}
开发者ID:IMSoP,项目名称:CDex,代码行数:33,代码来源:misc_support.cpp

示例2: strlen

ID3_Frame* ID3_AddComment(ID3_Tag *tag, const char *text,
                          const char *desc, const char* lang, bool replace)
{
    ID3_Frame* frame = NULL;
    if (NULL != tag  &&
            NULL != text &&
            NULL != desc &&
            strlen(text) > 0)
    {
        bool bAdd = true;
        if (replace)
        {
            ID3_RemoveComments(tag, desc);
        }
        else
        {
            // See if there is already a comment with this description
            ID3_Tag::Iterator* iter = tag->CreateIterator();
            ID3_Frame* frame = NULL;
            while ((frame = iter->GetNext()) != NULL)
            {
                if (frame->GetID() == ID3FID_COMMENT)
                {
                    char *tmp_desc = ID3_GetString(frame, ID3FN_DESCRIPTION);
                    if (strcmp(tmp_desc, desc) == 0)
                    {
                        bAdd = false;
                    }
                    delete [] tmp_desc;
                    if (!bAdd)
                    {
                        break;
                    }
                }
            }
            delete iter;
        }
        if (bAdd)
        {
            frame = new ID3_Frame(ID3FID_COMMENT);
            if (NULL != frame)
            {
                frame->GetField(ID3FN_LANGUAGE)->Set(lang);
                frame->GetField(ID3FN_DESCRIPTION)->Set(desc);
                frame->GetField(ID3FN_TEXT)->Set(text);
                tag->AttachFrame(frame);
            }
        }
    }
    return frame;
}
开发者ID:IMSoP,项目名称:CDex,代码行数:51,代码来源:misc_support.cpp

示例3: info

//***************************************************************************
bool Kwave::MP3Decoder::parseID3Tags(ID3_Tag &tag)
{
    if (tag.NumFrames() < 1) return true; // no tags, nothing to do

    QDate creation_date;
    QTime creation_time;
    int year  = -1;
    int month = -1;
    int day   = -1;

    ID3_Tag::Iterator *it = tag.CreateIterator();
    ID3_Frame *frame = 0;
    Kwave::FileInfo info(metaData());
    while (it && (frame = it->GetNext())) {
	const ID3_FrameID id = frame->GetID();
	const Kwave::FileProperty property = m_property_map.property(id);
	const ID3_PropertyMap::Encoding encoding = m_property_map.encoding(id);
	switch (encoding) {
	    case ID3_PropertyMap::ENC_TEXT_PARTINSET:
	    {
		QString s = parseId3Frame2String(frame);
		int cd  = 0;
		int cds = 0;
		if (s.contains(QLatin1Char('/'))) {
		    int i = s.indexOf(QLatin1Char('/'));
		    cd = s.left(i).toInt();
		    cds = s.mid(i + 1).toInt();
		} else {
		    cd = s.toInt();
		}
		if (cd  > 0) info.set(Kwave::INF_CD , QVariant(cd));
		if (cds > 0) info.set(Kwave::INF_CDS, QVariant(cds));
		break;
	    }
	    case ID3_PropertyMap::ENC_TRACK_NUM:
	    {
		QString s = parseId3Frame2String(frame);
		int track  = 0;
		int tracks = 0;
		if (s.contains(QLatin1Char('/'))) {
		    int i = s.indexOf(QLatin1Char('/'));
		    track = s.left(i).toInt();
		    tracks = s.mid(i + 1).toInt();
		} else {
		    track = s.toInt();
		}
		if (track  > 0) info.set(Kwave::INF_TRACK , QVariant(track));
		if (tracks > 0) info.set(Kwave::INF_TRACKS, QVariant(tracks));
		break;
	    }
	    case ID3_PropertyMap::ENC_TERMS_OF_USE:
		// the same as ENC_COMMENT, but without "Description"
		/* FALLTHROUGH */
	    case ID3_PropertyMap::ENC_COMMENT:
	    {
		QString s = parseId3Frame2String(frame);

		// optionally prepend language
		char *lang = ID3_GetString(frame, ID3FN_LANGUAGE);
		if (lang) {
		    s = _("[") + _(lang) + _("] ") + s;
		    ID3_FreeString(lang);
		}

		// append to already existing tag, separated by a slash
		if (info.contains(property))
		    s = info.get(property).toString() + _(" / ") + s;
		info.set(property, QVariant(s));
		break;
	    }
	    case ID3_PropertyMap::ENC_GENRE_TYPE:
	    {
		QString s = parseId3Frame2String(frame);
		int genre = Kwave::GenreType::fromID3(s);
		if (genre >= 0)
		    s = Kwave::GenreType::name(genre, false);
		info.set(property, QVariant(s));
		break;
	    }
	    case ID3_PropertyMap::ENC_LENGTH:
	    {
		// length in ms -> convert this to samples
		QString       s    = parseId3Frame2String(frame);
		const double  rate = info.rate();
		bool          ok   = false;
		const double  ms   = s.toDouble(&ok) + 0.5;
		if (ok && (rate > 0)) {
		    // NOTE: this overwrites the length found in the header!
		    sample_index_t length = static_cast<sample_index_t>(
			(rate * ms) / 1000.0);
		    info.setLength(length);
		}
		break;
	    }
	    case ID3_PropertyMap::ENC_TEXT_TIMESTAMP:
	    {
		if (!creation_date.isValid()) {
		    QString s = parseId3Frame2String(frame);
		    switch (id)
//.........这里部分代码省略.........
开发者ID:KDE,项目名称:kwave,代码行数:101,代码来源:MP3Decoder.cpp

示例4: if

MP3Data * MP3DataGenerator::readMetadata( const char * p_filePath)
{
	// Set up file connection.
	myID3_Tag = new ID3_Tag();
	myID3_Tag->Link( p_filePath);

	// Storage with default initialization.
	MP3Data * myMP3Data = new MP3Data();
	myMP3Data->setAll( "<undefinded>");

	// Retrieve metadata.
	ID3_Tag::Iterator * tagIter = myID3_Tag->CreateIterator();
	ID3_Frame * myFrame = NULL;
	while( NULL != ( myFrame = tagIter->GetNext()))
	{			
		if( NULL != myFrame)
		{			
			ID3_Field * myField = myFrame->GetField( ID3FN_TEXT);
			// Check if current frame is part of the set aka a field of interest.
			std::set<ID3_FrameID>::iterator current = interestingID3_FrameIDs->find( myFrame->GetID());
			if ( NULL != myField && current != interestingID3_FrameIDs->end())
			{
				ID3_FrameID_LUT * myLUT = new ID3_FrameID_LUT();
				std::string frameRealname = std::string( myLUT->getRealname( myFrame->GetID()));
				// @TODO Show encoding in gui (optional)
				if( myField->GetEncoding() == ID3TE_ASCII || ID3TE_ISO8859_1)
				{
					encoding += frameRealname + ": ISO8859_1 , ";
					// Genre needs to be converted.
					if( myFrame->GetID() == ID3FID_CONTENTTYPE) // ID3_FrameID = 32
					{
						const char * genre = myField->GetRawText();
						// ID3V1 genre has is an int surrounded by round brackets; ID3V2 genre is text.
						unsigned int genreIntegerAlias = removeBrackets( genre);
						if( genreIntegerAlias < ID3_NR_OF_V1_GENRES && genre[0] == '(')
							myMP3Data->setGenre( ID3_v1_genre_description[ genreIntegerAlias]);
						else 
							myMP3Data->setGenre( genre);
					}
					// All other tags.
					else if( myFrame->GetID() == ID3FID_TITLE)
						myMP3Data->setTitle( myField->GetRawText());
					else if( myFrame->GetID() == ID3FID_ALBUM)
						myMP3Data->setAlbum( myField->GetRawText());
					else if( myFrame->GetID() == ID3FID_YEAR)
						myMP3Data->setYear( myField->GetRawText());
					else if( myFrame->GetID() == ID3FID_TRACKNUM)
						myMP3Data->setTracknumber( myField->GetRawText());
					else if( myFrame->GetID() == ID3FID_LEADARTIST)
						myMP3Data->setArtist( myField->GetRawText());
				}
				else if( myField->GetEncoding() == ID3TE_UTF8)
				{
					encoding += frameRealname + ": utf8 , ";
					myMP3Data->setAll( "<unicode utf8 encoding>");
				}
				else if( myField->GetEncoding() == ID3TE_UNICODE || ID3TE_UTF16)
				{
					encoding += frameRealname + ": utf16 ,";
					// @TODO Conversion to std::string ... myField->GetRawUnicodeText();
					myMP3Data->setAll( "<unicode utf16 encoding>");
				}
				else if( myField->GetEncoding() == ID3TE_UTF16BE)
				{
					encoding += frameRealname + ": utf16be , ";
					myMP3Data->setAll( "<unicode utf16be encoding>");
				}
				else if( myField->GetEncoding() == ID3TE_NUMENCODINGS)
				{
					encoding += frameRealname + ": numencodings , ";
					myMP3Data->setAll( "<numencoding>");
				}
				else
				{
					encoding += frameRealname + ": unknown , ";
					myMP3Data->setAll( "<<unknown encoding>");
				}
			}
		}
	}
	// Retrieve file path and file name.
	myMP3Data->setFilepath( p_filePath);
	myMP3Data->setFilename( getFilename( p_filePath).c_str());
	return myMP3Data;
}
开发者ID:johnjohndoe,项目名称:Programming,代码行数:85,代码来源:MP3DataGenerator.cpp

示例5: while

void MP3TagReader::ImportTags(MatroskaTagInfo *target) {
#ifdef USING_ID3LIB
	
	// use an std::auto_ptr here to handle object cleanup automatically
  ID3_Tag::Iterator *iter = m_Tag.CreateIterator();
  ID3_Frame *myFrame = NULL;
  while (NULL != (myFrame = iter->GetNext())) {
		// do something with myFrame
		//myFrame;
		ID3_Field *textField = myFrame->GetField(ID3FN_TEXTENC);
		ID3_Field *intField = myFrame->GetField(ID3FN_COUNTER);
		
		if (myFrame->GetID() == ID3FID_PLAYCOUNTER) {
			target->Tag_PlayCounter = intField->Get();

		} else if (myFrame->GetID() == ID3FID_POPULARIMETER) {
			target->Tag_Popularimeter = intField->Get();

		} else if (myFrame->GetID() == ID3FID_ALBUM) {
			MatroskaTagMultiTitleItem *newTagItem = new MatroskaTagMultiTitleItem();
			newTagItem->Type = KaxTagMultiTitleType_AlbumMovieShowTitle;
			newTagItem->Name = textField->GetRawUnicodeText();
			target->AddMultiTitleItem(newTagItem);

		} else if (myFrame->GetID() == ID3FID_BPM) {
			target->Tag_BPM = intField->Get();

		} else if (myFrame->GetID() == ID3FID_COMPOSER) {
			MatroskaTagMultiEntityItem *newTagItem = new MatroskaTagMultiEntityItem();
			newTagItem->Type = KaxTagMultiEntitiesType_Composer;
			newTagItem->Name = textField->GetRawUnicodeText();
			target->AddMultiEntityItem(newTagItem);

		} else if (myFrame->GetID() == ID3FID_PLAYLISTDELAY) {	
			target->Tag_PlaylistDelay = intField->Get();

		} else if (myFrame->GetID() == ID3FID_ENCODEDBY) {	
			MatroskaTagMultiEntityItem *newTagItem = new MatroskaTagMultiEntityItem();
			newTagItem->Type = KaxTagMultiEntitiesType_EncodedBy;
			newTagItem->Name = textField->GetRawUnicodeText();
			target->AddMultiEntityItem(newTagItem);

		} else if (myFrame->GetID() == ID3FID_LYRICIST) {	
			MatroskaTagMultiEntityItem *newTagItem = new MatroskaTagMultiEntityItem();
			newTagItem->Type = KaxTagMultiEntitiesType_LyricistTextWriter;
			newTagItem->Name = textField->GetRawUnicodeText();
			target->AddMultiEntityItem(newTagItem);

		} else if (myFrame->GetID() == ID3FID_TITLE) {
			MatroskaTagMultiTitleItem *newTagItem = new MatroskaTagMultiTitleItem();
			newTagItem->Type = KaxTagMultiTitleType_TrackTitle;
			newTagItem->Name = textField->GetRawUnicodeText();
			target->AddMultiTitleItem(newTagItem);

		} else if (myFrame->GetID() == ID3FID_SUBTITLE) {
			MatroskaTagMultiTitleItem *newTagItem = new MatroskaTagMultiTitleItem();
			newTagItem->Type = KaxTagMultiTitleType_TrackTitle;
			newTagItem->SubTitle = textField->GetRawUnicodeText();
			target->AddMultiTitleItem(newTagItem);

		} 
		
  }
  delete iter;

#endif
};
开发者ID:Matroska-Org,项目名称:matroskautils,代码行数:67,代码来源:MP3TagReader.cpp

示例6: play_debug_meta

void play_debug_meta(char* filename){
  ID3_Tag tag(filename);

  ID3_Tag::Iterator* iter = tag.CreateIterator();
  ID3_Frame* frame = NULL;
  char buf[1000];

  // Iconv conversion descriptor: UTF-16 -> UTF-8
  iconv_t cd = iconv_open("UTF8","UTF16BE");

  while (NULL != (frame = iter->GetNext()))
  {
    char* val = NULL;
    field_text(&val, frame); 
    printf("Frame: type %d %s %s:\n", frame->GetID(), frame->GetTextID(), frame->GetDescription());
    ID3_Frame::Iterator* fieldIter = frame->CreateIterator();
    ID3_Field* field = NULL;

    while (NULL != (field = fieldIter->GetNext())) {
      printf("  Field: type ");
      ID3_FieldType type = field->GetType();
      switch(type) {
      case ID3FTY_NONE:
        printf("none"); break;
      case ID3FTY_INTEGER:
        printf("int"); break;
      case ID3FTY_BINARY:
        printf("binary"); break;
      case ID3FTY_TEXTSTRING:
        field->Get(buf, 1000);
        printf("text with %d items, encoding ", field->GetNumTextItems());
        switch(field->GetEncoding()){
        case ID3TE_UTF16: printf("UTF-16"); 

          if ( cd != (iconv_t) -1 ) {
            char* in = (char*) field->GetRawUnicodeText();
            size_t insize = field->Size();

            char* bufptr = buf;
            size_t bufsize = 1000;
            size_t rc = 0;

            // Initialize iconv state
            if( iconv(cd, NULL, NULL, &bufptr, &bufsize) == (size_t) -1 ){
              printf("iconv init Failed\n");
            }
            if ( (rc = iconv(cd, &in, &insize, &bufptr, &bufsize)) != (size_t) -1 ) {
              *bufptr = '\0';
              printf(": '%s' (%d chars)\n", buf, rc);
            } else {
              printf("<conversion using iconv failed>");
              perror("iconv");
            }
          }
          break;
        case ID3TE_UTF16BE: printf("UTF-16BE"); 
          printf(": '%s'", buf);
          break;
        case ID3TE_UTF8: printf("UTF-8");
          printf(": '%s'", buf);
          break;
        case ID3TE_NONE: printf("none");
          printf(": '%s'", buf);
          break;
        case ID3TE_ISO8859_1: printf("ISO-8859-1/ASCII");
          printf(": '%s'", buf);
          break;
        }
        break;
      }
      printf("\n");
    }
    delete fieldIter;
    delete [] val;
  }
  delete iter;

  iconv_close(cd);
}              
开发者ID:jeffwilliams,项目名称:wwwmp3,代码行数:79,代码来源:play_meta.cpp


注:本文中的id3_tag::Iterator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。