mirror of
https://github.com/taglib/taglib.git
synced 2025-06-04 01:28:21 -04:00
Implemented TagUnion::properties() and made Tag::*properties* virtual.
This allows to remove several default implementations in types using TagUnions.
This commit is contained in:
parent
b60b444d7b
commit
fa38c805f5
@ -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<APE::Tag>(ApeAPEIndex, false)->properties();
|
||||
if(d->hasID3v1)
|
||||
return d->tag.access<ID3v1::Tag>(ApeID3v1Index, false)->properties();
|
||||
return PropertyMap();
|
||||
}
|
||||
|
||||
void APE::File::removeUnsupportedProperties(const StringList &properties)
|
||||
{
|
||||
if(d->hasAPE)
|
||||
|
@ -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.
|
||||
|
@ -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<Ogg::XiphComment>(FlacXiphIndex, false)->properties();
|
||||
if(d->hasID3v2)
|
||||
return d->tag.access<ID3v2::Tag>(FlacID3v2Index, false)->properties();
|
||||
if(d->hasID3v1)
|
||||
return d->tag.access<ID3v1::Tag>(FlacID3v1Index, false)->properties();
|
||||
return PropertyMap();
|
||||
}
|
||||
|
||||
void FLAC::File::removeUnsupportedProperties(const StringList &unsupported)
|
||||
{
|
||||
if(d->hasXiphComment)
|
||||
|
@ -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 &);
|
||||
|
||||
/*!
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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.
|
||||
*/
|
||||
|
@ -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<APE::Tag>(MPCAPEIndex, false)->properties();
|
||||
if(d->hasID3v1)
|
||||
return d->tag.access<ID3v1::Tag>(MPCID3v1Index, false)->properties();
|
||||
return PropertyMap();
|
||||
}
|
||||
|
||||
void MPC::File::removeUnsupportedProperties(const StringList &properties)
|
||||
{
|
||||
if(d->hasAPE)
|
||||
|
@ -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);
|
||||
|
||||
/*!
|
||||
|
@ -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.
|
||||
|
@ -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<ID3v2::Tag>(ID3v2Index, false)->properties();
|
||||
if(d->hasAPE)
|
||||
return d->tag.access<APE::Tag>(APEIndex, false)->properties();
|
||||
if(d->hasID3v1)
|
||||
return d->tag.access<ID3v1::Tag>(ID3v1Index, false)->properties();
|
||||
return PropertyMap();
|
||||
}
|
||||
|
||||
void MPEG::File::removeUnsupportedProperties(const StringList &properties)
|
||||
{
|
||||
if(d->hasID3v2)
|
||||
|
@ -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);
|
||||
|
||||
/*!
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user