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

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

View File

@ -28,6 +28,7 @@
#include "taglib_export.h"
#include "tfile.h"
#include "tag.h"
#include "mpcproperties.h"
@ -107,6 +108,20 @@ 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 the APE
* tag will be converted to the TagDict.
*/
TagDict toDict() const;
/*!
* Implements the unified tag dictionary 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.
*/
void fromDict(const TagDict &);
/*!
* Returns the MPC::Properties for this file. If no audio properties
* were read then this will return a null pointer.