Started to work on ID3v2.

This commit is contained in:
Michael Helmling
2012-01-21 23:05:59 +01:00
parent e4d955d6ef
commit a5e45f196b
12 changed files with 308 additions and 94 deletions

View File

@ -113,27 +113,34 @@ TagLib::Tag *MPC::File::tag() const
return &d->tag;
}
TagLib::TagDict MPC::File::toDict(void) const
PropertyMap MPC::File::properties() const
{
// once Tag::toDict() is virtual, this case distinction could actually be done
// within TagUnion.
if (d->hasAPE)
return d->tag.access<APE::Tag>(APEIndex, false)->toDict();
if (d->hasID3v1)
return d->tag.access<ID3v1::Tag>(ID3v1Index, false)->toDict();
return TagLib::TagDict();
if(d->hasAPE)
return d->tag.access<APE::Tag>(APEIndex, false)->properties();
if(d->hasID3v1)
return d->tag.access<ID3v1::Tag>(ID3v1Index, false)->properties();
return PropertyMap();
}
void MPC::File::fromDict(const TagDict &dict)
void MPC::File::removeUnsupportedProperties(const StringList &properties)
{
if (d->hasAPE)
d->tag.access<APE::Tag>(APEIndex, false)->fromDict(dict);
else if (d->hasID3v1)
d->tag.access<ID3v1::Tag>(ID3v1Index, false)->fromDict(dict);
else
d->tag.access<APE::Tag>(APEIndex, true)->fromDict(dict);
if(d->hasAPE)
d->tag.access<APE::Tag>(APEIndex, false)->removeUnsupportedProperties(properties);
if(d->hasID3v1)
d->tag.access<ID3v1::Tag>(ID3v1Index, false)->removeUnsupportedProperties(properties);
}
PropertyMap MPC::File::setProperties(const PropertyMap &properties)
{
if(d->hasAPE)
return d->tag.access<APE::Tag>(APEIndex, false)->setProperties(properties);
else if(d->hasID3v1)
return d->tag.access<ID3v1::Tag>(ID3v1Index, false)->setProperties(properties);
else
return d->tag.access<APE::Tag>(APE, true)->setProperties(properties);
}
MPC::Properties *MPC::File::audioProperties() const
{
return d->properties;

View File

@ -109,18 +109,20 @@ namespace TagLib {
virtual TagLib::Tag *tag() const;
/*!
* Implements the unified tag dictionary interface -- export function.
* Implements the unified property interface -- export function.
* If the file contains both an APE and an ID3v1 tag, only the APE
* tag will be converted to the TagDict.
* tag will be converted to the PropertyMap.
*/
TagDict toDict() const;
PropertyMap properties() const;
void removeUnsupportedProperties(const StringList &properties);
/*!
* Implements the unified tag dictionary interface -- import function.
* Implements the unified property interface -- import function.
* As with the export, only one tag is taken into account. If the file
* has no tag at all, APE will be created.
* has no tag at all, an APE tag will be created.
*/
void fromDict(const TagDict &);
PropertyMap setProperties(const PropertyMap &);
/*!
* Returns the MPC::Properties for this file. If no audio properties