Made im/export functions nonvirtual. Added similar functions to File and

its subclasses. TagLib::File contains a bunch of dynamic_casts to call
the correct specializations.
This commit is contained in:
Michael Helmling
2011-08-28 22:58:40 +02:00
parent fa8159a9d0
commit 5647b2e293
20 changed files with 297 additions and 9 deletions

View File

@ -109,6 +109,25 @@ TagLib::Tag *APE::File::tag() const
return &d->tag;
}
TagLib::TagDict APE::File::toDict(void) const
{
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();
}
void APE::File::fromDict(const TagDict &dict)
{
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>(APE, true)->fromDict(dict);
}
APE::Properties *APE::File::audioProperties() const
{
return d->properties;

View File

@ -110,6 +110,19 @@ namespace TagLib {
*/
virtual TagLib::Tag *tag() const;
/*!
* Implements the unified tag dictionary interface -- export function.
* If the file contains both an APE and an ID3v1 tag, only APE
* will be converted to the TagDict.
*/
TagDict toDict() const;
/*!
* Implements the unified tag dictionary interface -- import function.
* As for the export, only one tag is taken into account. If the file
* has no tag at all, APE will be created.
*/
void fromDict(const TagDict &);
/*!
* Returns the APE::Properties for this file. If no audio properties
* were read then this will return a null pointer.

View File

@ -114,13 +114,13 @@ namespace TagLib {
* TRACK to TRACKNUMBER and YEAR to DATE, respectively, in order to be compliant
* with the names used in other formats.
*/
virtual TagDict toDict() const;
TagDict toDict() const;
/*!
* Implements the unified tag dictionary interface -- import function. The same
* comments as for the export function apply.
*/
virtual void fromDict(const TagDict &);
void fromDict(const TagDict &);
/*!
* Returns a pointer to the tag's footer.