From 8b564baf0177c5a2dfe93e99383f23503daa7c94 Mon Sep 17 00:00:00 2001 From: Urs Fleisch Date: Fri, 24 Nov 2023 06:58:49 +0100 Subject: [PATCH] Make PropertyMap::unsupportedData() const --- taglib/ape/apetag.cpp | 2 +- taglib/asf/asftag.cpp | 2 +- taglib/mp4/mp4tag.cpp | 2 +- taglib/mpeg/id3v2/frames/chapterframe.cpp | 2 +- taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp | 2 +- taglib/mpeg/id3v2/frames/textidentificationframe.cpp | 10 +++++----- .../mpeg/id3v2/frames/uniquefileidentifierframe.cpp | 2 +- taglib/mpeg/id3v2/frames/urllinkframe.cpp | 2 +- taglib/mpeg/id3v2/id3v2frame.cpp | 4 ++-- taglib/toolkit/tpropertymap.cpp | 7 ++++++- taglib/toolkit/tpropertymap.h | 12 ++++++++---- 11 files changed, 28 insertions(+), 19 deletions(-) diff --git a/taglib/ape/apetag.cpp b/taglib/ape/apetag.cpp index 98aff334..f839a91d 100644 --- a/taglib/ape/apetag.cpp +++ b/taglib/ape/apetag.cpp @@ -207,7 +207,7 @@ PropertyMap APE::Tag::properties() const // if the item is Binary or Locator, or if the key is an invalid string, // add to unsupportedData if(item.type() != Item::Text || tagName.isEmpty()) { - properties.unsupportedData().append(tag); + properties.addUnsupportedData(tag); } else { // Some tags need to be handled specially diff --git a/taglib/asf/asftag.cpp b/taglib/asf/asftag.cpp index 783c3217..1c930be8 100644 --- a/taglib/asf/asftag.cpp +++ b/taglib/asf/asftag.cpp @@ -305,7 +305,7 @@ PropertyMap ASF::Tag::properties() const } } else { - props.unsupportedData().append(k); + props.addUnsupportedData(k); } } return props; diff --git a/taglib/mp4/mp4tag.cpp b/taglib/mp4/mp4tag.cpp index eef637a0..aa475fae 100644 --- a/taglib/mp4/mp4tag.cpp +++ b/taglib/mp4/mp4tag.cpp @@ -478,7 +478,7 @@ PropertyMap MP4::Tag::properties() const props[key] = value; } else { - props.unsupportedData().append(k); + props.addUnsupportedData(k); } } return props; diff --git a/taglib/mpeg/id3v2/frames/chapterframe.cpp b/taglib/mpeg/id3v2/frames/chapterframe.cpp index 22a90f06..10dcc556 100644 --- a/taglib/mpeg/id3v2/frames/chapterframe.cpp +++ b/taglib/mpeg/id3v2/frames/chapterframe.cpp @@ -209,7 +209,7 @@ PropertyMap ChapterFrame::asProperties() const { PropertyMap map; - map.unsupportedData().append(frameID() + String("/") + d->elementID); + map.addUnsupportedData(frameID() + String("/") + d->elementID); return map; } diff --git a/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp b/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp index 831f7ca5..f45792db 100644 --- a/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp +++ b/taglib/mpeg/id3v2/frames/tableofcontentsframe.cpp @@ -236,7 +236,7 @@ PropertyMap TableOfContentsFrame::asProperties() const { PropertyMap map; - map.unsupportedData().append(frameID() + String("/") + d->elementID); + map.addUnsupportedData(frameID() + String("/") + d->elementID); return map; } diff --git a/taglib/mpeg/id3v2/frames/textidentificationframe.cpp b/taglib/mpeg/id3v2/frames/textidentificationframe.cpp index 9ead4d62..7adcecc7 100644 --- a/taglib/mpeg/id3v2/frames/textidentificationframe.cpp +++ b/taglib/mpeg/id3v2/frames/textidentificationframe.cpp @@ -171,7 +171,7 @@ PropertyMap TextIdentificationFrame::asProperties() const PropertyMap map; String tagName = frameIDToKey(frameID()); if(tagName.isEmpty()) { - map.unsupportedData().append(frameID()); + map.addUnsupportedData(frameID()); return map; } StringList values = fieldList(); @@ -304,7 +304,7 @@ PropertyMap TextIdentificationFrame::makeTIPLProperties() const PropertyMap map; if(fieldList().size() % 2 != 0){ // according to the ID3 spec, TIPL must contain an even number of entries - map.unsupportedData().append(frameID()); + map.addUnsupportedData(frameID()); return map; } const StringList l = fieldList(); @@ -317,7 +317,7 @@ PropertyMap TextIdentificationFrame::makeTIPLProperties() const else { // invalid involved role -> mark whole frame as unsupported in order to be consistent with writing map.clear(); - map.unsupportedData().append(frameID()); + map.addUnsupportedData(frameID()); return map; } } @@ -329,7 +329,7 @@ PropertyMap TextIdentificationFrame::makeTMCLProperties() const PropertyMap map; if(fieldList().size() % 2 != 0){ // according to the ID3 spec, TMCL must contain an even number of entries - map.unsupportedData().append(frameID()); + map.addUnsupportedData(frameID()); return map; } const StringList l = fieldList(); @@ -338,7 +338,7 @@ PropertyMap TextIdentificationFrame::makeTMCLProperties() const if(instrument.isEmpty()) { // instrument is not a valid key -> frame unsupported map.clear(); - map.unsupportedData().append(frameID()); + map.addUnsupportedData(frameID()); return map; } map.insert(L"PERFORMER:" + instrument, (++it)->split(",")); diff --git a/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.cpp b/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.cpp index 1d5591a3..33d8fd50 100644 --- a/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.cpp +++ b/taglib/mpeg/id3v2/frames/uniquefileidentifierframe.cpp @@ -95,7 +95,7 @@ PropertyMap UniqueFileIdentifierFrame::asProperties() const map.insert("MUSICBRAINZ_TRACKID", String(d->identifier)); } else { - map.unsupportedData().append(frameID() + String("/") + d->owner); + map.addUnsupportedData(frameID() + String("/") + d->owner); } return map; } diff --git a/taglib/mpeg/id3v2/frames/urllinkframe.cpp b/taglib/mpeg/id3v2/frames/urllinkframe.cpp index c5a3f7fd..d7071c65 100644 --- a/taglib/mpeg/id3v2/frames/urllinkframe.cpp +++ b/taglib/mpeg/id3v2/frames/urllinkframe.cpp @@ -90,7 +90,7 @@ PropertyMap UrlLinkFrame::asProperties() const PropertyMap map; if(key.isEmpty()) // unknown W*** frame - this normally shouldn't happen - map.unsupportedData().append(frameID()); + map.addUnsupportedData(frameID()); else map.insert(key, url()); return map; diff --git a/taglib/mpeg/id3v2/id3v2frame.cpp b/taglib/mpeg/id3v2/id3v2frame.cpp index 04b45711..e8ebe12b 100644 --- a/taglib/mpeg/id3v2/id3v2frame.cpp +++ b/taglib/mpeg/id3v2/id3v2frame.cpp @@ -364,12 +364,12 @@ PropertyMap Frame::asProperties() const { if(dynamic_cast< const UnknownFrame *>(this)) { PropertyMap m; - m.unsupportedData().append("UNKNOWN/" + frameID()); + m.addUnsupportedData("UNKNOWN/" + frameID()); return m; } const ByteVector &id = frameID(); PropertyMap m; - m.unsupportedData().append(id); + m.addUnsupportedData(id); return m; } diff --git a/taglib/toolkit/tpropertymap.cpp b/taglib/toolkit/tpropertymap.cpp index f01da2b5..081a8571 100644 --- a/taglib/toolkit/tpropertymap.cpp +++ b/taglib/toolkit/tpropertymap.cpp @@ -179,11 +179,16 @@ void PropertyMap::removeEmpty() *this = m; } -StringList &PropertyMap::unsupportedData() +const StringList &PropertyMap::unsupportedData() const { return d->unsupported; } +void PropertyMap::addUnsupportedData(const String &key) +{ + d->unsupported.append(key); +} + PropertyMap &PropertyMap::operator=(const PropertyMap &other) { if(this == &other) diff --git a/taglib/toolkit/tpropertymap.h b/taglib/toolkit/tpropertymap.h index 5d390788..c8683fac 100644 --- a/taglib/toolkit/tpropertymap.h +++ b/taglib/toolkit/tpropertymap.h @@ -236,11 +236,15 @@ namespace TagLib { * You can remove items from the returned list, which tells TagLib to remove * those unsupported elements if you call File::setProperties() with the * same PropertyMap as argument. - * - * \deprecated */ - // TODO: Returning mutable references to internal data structures is a bad idea. - StringList &unsupportedData(); + const StringList &unsupportedData() const; + + /*! + * Add property \a key to list of unsupported data. + * + * \see unsupportedData() + */ + void addUnsupportedData(const String &key); /*! * Removes all entries which have an empty value list.