*/
#include <iostream>
+#include <iomanip>
#include <string.h>
#include <stdio.h>
#include <fileref.h>
#include <tfile.h>
#include <tag.h>
+#include <tpropertymap.h>
using namespace std;
cout << " -g <genre>" << endl;
cout << " -y <year>" << endl;
cout << " -T <track>" << endl;
+ cout << " -R <tagname> <tagvalue>" << endl;
+ cout << " -I <tagname> <tagvalue>" << endl;
+ cout << " -D <tagname>" << endl;
cout << endl;
exit(1);
}
+void checkForRejectedProperties(const TagLib::PropertyMap &tags)
+{ // stolen from tagreader.cpp
+ if(tags.size() > 0) {
+ unsigned int longest = 0;
+ for(TagLib::PropertyMap::ConstIterator i = tags.begin(); i != tags.end(); ++i) {
+ if(i->first.size() > longest) {
+ longest = i->first.size();
+ }
+ }
+ cout << "-- rejected TAGs (properties) --" << endl;
+ for(TagLib::PropertyMap::ConstIterator i = tags.begin(); i != tags.end(); ++i) {
+ for(TagLib::StringList::ConstIterator j = i->second.begin(); j != i->second.end(); ++j) {
+ cout << left << std::setw(longest) << i->first << " - " << '"' << *j << '"' << endl;
+ }
+ }
+ }
+}
+
int main(int argc, char *argv[])
{
TagLib::List<TagLib::FileRef> fileList;
case 'T':
t->setTrack(value.toInt());
break;
+ case 'R':
+ case 'I':
+ if(i + 2 < argc) {
+ TagLib::PropertyMap map = (*it).file()->properties ();
+ if(field == 'R') {
+ map.replace(value, TagLib::String(argv[i + 2]));
+ }
+ else {
+ map.insert(value, TagLib::String(argv[i + 2]));
+ }
+ ++i;
+ checkForRejectedProperties((*it).file()->setProperties(map));
+ }
+ else {
+ usage();
+ }
+ break;
+ case 'D': {
+ TagLib::PropertyMap map = (*it).file()->properties();
+ map.erase(value);
+ checkForRejectedProperties((*it).file()->setProperties(map));
+ break;
+ }
default:
usage();
break;