Implemented dict interface for more formats.

Now supported: MOD files (IT, MOD, S3M, XM), RIFF files
(AIFF, WAV), TrueAudio, WavPack.
This commit is contained in:
Michael Helmling
2011-11-02 21:02:35 +01:00
parent 292a377d1e
commit 0eaf3a3fbd
20 changed files with 315 additions and 29 deletions

View File

@ -31,6 +31,7 @@
#include <tstring.h>
#include <tdebug.h>
#include <tagunion.h>
#include <tstringlist.h>
#include "trueaudiofile.h"
#include "id3v1tag.h"
@ -126,6 +127,27 @@ TagLib::Tag *TrueAudio::File::tag() const
return &d->tag;
}
TagLib::TagDict TrueAudio::File::toDict(void) const
{
// once Tag::toDict() is virtual, this case distinction could actually be done
// within TagUnion.
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 TrueAudio::File::fromDict(const TagDict &dict)
{
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<ID3v2::Tag>(ID3v2Index, true)->fromDict(dict);
}
TrueAudio::Properties *TrueAudio::File::audioProperties() const
{
return d->properties;

View File

@ -124,6 +124,20 @@ namespace TagLib {
*/
virtual TagLib::Tag *tag() const;
/*!
* Implements the unified tag dictionary interface -- export function.
* If the file contains both ID3v1 and v2 tags, only ID3v2 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, ID3v2 will be created.
*/
void fromDict(const TagDict &);
/*!
* Returns the TrueAudio::Properties for this file. If no audio properties
* were read then this will return a null pointer.