mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Added the methods to check which kind of tags the file actually has.
This commit is contained in:
parent
7e866e11ad
commit
1503909824
@ -47,7 +47,7 @@ using namespace TagLib;
|
||||
|
||||
namespace
|
||||
{
|
||||
enum { ApeAPEIndex, ApeID3v1Index };
|
||||
enum { ApeAPEIndex = 0, ApeID3v1Index = 1 };
|
||||
}
|
||||
|
||||
class APE::File::FilePrivate
|
||||
@ -235,6 +235,16 @@ void APE::File::strip(int tags)
|
||||
}
|
||||
}
|
||||
|
||||
bool APE::File::hasAPETag() const
|
||||
{
|
||||
return d->hasAPE;
|
||||
}
|
||||
|
||||
bool APE::File::hasID3v1Tag() const
|
||||
{
|
||||
return d->hasID3v1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// private members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -186,6 +186,16 @@ namespace TagLib {
|
||||
*/
|
||||
void strip(int tags = AllTags);
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk contains an APE tag.
|
||||
*/
|
||||
bool hasAPETag() const;
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk contains an ID3v1 tag.
|
||||
*/
|
||||
bool hasID3v1Tag() const;
|
||||
|
||||
private:
|
||||
File(const File &);
|
||||
File &operator=(const File &);
|
||||
|
@ -552,3 +552,17 @@ void FLAC::File::removePictures()
|
||||
d->blocks = newBlocks;
|
||||
}
|
||||
|
||||
bool FLAC::File::hasXiphComment() const
|
||||
{
|
||||
return d->hasXiphComment;
|
||||
}
|
||||
|
||||
bool FLAC::File::hasID3v1Tag() const
|
||||
{
|
||||
return d->hasID3v1;
|
||||
}
|
||||
|
||||
bool FLAC::File::hasID3v2Tag() const
|
||||
{
|
||||
return d->hasID3v2;
|
||||
}
|
||||
|
@ -246,6 +246,21 @@ namespace TagLib {
|
||||
*/
|
||||
void addPicture(Picture *picture);
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk contains a Xiph comment.
|
||||
*/
|
||||
bool hasXiphComment() const;
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk contains an ID3v1 tag.
|
||||
*/
|
||||
bool hasID3v1Tag() const;
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk contains an ID3v2 tag.
|
||||
*/
|
||||
bool hasID3v2Tag() const;
|
||||
|
||||
private:
|
||||
File(const File &);
|
||||
File &operator=(const File &);
|
||||
|
@ -39,7 +39,7 @@ using namespace TagLib;
|
||||
|
||||
namespace
|
||||
{
|
||||
enum { MPCAPEIndex, MPCID3v1Index };
|
||||
enum { MPCAPEIndex = 0, MPCID3v1Index = 1 };
|
||||
}
|
||||
|
||||
class MPC::File::FilePrivate
|
||||
@ -256,6 +256,15 @@ void MPC::File::remove(int tags)
|
||||
strip(tags);
|
||||
}
|
||||
|
||||
bool MPC::File::hasID3v1Tag() const
|
||||
{
|
||||
return d->hasID3v1;
|
||||
}
|
||||
|
||||
bool MPC::File::hasAPETag() const
|
||||
{
|
||||
return d->hasAPE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// private members
|
||||
|
@ -187,6 +187,16 @@ namespace TagLib {
|
||||
*/
|
||||
void remove(int tags = AllTags);
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk contains an ID3v1 tag.
|
||||
*/
|
||||
bool hasID3v1Tag() const;
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk contains an APE tag.
|
||||
*/
|
||||
bool hasAPETag() const;
|
||||
|
||||
private:
|
||||
File(const File &);
|
||||
File &operator=(const File &);
|
||||
|
@ -327,17 +327,17 @@ namespace TagLib {
|
||||
long lastFrameOffset();
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk contains ID3v1 tag.
|
||||
* Returns whether or not the file on disk contains an ID3v1 tag.
|
||||
*/
|
||||
bool hasID3v1Tag() const;
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk contains ID3v2 tag.
|
||||
* Returns whether or not the file on disk contains an ID3v2 tag.
|
||||
*/
|
||||
bool hasID3v2Tag() const;
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk contains APE tag.
|
||||
* Returns whether or not the file on disk contains an APE tag.
|
||||
*/
|
||||
bool hasAPETag() const;
|
||||
|
||||
|
@ -287,3 +287,8 @@ void Ogg::FLAC::File::scan()
|
||||
|
||||
d->scanned = true;
|
||||
}
|
||||
|
||||
bool Ogg::FLAC::File::hasXiphComment() const
|
||||
{
|
||||
return d->hasXiphComment;
|
||||
}
|
||||
|
@ -128,6 +128,11 @@ namespace TagLib {
|
||||
*/
|
||||
long streamLength();
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk contains a Xiph comment.
|
||||
*/
|
||||
bool hasXiphComment() const;
|
||||
|
||||
private:
|
||||
File(const File &);
|
||||
File &operator=(const File &);
|
||||
|
@ -123,6 +123,7 @@ bool RIFF::AIFF::File::save()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// private members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -113,6 +113,11 @@ namespace TagLib {
|
||||
*/
|
||||
virtual bool save();
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk contains an ID3v2 tag.
|
||||
*/
|
||||
bool hasID3v2Tag() const;
|
||||
|
||||
private:
|
||||
File(const File &);
|
||||
File &operator=(const File &);
|
||||
|
@ -45,7 +45,9 @@ class RIFF::WAV::File::FilePrivate
|
||||
public:
|
||||
FilePrivate() :
|
||||
properties(0),
|
||||
tagChunkID("ID3 ")
|
||||
tagChunkID("ID3 "),
|
||||
hasID3v2(false),
|
||||
hasInfo(false)
|
||||
{
|
||||
}
|
||||
|
||||
@ -59,6 +61,9 @@ public:
|
||||
ByteVector tagChunkID;
|
||||
|
||||
TagUnion tag;
|
||||
|
||||
bool hasID3v2;
|
||||
bool hasInfo;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -143,8 +148,10 @@ bool RIFF::WAV::File::save(TagTypes tags, bool stripOthers, int id3v2Version)
|
||||
|
||||
ID3v2::Tag *id3v2tag = d->tag.access<ID3v2::Tag>(ID3v2Index, false);
|
||||
if(!id3v2tag->isEmpty()) {
|
||||
if(tags & ID3v2)
|
||||
if(tags & ID3v2) {
|
||||
setChunkData(d->tagChunkID, id3v2tag->render(id3v2Version));
|
||||
d->hasID3v2 = true;
|
||||
}
|
||||
}
|
||||
|
||||
Info::Tag *infotag = d->tag.access<Info::Tag>(InfoIndex, false);
|
||||
@ -155,12 +162,24 @@ bool RIFF::WAV::File::save(TagTypes tags, bool stripOthers, int id3v2Version)
|
||||
setChunkData(chunkId, infotag->render());
|
||||
else
|
||||
setChunkData("LIST", infotag->render(), true);
|
||||
|
||||
d->hasInfo = true;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RIFF::WAV::File::hasID3v2Tag() const
|
||||
{
|
||||
return d->hasID3v2;
|
||||
}
|
||||
|
||||
bool RIFF::WAV::File::hasInfoTag() const
|
||||
{
|
||||
return d->hasInfo;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// private members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -174,6 +193,7 @@ void RIFF::WAV::File::read(bool readProperties, Properties::ReadStyle properties
|
||||
if(name == "ID3 " || name == "id3 ") {
|
||||
d->tagChunkID = chunkName(i);
|
||||
d->tag.set(ID3v2Index, new ID3v2::Tag(this, chunkOffset(i)));
|
||||
d->hasID3v2 = true;
|
||||
}
|
||||
else if(name == "fmt " && readProperties)
|
||||
formatData = chunkData(i);
|
||||
@ -183,8 +203,10 @@ void RIFF::WAV::File::read(bool readProperties, Properties::ReadStyle properties
|
||||
ByteVector data = chunkData(i);
|
||||
ByteVector type = data.mid(0, 4);
|
||||
|
||||
if(type == "INFO")
|
||||
if(type == "INFO") {
|
||||
d->tag.set(InfoIndex, new RIFF::Info::Tag(data));
|
||||
d->hasInfo = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,6 +139,16 @@ namespace TagLib {
|
||||
virtual bool save();
|
||||
|
||||
bool save(TagTypes tags, bool stripOthers = true, int id3v2Version = 4);
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk contains an ID3v2 tag.
|
||||
*/
|
||||
bool hasID3v2Tag() const;
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk contains an RIFF INFO tag.
|
||||
*/
|
||||
bool hasInfoTag() const;
|
||||
|
||||
private:
|
||||
File(const File &);
|
||||
|
@ -236,6 +236,16 @@ void TrueAudio::File::strip(int tags)
|
||||
}
|
||||
}
|
||||
|
||||
bool TrueAudio::File::hasID3v1Tag() const
|
||||
{
|
||||
return d->hasID3v1;
|
||||
}
|
||||
|
||||
bool TrueAudio::File::hasID3v2Tag() const
|
||||
{
|
||||
return d->hasID3v2;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// private members
|
||||
|
@ -209,7 +209,17 @@ namespace TagLib {
|
||||
* \note In order to make the removal permanent save() still needs to be called
|
||||
*/
|
||||
void strip(int tags = AllTags);
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk contains an ID3v1 tag.
|
||||
*/
|
||||
bool hasID3v1Tag() const;
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk contains an ID3v2 tag.
|
||||
*/
|
||||
bool hasID3v2Tag() const;
|
||||
|
||||
private:
|
||||
File(const File &);
|
||||
File &operator=(const File &);
|
||||
|
@ -231,6 +231,16 @@ void WavPack::File::strip(int tags)
|
||||
}
|
||||
}
|
||||
|
||||
bool WavPack::File::hasID3v1Tag() const
|
||||
{
|
||||
return d->hasID3v1;
|
||||
}
|
||||
|
||||
bool WavPack::File::hasAPETag() const
|
||||
{
|
||||
return d->hasAPE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// private members
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -173,7 +173,17 @@ namespace TagLib {
|
||||
* \note In order to make the removal permanent save() still needs to be called
|
||||
*/
|
||||
void strip(int tags = AllTags);
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk contains an ID3v1 tag.
|
||||
*/
|
||||
bool hasID3v1Tag() const;
|
||||
|
||||
/*!
|
||||
* Returns whether or not the file on disk contains an APE tag.
|
||||
*/
|
||||
bool hasAPETag() const;
|
||||
|
||||
private:
|
||||
File(const File &);
|
||||
File &operator=(const File &);
|
||||
|
Loading…
Reference in New Issue
Block a user