mirror of
https://github.com/taglib/taglib.git
synced 2025-07-14 11:04:17 -04:00
Provide properties methods on FileRef, make FileRef non-virtual
Use of FileRef::file() is discouraged, but was necessary to access the properties. It was also not clear whether to access the properties via tag() or file(). With the property methods on FileRef, it should become the "simple usage" interface it was meant to be. As the destructor was the only virtual method on FileRef, it is now made non-virtual. Probably, it is not useful as a virtual base class.
This commit is contained in:
@ -55,7 +55,7 @@ int main(int argc, char *argv[])
|
||||
cout << "track - \"" << tag->track() << "\"" << endl;
|
||||
cout << "genre - \"" << tag->genre() << "\"" << endl;
|
||||
|
||||
TagLib::PropertyMap tags = f.file()->properties();
|
||||
TagLib::PropertyMap tags = f.properties();
|
||||
|
||||
unsigned int longest = 0;
|
||||
for(auto i = tags.cbegin(); i != tags.cend(); ++i) {
|
||||
@ -71,9 +71,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
TagLib::StringList names = f.file()->complexPropertyKeys();
|
||||
TagLib::StringList names = f.complexPropertyKeys();
|
||||
for(const auto &name : names) {
|
||||
const auto& properties = f.file()->complexProperties(name);
|
||||
const auto& properties = f.complexProperties(name);
|
||||
for(const auto &property : properties) {
|
||||
cout << name << ":" << endl;
|
||||
for(const auto &[key, value] : property) {
|
||||
|
@ -122,10 +122,9 @@ int main(int argc, char *argv[])
|
||||
TagLib::String value = argv[i + 1];
|
||||
int numArgsConsumed = 2;
|
||||
|
||||
TagLib::List<TagLib::FileRef>::ConstIterator it;
|
||||
for(it = fileList.cbegin(); it != fileList.cend(); ++it) {
|
||||
for(auto &f : fileList) {
|
||||
|
||||
TagLib::Tag *t = (*it).tag();
|
||||
TagLib::Tag *t = f.tag();
|
||||
|
||||
switch (field) {
|
||||
case 't':
|
||||
@ -152,7 +151,7 @@ int main(int argc, char *argv[])
|
||||
case 'R':
|
||||
case 'I':
|
||||
if(i + 2 < argc) {
|
||||
TagLib::PropertyMap map = (*it).file()->properties ();
|
||||
TagLib::PropertyMap map = f.properties();
|
||||
if(field == 'R') {
|
||||
map.replace(value, TagLib::String(argv[i + 2]));
|
||||
}
|
||||
@ -160,16 +159,16 @@ int main(int argc, char *argv[])
|
||||
map.insert(value, TagLib::String(argv[i + 2]));
|
||||
}
|
||||
numArgsConsumed = 3;
|
||||
checkForRejectedProperties((*it).file()->setProperties(map));
|
||||
checkForRejectedProperties(f.setProperties(map));
|
||||
}
|
||||
else {
|
||||
usage();
|
||||
}
|
||||
break;
|
||||
case 'D': {
|
||||
TagLib::PropertyMap map = (*it).file()->properties();
|
||||
TagLib::PropertyMap map = f.properties();
|
||||
map.erase(value);
|
||||
checkForRejectedProperties((*it).file()->setProperties(map));
|
||||
checkForRejectedProperties(f.setProperties(map));
|
||||
break;
|
||||
}
|
||||
case 'p': {
|
||||
@ -190,7 +189,7 @@ int main(int argc, char *argv[])
|
||||
TagLib::String mimeType = data.startsWith("\x89PNG\x0d\x0a\x1a\x0a")
|
||||
? "image/png" : "image/jpeg";
|
||||
TagLib::String description(argv[i + 2]);
|
||||
it->file()->setComplexProperties("PICTURE", {
|
||||
f.setComplexProperties("PICTURE", {
|
||||
{
|
||||
{"data", data},
|
||||
{"pictureType", "Front Cover"},
|
||||
@ -201,7 +200,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else {
|
||||
// empty value, remove pictures
|
||||
it->file()->setComplexProperties("PICTURE", {});
|
||||
f.setComplexProperties("PICTURE", {});
|
||||
}
|
||||
}
|
||||
else {
|
||||
@ -220,9 +219,8 @@ int main(int argc, char *argv[])
|
||||
usage();
|
||||
}
|
||||
|
||||
TagLib::List<TagLib::FileRef>::ConstIterator it;
|
||||
for(it = fileList.cbegin(); it != fileList.cend(); ++it)
|
||||
(*it).file()->save();
|
||||
for(auto &f : fileList)
|
||||
f.save();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user