From c46ecd186d9758be61af00d70ab35f99e913898f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= <lalinsky@gmail.com> Date: Sat, 20 Oct 2012 09:30:26 +0200 Subject: [PATCH] Make the PropertyMap accessor methods virtual --- taglib/tag.h | 3 -- taglib/toolkit/tfile.cpp | 107 +-------------------------------------- taglib/toolkit/tfile.h | 10 ++-- 3 files changed, 6 insertions(+), 114 deletions(-) diff --git a/taglib/tag.h b/taglib/tag.h index 76c9a82a..93bbfb15 100644 --- a/taglib/tag.h +++ b/taglib/tag.h @@ -64,9 +64,6 @@ namespace TagLib { * Removes unsupported properties, or a subset of them, from the tag. * The parameter \a properties must contain only entries from * properties().unsupportedData(). - * BIC: Will become virtual in future releases. Currently the non-virtual - * standard implementation of TagLib::Tag does nothing, since there are - * no unsupported elements. */ void removeUnsupportedProperties(const StringList& properties); diff --git a/taglib/toolkit/tfile.cpp b/taglib/toolkit/tfile.cpp index 8d7ccdc9..e6062199 100644 --- a/taglib/toolkit/tfile.cpp +++ b/taglib/toolkit/tfile.cpp @@ -119,120 +119,17 @@ FileName File::name() const PropertyMap File::properties() const { - // ugly workaround until this method is virtual - if(dynamic_cast<const APE::File* >(this)) - return dynamic_cast<const APE::File* >(this)->properties(); - if(dynamic_cast<const FLAC::File* >(this)) - return dynamic_cast<const FLAC::File* >(this)->properties(); - if(dynamic_cast<const IT::File* >(this)) - return dynamic_cast<const IT::File* >(this)->properties(); - if(dynamic_cast<const Mod::File* >(this)) - return dynamic_cast<const Mod::File* >(this)->properties(); - if(dynamic_cast<const MPC::File* >(this)) - return dynamic_cast<const MPC::File* >(this)->properties(); - if(dynamic_cast<const MPEG::File* >(this)) - return dynamic_cast<const MPEG::File* >(this)->properties(); - if(dynamic_cast<const Ogg::FLAC::File* >(this)) - return dynamic_cast<const Ogg::FLAC::File* >(this)->properties(); - if(dynamic_cast<const Ogg::Speex::File* >(this)) - return dynamic_cast<const Ogg::Speex::File* >(this)->properties(); - if(dynamic_cast<const Ogg::Opus::File* >(this)) - return dynamic_cast<const Ogg::Opus::File* >(this)->properties(); - if(dynamic_cast<const Ogg::Vorbis::File* >(this)) - return dynamic_cast<const Ogg::Vorbis::File* >(this)->properties(); - if(dynamic_cast<const RIFF::AIFF::File* >(this)) - return dynamic_cast<const RIFF::AIFF::File* >(this)->properties(); - if(dynamic_cast<const RIFF::WAV::File* >(this)) - return dynamic_cast<const RIFF::WAV::File* >(this)->properties(); - if(dynamic_cast<const S3M::File* >(this)) - return dynamic_cast<const S3M::File* >(this)->properties(); - if(dynamic_cast<const TrueAudio::File* >(this)) - return dynamic_cast<const TrueAudio::File* >(this)->properties(); - if(dynamic_cast<const WavPack::File* >(this)) - return dynamic_cast<const WavPack::File* >(this)->properties(); - if(dynamic_cast<const XM::File* >(this)) - return dynamic_cast<const XM::File* >(this)->properties(); - // no specialized implementation available -> use generic one - // - ASF: ugly format, largely undocumented, not worth implementing - // dict interface ... - // - MP4: taglib's MP4::Tag does not really support anything beyond - // the basic implementation, therefor we use just the default Tag - // interface return tag()->properties(); } void File::removeUnsupportedProperties(const StringList &properties) { - // here we only consider those formats that could possibly contain - // unsupported properties - if(dynamic_cast<APE::File* >(this)) - dynamic_cast<APE::File* >(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast<FLAC::File* >(this)) - dynamic_cast<FLAC::File* >(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast<MPC::File* >(this)) - dynamic_cast<MPC::File* >(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast<MPEG::File* >(this)) - dynamic_cast<MPEG::File* >(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast<Ogg::FLAC::File* >(this)) - dynamic_cast<Ogg::FLAC::File* >(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast<Ogg::Speex::File* >(this)) - dynamic_cast<Ogg::Speex::File* >(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast<Ogg::Opus::File* >(this)) - dynamic_cast<Ogg::Opus::File* >(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast<Ogg::Vorbis::File* >(this)) - dynamic_cast<Ogg::Vorbis::File* >(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast<RIFF::AIFF::File* >(this)) - dynamic_cast<RIFF::AIFF::File* >(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast<RIFF::WAV::File* >(this)) - dynamic_cast<RIFF::WAV::File* >(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast<S3M::File* >(this)) - dynamic_cast<S3M::File* >(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast<TrueAudio::File* >(this)) - dynamic_cast<TrueAudio::File* >(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast<WavPack::File* >(this)) - dynamic_cast<WavPack::File* >(this)->removeUnsupportedProperties(properties); - else if(dynamic_cast<XM::File* >(this)) - dynamic_cast<XM::File* >(this)->removeUnsupportedProperties(properties); - else - tag()->removeUnsupportedProperties(properties); + tag()->removeUnsupportedProperties(properties); } PropertyMap File::setProperties(const PropertyMap &properties) { - if(dynamic_cast<APE::File* >(this)) - return dynamic_cast<APE::File* >(this)->setProperties(properties); - else if(dynamic_cast<FLAC::File* >(this)) - return dynamic_cast<FLAC::File* >(this)->setProperties(properties); - else if(dynamic_cast<IT::File* >(this)) - return dynamic_cast<IT::File* >(this)->setProperties(properties); - else if(dynamic_cast<Mod::File* >(this)) - return dynamic_cast<Mod::File* >(this)->setProperties(properties); - else if(dynamic_cast<MPC::File* >(this)) - return dynamic_cast<MPC::File* >(this)->setProperties(properties); - else if(dynamic_cast<MPEG::File* >(this)) - return dynamic_cast<MPEG::File* >(this)->setProperties(properties); - else if(dynamic_cast<Ogg::FLAC::File* >(this)) - return dynamic_cast<Ogg::FLAC::File* >(this)->setProperties(properties); - else if(dynamic_cast<Ogg::Speex::File* >(this)) - return dynamic_cast<Ogg::Speex::File* >(this)->setProperties(properties); - else if(dynamic_cast<Ogg::Opus::File* >(this)) - return dynamic_cast<Ogg::Opus::File* >(this)->setProperties(properties); - else if(dynamic_cast<Ogg::Vorbis::File* >(this)) - return dynamic_cast<Ogg::Vorbis::File* >(this)->setProperties(properties); - else if(dynamic_cast<RIFF::AIFF::File* >(this)) - return dynamic_cast<RIFF::AIFF::File* >(this)->setProperties(properties); - else if(dynamic_cast<RIFF::WAV::File* >(this)) - return dynamic_cast<RIFF::WAV::File* >(this)->setProperties(properties); - else if(dynamic_cast<S3M::File* >(this)) - return dynamic_cast<S3M::File* >(this)->setProperties(properties); - else if(dynamic_cast<TrueAudio::File* >(this)) - return dynamic_cast<TrueAudio::File* >(this)->setProperties(properties); - else if(dynamic_cast<WavPack::File* >(this)) - return dynamic_cast<WavPack::File* >(this)->setProperties(properties); - else if(dynamic_cast<XM::File* >(this)) - return dynamic_cast<XM::File* >(this)->setProperties(properties); - else - return tag()->setProperties(properties); + return tag()->setProperties(properties); } ByteVector File::readBlock(ulong length) diff --git a/taglib/toolkit/tfile.h b/taglib/toolkit/tfile.h index 7e6f2b93..1dfab498 100644 --- a/taglib/toolkit/tfile.h +++ b/taglib/toolkit/tfile.h @@ -86,17 +86,15 @@ namespace TagLib { * format, the returend map's unsupportedData() list will contain one entry identifying * that object (e.g. the frame type for ID3v2 tags). Use removeUnsupportedProperties() * to remove (a subset of) them. - * BIC: Will be made virtual in future releases. */ - PropertyMap properties() const; + virtual PropertyMap properties() const; /*! * Removes unsupported properties, or a subset of them, from the file's metadata. * The parameter \a properties must contain only entries from * properties().unsupportedData(). - * BIC: Will be mad virtual in future releases. */ - void removeUnsupportedProperties(const StringList& properties); + virtual void removeUnsupportedProperties(const StringList& properties); /*! * Sets the tags of this File to those specified in \a properties. Calls the @@ -105,9 +103,9 @@ namespace TagLib { * If some value(s) could not be written imported to the specific metadata format, * the returned PropertyMap will contain those value(s). Otherwise it will be empty, * indicating that no problems occured. - * BIC: will become pure virtual in the future */ - PropertyMap setProperties(const PropertyMap &properties); + virtual PropertyMap setProperties(const PropertyMap &properties); + /*! * Returns a pointer to this file's audio properties. This should be * reimplemented in the concrete subclasses. If no audio properties were