本文整理汇总了C++中taglib::Tag::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ Tag::isEmpty方法的具体用法?C++ Tag::isEmpty怎么用?C++ Tag::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类taglib::Tag
的用法示例。
在下文中一共展示了Tag::isEmpty方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fileref
Tag::Tag(const QString &filename)
: m_filename(filename)
{
TagLib::MPEG::File mpegfile(filename.toLocal8Bit().constData());
TagLib::ID3v2::Tag* id3v2 = mpegfile.ID3v2Tag();
if (id3v2 && !id3v2->isEmpty()) {
readRegularTag(id3v2, m_data);
int picnum = 0;
TagLib::ID3v2::FrameList frames = id3v2->frameListMap()["APIC"]; // attached picture
TagLib::ID3v2::FrameList::ConstIterator it = frames.begin();
while (it != frames.end()) {
TagLib::ID3v2::AttachedPictureFrame* apic = static_cast<TagLib::ID3v2::AttachedPictureFrame*>(*it);
TagLib::ByteVector bytes = apic->picture();
QImage img = QImage::fromData(reinterpret_cast<const uchar*>(bytes.data()), bytes.size());
if (!img.isNull()) {
m_data[QLatin1String("picture") + QString::number(picnum++)] = QVariant(img);
}
++it;
}
} else {
TagLib::FileRef fileref(filename.toLocal8Bit().constData());
if (fileref.isNull())
return;
TagLib::Tag* tag = fileref.tag();
if (!tag || tag->isEmpty())
return;
readRegularTag(tag, m_data);
}
}
示例2: urlObj
TagLibTokenizer::TagLibTokenizer(const Document *pDocument) :
Tokenizer(NULL),
m_pTagDocument(NULL)
{
if (pDocument != NULL)
{
Url urlObj(pDocument->getLocation());
string pseudoContent;
if ((urlObj.isLocal() == true) &&
(urlObj.getFile().empty() == false))
{
string location(urlObj.getLocation());
string trackTitle;
location += "/";
location += urlObj.getFile();
TagLib::FileRef fileRef(location.c_str(), false);
if (fileRef.isNull() == false)
{
TagLib::Tag *pTag = fileRef.tag();
if ((pTag != NULL) &&
(pTag->isEmpty() == false))
{
char yearStr[64];
trackTitle = pTag->title().to8Bit();
trackTitle += " ";
trackTitle += pTag->artist().to8Bit();
pseudoContent = trackTitle;
pseudoContent += " ";
pseudoContent += pTag->album().to8Bit();
pseudoContent += " ";
pseudoContent += pTag->comment().to8Bit();
pseudoContent += " ";
pseudoContent += pTag->genre().to8Bit();
snprintf(yearStr, 64, " %u", pTag->year());
pseudoContent += yearStr;
}
}
else
{
trackTitle = pseudoContent = pDocument->getTitle();
}
m_pTagDocument = new Document(trackTitle, pDocument->getLocation(),
pDocument->getType(), pDocument->getLanguage());
m_pTagDocument->setData(pseudoContent.c_str(), pseudoContent.length());
m_pTagDocument->setTimestamp(pDocument->getTimestamp());
m_pTagDocument->setSize(pDocument->getSize());
// Give the result to the parent class
setDocument(m_pTagDocument);
}
}
}
示例3: extract
void TagLibExtractor::extract(ExtractionResult* result)
{
const QString fileUrl = result->inputUrl();
const QString mimeType = result->inputMimetype();
TagLib::FileRef file(fileUrl.toUtf8().constData(), true);
if (file.isNull()) {
return;
}
TagLib::Tag* tags = file.tag();
result->addType(Type::Audio);
TagLib::String artists;
TagLib::String albumArtists;
TagLib::String composers;
TagLib::String lyricists;
TagLib::StringList genres;
// Handling multiple tags in mpeg files.
if ((mimeType == QLatin1String("audio/mpeg")) || (mimeType == QLatin1String("audio/mpeg3")) || (mimeType == QLatin1String("audio/x-mpeg"))) {
TagLib::MPEG::File mpegFile(fileUrl.toUtf8().constData(), true);
if (mpegFile.ID3v2Tag() && !mpegFile.ID3v2Tag()->isEmpty()) {
TagLib::ID3v2::FrameList lstID3v2;
// Artist.
lstID3v2 = mpegFile.ID3v2Tag()->frameListMap()["TPE1"];
if (!lstID3v2.isEmpty()) {
for (TagLib::ID3v2::FrameList::ConstIterator it = lstID3v2.begin(); it != lstID3v2.end(); ++it) {
if (!artists.isEmpty()) {
artists += ", ";
}
artists += (*it)->toString();
}
}
// Album Artist.
lstID3v2 = mpegFile.ID3v2Tag()->frameListMap()["TPE2"];
if (!lstID3v2.isEmpty()) {
for (TagLib::ID3v2::FrameList::ConstIterator it = lstID3v2.begin(); it != lstID3v2.end(); ++it) {
if (!albumArtists.isEmpty()) {
albumArtists += ", ";
}
albumArtists += (*it)->toString();
}
}
// Composer.
lstID3v2 = mpegFile.ID3v2Tag()->frameListMap()["TCOM"];
if (!lstID3v2.isEmpty()) {
for (TagLib::ID3v2::FrameList::ConstIterator it = lstID3v2.begin(); it != lstID3v2.end(); ++it) {
if (!composers.isEmpty()) {
composers += ", ";
}
composers += (*it)->toString();
}
}
// Lyricist.
lstID3v2 = mpegFile.ID3v2Tag()->frameListMap()["TEXT"];
if (!lstID3v2.isEmpty()) {
for (TagLib::ID3v2::FrameList::ConstIterator it = lstID3v2.begin(); it != lstID3v2.end(); ++it) {
if (!lyricists.isEmpty()) {
lyricists += ", ";
}
lyricists += (*it)->toString();
}
}
// Genre.
lstID3v2 = mpegFile.ID3v2Tag()->frameListMap()["TCON"];
if (!lstID3v2.isEmpty()) {
for (TagLib::ID3v2::FrameList::ConstIterator it = lstID3v2.begin(); it != lstID3v2.end(); ++it) {
genres.append((*it)->toString());
}
}
}
}
// Handling multiple tags in Ogg containers.
{
TagLib::Ogg::FieldListMap lstOgg;
// FLAC files.
if (mimeType == QLatin1String("audio/flac")) {
TagLib::FLAC::File flacFile(fileUrl.toUtf8().constData(), true);
if (flacFile.xiphComment() && !flacFile.xiphComment()->isEmpty()) {
lstOgg = flacFile.xiphComment()->fieldListMap();
}
}
// Vorbis files.
if (mimeType == QLatin1String("audio/ogg") || mimeType == QLatin1String("audio/x-vorbis+ogg")) {
TagLib::Ogg::Vorbis::File oggFile(fileUrl.toUtf8().constData(), true);
if (oggFile.tag() && !oggFile.tag()->isEmpty()) {
lstOgg = oggFile.tag()->fieldListMap();
}
}
//.........这里部分代码省略.........
示例4: main
int main (int argc, char *argv[]) {
try {
static struct option long_options[] = {
{ "source-encoding", required_argument, NULL, 's' },
{ "id3v1-encoding", required_argument, NULL, '1' },
{ "id3v2-encoding", required_argument, NULL, '2' },
{ "preserve-unicode", no_argument, NULL, 'p' },
{ "preview", no_argument, NULL, 'w' },
{ "version", no_argument, NULL, 'v' },
{ "help", no_argument, NULL, 'h' },
{ "quiet", no_argument, NULL, 'q' },
{ NULL, 0, NULL, 0 }
};
int long_options_ret;
std::string source_encoding;
std::string id3v1_encoding = "none";
std::string id3v2_encoding = "none";
bool preserve_unicode = false;
bool preview = false;
bool usage_ok = true;
bool verbose = true;
if(argc == 1) {
printf("%s", msg::usage);
exit(1);
}
while (
(long_options_ret = getopt_long (argc, argv, "s:1:2:pwdvhq", long_options, NULL)) != -1
) {
switch (long_options_ret) {
case 's':
source_encoding = optarg;
tolower(source_encoding);
break;
case '1':
id3v1_encoding = optarg;
tolower(id3v1_encoding);
break;
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,
//.........这里部分代码省略.........