Make PropertyMap::unsupportedData() const

This commit is contained in:
Urs Fleisch 2023-11-24 06:58:49 +01:00
parent 3d67b139e4
commit 8b564baf01
11 changed files with 28 additions and 19 deletions

View File

@ -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

View File

@ -305,7 +305,7 @@ PropertyMap ASF::Tag::properties() const
}
}
else {
props.unsupportedData().append(k);
props.addUnsupportedData(k);
}
}
return props;

View File

@ -478,7 +478,7 @@ PropertyMap MP4::Tag::properties() const
props[key] = value;
}
else {
props.unsupportedData().append(k);
props.addUnsupportedData(k);
}
}
return props;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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(","));

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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)

View File

@ -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.