mirror of
https://github.com/taglib/taglib.git
synced 2025-05-27 21:20:26 -04:00
Added setProperties implementation to TagUnion (#813)
Added setProperties support in TagUnion
This commit is contained in:
parent
6048cdef3e
commit
2052cda5fb
@ -118,6 +118,46 @@ namespace TagLib
|
||||
}
|
||||
}
|
||||
|
||||
template <size_t COUNT>
|
||||
PropertyMap TagUnion<COUNT>::setProperties(const PropertyMap &properties)
|
||||
{
|
||||
//Record unassigned properties for each tag in the union
|
||||
std::vector<PropertyMap> returnCandidates;
|
||||
for (size_t i = 0; i < COUNT; ++i) {
|
||||
if (d->tags[i])
|
||||
returnCandidates.insert(returnCandidates.end(),
|
||||
d->tags[i]->setProperties(properties));
|
||||
}
|
||||
|
||||
if (!returnCandidates.empty()) {
|
||||
//Only one tag present, return its unassigned properties
|
||||
if (returnCandidates.size() == 1) {
|
||||
return returnCandidates.front();
|
||||
}
|
||||
|
||||
//Multiple tags in union:
|
||||
//if a property has been assigned in any member tag
|
||||
//remove it from ignored properties to return
|
||||
PropertyMap propertiesCopy(properties);
|
||||
for (std::vector<PropertyMap>::iterator i = returnCandidates.begin();
|
||||
i != returnCandidates.end(); i++) {
|
||||
for (PropertyMap::Iterator j = propertiesCopy.begin();
|
||||
j != propertiesCopy.end();) {
|
||||
if (!i->contains(j->first)) {
|
||||
j = propertiesCopy.erase(j->first).begin();
|
||||
}
|
||||
else {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//No assignments made by union member tags.
|
||||
//Return input (this should not happen)
|
||||
return properties;
|
||||
}
|
||||
|
||||
template <size_t COUNT>
|
||||
String TagUnion<COUNT>::title() const
|
||||
{
|
||||
|
@ -58,8 +58,8 @@ namespace TagLib {
|
||||
void set(size_t index, Tag *tag);
|
||||
|
||||
virtual PropertyMap properties() const;
|
||||
|
||||
virtual void removeUnsupportedProperties(const StringList& properties);
|
||||
virtual PropertyMap setProperties(const PropertyMap& properties);
|
||||
|
||||
virtual String title() const;
|
||||
virtual String artist() const;
|
||||
|
Loading…
Reference in New Issue
Block a user