本文整理汇总了C++中Converter::Tags方法的典型用法代码示例。如果您正苦于以下问题:C++ Converter::Tags方法的具体用法?C++ Converter::Tags怎么用?C++ Converter::Tags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Converter
的用法示例。
在下文中一共展示了Converter::Tags方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
case '2':
id3v2_encoding = optarg;
tolower(id3v2_encoding);
break;
case 'p':
preserve_unicode = true;
break;
case 'w':
preview = true;
break;
case 'v':
printf("%s %s\n", PACKAGE, PACKAGE_VERSION);
printf("%s", msg::copyright);
exit (1);
break;
case 'h':
printf("%s", msg::usage);
exit(1);
case 'q':
verbose = false;
break;
default:
usage_ok = false;
break;
}
}
if (usage_ok && source_encoding.empty ()) {
printf("%s", msg::nosenc);
usage_ok = false;
}
if(optind == argc) {
printf("%s", msg::nofiles);
usage_ok = false;
}
if (!usage_ok) {
printf("%s", msg::seehelp);
exit (1);
}
TagLib::ID3v2::FrameFactory::instance()->setDefaultTextEncoding (TagLib::String::UTF8);
for (int i=optind;i<argc;i++) {
TagLib::MPEG::File mp3file(argv[i]);
if (!mp3file.isOpen ()) {
throw msg::nofile(argv[i]);
}
TagLib::Tag *tag = mp3file.tag();
if(tag->isEmpty()) {
printf("%s", msg::emptyfile(argv[i]).c_str());
}
else {
Converter converter (
source_encoding,
id3v1_encoding,
id3v2_encoding,
mp3file.ID3v1Tag (true),
mp3file.ID3v2Tag (true),
preserve_unicode
);
converter.Convert (tag->title (), &TagLib::Tag::setTitle);
converter.Convert (tag->artist (), &TagLib::Tag::setArtist);
converter.Convert (tag->album (), &TagLib::Tag::setAlbum);
converter.Convert (tag->comment (), &TagLib::Tag::setComment);
converter.Convert (tag->genre (), &TagLib::Tag::setGenre);
if (preview) {
converter.printTags(argv[i]);
}
else {
mp3file.strip(~converter.Tags());
if (!mp3file.save (converter.Tags ())) {
printf("%s", msg::writefail(argv[i]).c_str());
}
else if(verbose) {
printf("%s", msg::filedone(argv[i]).c_str());
}
}
}
}
exit (0);
}
catch (const std::string &e) {
printf ("%s", msg::error(e).c_str());
exit (1);
}
catch (const char *e) {
printf ("%s", msg::error(e).c_str());
exit (1);
}
return 1;
}