mirror of
https://github.com/taglib/taglib.git
synced 2026-02-14 12:13:07 -05:00
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:
@ -138,6 +138,31 @@ TagLib::Tag *FLAC::File::tag() const
|
||||
return &d->tag;
|
||||
}
|
||||
|
||||
TagLib::TagDict FLAC::File::toDict(void) const
|
||||
{
|
||||
// once Tag::toDict() is virtual, this case distinction could actually be done
|
||||
// within TagUnion.
|
||||
if (d->hasXiphComment)
|
||||
return d->tag.access<Ogg::XiphComment>(XiphIndex, false)->toDict();
|
||||
if (d->hasID3v2)
|
||||
return d->tag.access<ID3v2::Tag>(ID3v2Index, false)->toDict();
|
||||
if (d->hasID3v1)
|
||||
return d->tag.access<ID3v1::Tag>(ID3v1Index, false)->toDict();
|
||||
return TagLib::TagDict();
|
||||
}
|
||||
|
||||
void FLAC::File::fromDict(const TagDict &dict)
|
||||
{
|
||||
if (d->hasXiphComment)
|
||||
d->tag.access<Ogg::XiphComment>(XiphIndex, false)->fromDict(dict);
|
||||
else if (d->hasID3v2)
|
||||
d->tag.access<ID3v2::Tag>(ID3v2Index, false)->fromDict(dict);
|
||||
else if (d->hasID3v1)
|
||||
d->tag.access<ID3v1::Tag>(ID3v1Index, false)->fromDict(dict);
|
||||
else
|
||||
d->tag.access<Ogg::XiphComment>(XiphIndex, true)->fromDict(dict);
|
||||
}
|
||||
|
||||
FLAC::Properties *FLAC::File::audioProperties() const
|
||||
{
|
||||
return d->properties;
|
||||
|
||||
@ -29,6 +29,7 @@
|
||||
#include "taglib_export.h"
|
||||
#include "tfile.h"
|
||||
#include "tlist.h"
|
||||
#include "tag.h"
|
||||
|
||||
#include "flacpicture.h"
|
||||
#include "flacproperties.h"
|
||||
@ -36,7 +37,6 @@
|
||||
namespace TagLib {
|
||||
|
||||
class Tag;
|
||||
|
||||
namespace ID3v2 { class FrameFactory; class Tag; }
|
||||
namespace ID3v1 { class Tag; }
|
||||
namespace Ogg { class XiphComment; }
|
||||
@ -118,6 +118,21 @@ namespace TagLib {
|
||||
*/
|
||||
virtual TagLib::Tag *tag() const;
|
||||
|
||||
/*!
|
||||
* Implements the unified tag dictionary interface -- export function.
|
||||
* If the file contains more than one tag (e.g. XiphComment and ID3v1),
|
||||
* only the first one (in the order XiphComment, ID3v2, ID3v1) 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, a XiphComment will be created.
|
||||
*/
|
||||
void fromDict(const TagDict &);
|
||||
|
||||
/*!
|
||||
* Returns the FLAC::Properties for this file. If no audio properties
|
||||
* were read then this will return a null pointer.
|
||||
|
||||
Reference in New Issue
Block a user