mirror of
https://github.com/taglib/taglib.git
synced 2025-08-15 10:44:39 -04:00
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:
@ -70,6 +70,16 @@ Mod::Properties *Mod::File::audioProperties() const
|
||||
return &d->properties;
|
||||
}
|
||||
|
||||
TagDict Mod::File::toDict() const
|
||||
{
|
||||
return d->tag.toDict();
|
||||
}
|
||||
|
||||
void Mod::File::fromDict(const TagDict &tagDict)
|
||||
{
|
||||
d->tag.fromDict(tagDict);
|
||||
}
|
||||
|
||||
bool Mod::File::save()
|
||||
{
|
||||
if(readOnly()) {
|
||||
|
@ -61,6 +61,17 @@ namespace TagLib {
|
||||
|
||||
Mod::Tag *tag() const;
|
||||
|
||||
/*!
|
||||
* Implements the unified tag dictionary interface -- export function.
|
||||
* Forwards to Mod::Tag::toDict().
|
||||
*/
|
||||
TagDict toDict() const;
|
||||
|
||||
/*!
|
||||
* Implements the unified tag dictionary interface -- import function.
|
||||
* Forwards to Mod::Tag::fromDict().
|
||||
*/
|
||||
void fromDict(const TagDict &);
|
||||
/*!
|
||||
* Returns the Mod::Properties for this file. If no audio properties
|
||||
* were read then this will return a null pointer.
|
||||
|
@ -20,7 +20,7 @@
|
||||
***************************************************************************/
|
||||
|
||||
#include "modtag.h"
|
||||
|
||||
#include "tstringlist.h"
|
||||
using namespace TagLib;
|
||||
using namespace Mod;
|
||||
|
||||
@ -120,3 +120,31 @@ void Mod::Tag::setTrackerName(const String &trackerName)
|
||||
{
|
||||
d->trackerName = trackerName;
|
||||
}
|
||||
|
||||
TagDict Mod::Tag::toDict() const
|
||||
{
|
||||
TagDict dict;
|
||||
dict["TITLE"] = d->title;
|
||||
dict["COMMENT"] = d->comment;
|
||||
if (!(d->trackerName == String::null))
|
||||
dict["TRACKERNAME"] = d->trackerName;
|
||||
return dict;
|
||||
}
|
||||
|
||||
void Mod::Tag::fromDict(const TagDict &tagDict)
|
||||
{
|
||||
if (tagDict.contains("TITLE") && !tagDict["TITILE"].isEmpty())
|
||||
d->title = tagDict["TITLE"][0];
|
||||
else
|
||||
d->title = String::null;
|
||||
|
||||
if (tagDict.contains("COMMENT") && !tagDict["COMMENT"].isEmpty())
|
||||
d->comment = tagDict["COMMENT"][0];
|
||||
else
|
||||
d->comment = String::null;
|
||||
|
||||
if (tagDict.contains("TRACKERNAME") && !tagDict["TRACKERNAME"].isEmpty())
|
||||
d->trackerName = tagDict["TRACKERNAME"][0];
|
||||
else
|
||||
d->trackerName = String::null;
|
||||
}
|
||||
|
@ -159,6 +159,21 @@ namespace TagLib {
|
||||
*/
|
||||
void setTrackerName(const String &trackerName);
|
||||
|
||||
/*!
|
||||
* Implements the unified tag dictionary interface -- export function.
|
||||
* Since the module tag is very limited, the exported dict is as well.
|
||||
*/
|
||||
TagDict toDict() const;
|
||||
|
||||
/*!
|
||||
* Implements the unified tag dictionary interface -- import function.
|
||||
* Because of the limitations of the module file tag, any tags besides
|
||||
* COMMENT, TITLE and, if it is an XM file, TRACKERNAME, will be
|
||||
* ignored. Additionally, if the dict contains tags with multiple values,
|
||||
* all but the first will be ignored.
|
||||
*/
|
||||
void fromDict(const TagDict &);
|
||||
|
||||
private:
|
||||
Tag(const Tag &);
|
||||
Tag &operator=(const Tag &);
|
||||
|
Reference in New Issue
Block a user