]> granicus.if.org Git - taglib/commitdiff
Use PropertyMap in tagreader
authorLukáš Lalinský <lalinsky@gmail.com>
Wed, 21 Nov 2012 13:40:26 +0000 (14:40 +0100)
committerLukáš Lalinský <lalinsky@gmail.com>
Wed, 21 Nov 2012 13:40:26 +0000 (14:40 +0100)
examples/tagreader.cpp

index 76fe0d1a3bf54ec3218b18a6ac2f249d11e79ef0..cc978ebad23af0b5f6f95f823d6380750415f7e0 100644 (file)
  */
 
 #include <iostream>
+#include <iomanip>
 #include <stdio.h>
 
 #include <fileref.h>
 #include <tag.h>
+#include <tpropertymap.h>
 
 using namespace std;
 
@@ -49,7 +51,7 @@ int main(int argc, char *argv[])
 
       TagLib::Tag *tag = f.tag();
 
-      cout << "-- TAG --" << endl;
+      cout << "-- TAG (basic) --" << endl;
       cout << "title   - \"" << tag->title()   << "\"" << endl;
       cout << "artist  - \"" << tag->artist()  << "\"" << endl;
       cout << "album   - \"" << tag->album()   << "\"" << endl;
@@ -57,6 +59,23 @@ int main(int argc, char *argv[])
       cout << "comment - \"" << tag->comment() << "\"" << endl;
       cout << "track   - \"" << tag->track()   << "\"" << endl;
       cout << "genre   - \"" << tag->genre()   << "\"" << endl;
+
+      TagLib::PropertyMap tags = f.file()->properties();
+
+      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 << "-- TAG (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;
+        }
+      }
+
     }
 
     if(!f.isNull() && f.audioProperties()) {