diff --git a/taglib/ape/apefile.cpp b/taglib/ape/apefile.cpp index b3da1379..491e24d7 100644 --- a/taglib/ape/apefile.cpp +++ b/taglib/ape/apefile.cpp @@ -112,15 +112,6 @@ TagLib::Tag *APE::File::tag() const return &d->tag; } -PropertyMap APE::File::properties() const -{ - if(d->hasAPE) - return d->tag.access(ApeAPEIndex, false)->properties(); - if(d->hasID3v1) - return d->tag.access(ApeID3v1Index, false)->properties(); - return PropertyMap(); -} - void APE::File::removeUnsupportedProperties(const StringList &properties) { if(d->hasAPE) diff --git a/taglib/ape/apefile.h b/taglib/ape/apefile.h index cfee50da..cdd37062 100644 --- a/taglib/ape/apefile.h +++ b/taglib/ape/apefile.h @@ -113,13 +113,6 @@ namespace TagLib { */ virtual TagLib::Tag *tag() const; - /*! - * Implements the unified property interface -- export function. - * If the file contains both an APE and an ID3v1 tag, only APE - * will be converted to the PropertyMap. - */ - PropertyMap properties() const; - /*! * Removes unsupported properties. Forwards to the actual Tag's * removeUnsupportedProperties() function. diff --git a/taglib/flac/flacfile.cpp b/taglib/flac/flacfile.cpp index e0faa18d..ef0325e5 100644 --- a/taglib/flac/flacfile.cpp +++ b/taglib/flac/flacfile.cpp @@ -138,19 +138,6 @@ TagLib::Tag *FLAC::File::tag() const return &d->tag; } -PropertyMap FLAC::File::properties() const -{ - // once Tag::properties() is virtual, this case distinction could actually be done - // within TagUnion. - if(d->hasXiphComment) - return d->tag.access(FlacXiphIndex, false)->properties(); - if(d->hasID3v2) - return d->tag.access(FlacID3v2Index, false)->properties(); - if(d->hasID3v1) - return d->tag.access(FlacID3v1Index, false)->properties(); - return PropertyMap(); -} - void FLAC::File::removeUnsupportedProperties(const StringList &unsupported) { if(d->hasXiphComment) diff --git a/taglib/flac/flacfile.h b/taglib/flac/flacfile.h index cf91a21e..1cd01d49 100644 --- a/taglib/flac/flacfile.h +++ b/taglib/flac/flacfile.h @@ -110,14 +110,6 @@ namespace TagLib { */ virtual TagLib::Tag *tag() const; - /*! - * Implements the unified property 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 PropertyMap. - */ - PropertyMap properties() const; - void removeUnsupportedProperties(const StringList &); /*! diff --git a/taglib/mp4/mp4file.cpp b/taglib/mp4/mp4file.cpp index f41ee888..f6e15e65 100644 --- a/taglib/mp4/mp4file.cpp +++ b/taglib/mp4/mp4file.cpp @@ -91,21 +91,6 @@ MP4::File::tag() const return d->tag; } -PropertyMap MP4::File::properties() const -{ - return d->tag->properties(); -} - -void MP4::File::removeUnsupportedProperties(const StringList &properties) -{ - d->tag->removeUnsupportedProperties(properties); -} - -PropertyMap MP4::File::setProperties(const PropertyMap &properties) -{ - return d->tag->setProperties(properties); -} - MP4::Properties * MP4::File::audioProperties() const { diff --git a/taglib/mp4/mp4file.h b/taglib/mp4/mp4file.h index 17fd5a95..2ed3bea5 100644 --- a/taglib/mp4/mp4file.h +++ b/taglib/mp4/mp4file.h @@ -88,22 +88,6 @@ namespace TagLib { */ Tag *tag() const; - /*! - * Implements the unified property interface -- export function. - */ - PropertyMap properties() const; - - /*! - * Removes unsupported properties. Forwards to the actual Tag's - * removeUnsupportedProperties() function. - */ - void removeUnsupportedProperties(const StringList &properties); - - /*! - * Implements the unified property interface -- import function. - */ - PropertyMap setProperties(const PropertyMap &); - /*! * Returns the MP4 audio properties for this file. */ diff --git a/taglib/mpc/mpcfile.cpp b/taglib/mpc/mpcfile.cpp index b27fb8d2..2638df85 100644 --- a/taglib/mpc/mpcfile.cpp +++ b/taglib/mpc/mpcfile.cpp @@ -116,15 +116,6 @@ TagLib::Tag *MPC::File::tag() const return &d->tag; } -PropertyMap MPC::File::properties() const -{ - if(d->hasAPE) - return d->tag.access(MPCAPEIndex, false)->properties(); - if(d->hasID3v1) - return d->tag.access(MPCID3v1Index, false)->properties(); - return PropertyMap(); -} - void MPC::File::removeUnsupportedProperties(const StringList &properties) { if(d->hasAPE) diff --git a/taglib/mpc/mpcfile.h b/taglib/mpc/mpcfile.h index 887aa46d..1f47996f 100644 --- a/taglib/mpc/mpcfile.h +++ b/taglib/mpc/mpcfile.h @@ -113,13 +113,6 @@ namespace TagLib { */ virtual TagLib::Tag *tag() const; - /*! - * Implements the unified property interface -- export function. - * If the file contains both an APE and an ID3v1 tag, only the APE - * tag will be converted to the PropertyMap. - */ - PropertyMap properties() const; - void removeUnsupportedProperties(const StringList &properties); /*! diff --git a/taglib/mpeg/id3v2/id3v2tag.h b/taglib/mpeg/id3v2/id3v2tag.h index 6841bc5c..c58d4d86 100644 --- a/taglib/mpeg/id3v2/id3v2tag.h +++ b/taglib/mpeg/id3v2/id3v2tag.h @@ -326,7 +326,7 @@ namespace TagLib { * once, the description, separated by a "/". * */ - PropertyMap properties() const; + virtual PropertyMap properties() const; /*! * Removes unsupported frames given by \a properties. The elements of @@ -339,13 +339,13 @@ namespace TagLib { * - "UNKNOWN/" + frameID, for frames that could not be parsed by TagLib. * In that case, *all* unknown frames with the given ID will be removed. */ - void removeUnsupportedProperties(const StringList &properties); + virtual void removeUnsupportedProperties(const StringList &properties); /*! * Implements the unified property interface -- import function. * See the comments in properties(). */ - PropertyMap setProperties(const PropertyMap &); + virtual PropertyMap setProperties(const PropertyMap &); /*! * Render the tag back to binary data, suitable to be written to disk. diff --git a/taglib/mpeg/mpegfile.cpp b/taglib/mpeg/mpegfile.cpp index 1091ea14..5d1ac1fb 100644 --- a/taglib/mpeg/mpegfile.cpp +++ b/taglib/mpeg/mpegfile.cpp @@ -134,19 +134,6 @@ TagLib::Tag *MPEG::File::tag() const return &d->tag; } -PropertyMap MPEG::File::properties() const -{ - // once Tag::properties() is virtual, this case distinction could actually be done - // within TagUnion. - if(d->hasID3v2) - return d->tag.access(ID3v2Index, false)->properties(); - if(d->hasAPE) - return d->tag.access(APEIndex, false)->properties(); - if(d->hasID3v1) - return d->tag.access(ID3v1Index, false)->properties(); - return PropertyMap(); -} - void MPEG::File::removeUnsupportedProperties(const StringList &properties) { if(d->hasID3v2) diff --git a/taglib/mpeg/mpegfile.h b/taglib/mpeg/mpegfile.h index 725dc19d..068432ad 100644 --- a/taglib/mpeg/mpegfile.h +++ b/taglib/mpeg/mpegfile.h @@ -132,14 +132,6 @@ namespace TagLib { */ virtual Tag *tag() const; - /*! - * Implements the reading part of the unified property interface. - * If the file contains more than one tag, only the - * first one (in the order ID3v2, APE, ID3v1) will be converted to the - * PropertyMap. - */ - PropertyMap properties() const; - void removeUnsupportedProperties(const StringList &properties); /*! diff --git a/taglib/ogg/xiphcomment.h b/taglib/ogg/xiphcomment.h index 7fbc151d..bf94b69c 100644 --- a/taglib/ogg/xiphcomment.h +++ b/taglib/ogg/xiphcomment.h @@ -148,7 +148,7 @@ namespace TagLib { * comment is nothing more than a map from tag names to list of values, * as is the dict interface). */ - PropertyMap properties() const; + virtual PropertyMap properties() const; /*! * Implements the unified property interface -- import function. @@ -157,7 +157,7 @@ namespace TagLib { * containing '=' or '~') in which case the according values will * be contained in the returned PropertyMap. */ - PropertyMap setProperties(const PropertyMap&); + virtual PropertyMap setProperties(const PropertyMap&); /*! * Check if the given String is a valid Xiph comment key. diff --git a/taglib/tag.h b/taglib/tag.h index 96612110..693b38b4 100644 --- a/taglib/tag.h +++ b/taglib/tag.h @@ -58,14 +58,14 @@ namespace TagLib { * The default implementation in this class considers only the usual built-in * tags (artist, album, ...) and only one value per key. */ - PropertyMap properties() const; + virtual PropertyMap properties() const; /*! * Removes unsupported properties, or a subset of them, from the tag. * The parameter \a properties must contain only entries from * properties().unsupportedData(). */ - void removeUnsupportedProperties(const StringList& properties); + virtual void removeUnsupportedProperties(const StringList& properties); /*! * Sets the tags of this File to those specified in \a properties. This default @@ -73,7 +73,7 @@ namespace TagLib { * (artist, album, ...), and only one value per key; the rest will be contained * in the returned PropertyMap. */ - PropertyMap setProperties(const PropertyMap &properties); + virtual PropertyMap setProperties(const PropertyMap &properties); /*! * Returns the track name; if no track name is present in the tag diff --git a/taglib/tagunion.cpp b/taglib/tagunion.cpp index 52d7136b..4a5afd32 100644 --- a/taglib/tagunion.cpp +++ b/taglib/tagunion.cpp @@ -25,6 +25,7 @@ #include "tagunion.h" #include "tstringlist.h" +#include "tpropertymap.h" using namespace TagLib; @@ -102,6 +103,16 @@ void TagUnion::set(int index, Tag *tag) d->tags[index] = tag; } +PropertyMap TagUnion::properties() const +{ + for(uint i = 0; i < 3; ++i) { + if(tag(i)) { + return tag(i)->properties(); + } + } + return PropertyMap(); +} + String TagUnion::title() const { stringUnion(title); diff --git a/taglib/tagunion.h b/taglib/tagunion.h index e94d523a..98b4d338 100644 --- a/taglib/tagunion.h +++ b/taglib/tagunion.h @@ -56,6 +56,8 @@ namespace TagLib { void set(int index, Tag *tag); + virtual PropertyMap properties() const; + virtual String title() const; virtual String artist() const; virtual String album() const;