From d376aa5fa9a2767c83ebfe2bdac50642cfbad96d Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Sun, 19 Aug 2012 23:10:56 +0200 Subject: Add read tag program. Fix uninitialized error. --- AudioFile.cpp | 2 +- Makefile | 10 ++++++++++ readtags.cpp | 30 ++++++++++++++++++++++++++++++ test-main.cpp | 30 ------------------------------ 4 files changed, 41 insertions(+), 31 deletions(-) create mode 100644 Makefile create mode 100644 readtags.cpp delete mode 100644 test-main.cpp diff --git a/AudioFile.cpp b/AudioFile.cpp index 542d0c6..5157b11 100644 --- a/AudioFile.cpp +++ b/AudioFile.cpp @@ -19,7 +19,7 @@ template inline T extractTag(M &map, const char *key) { - T ret; + T ret = 0; std::stringstream stream(extractTag(map, key)); stream >> ret; return ret; diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..dcf72b2 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +LDFLAGS += $(shell pkg-config --libs taglib) +CXXFLAGS ?= -O3 -pipe -fomit-frame-pointer -march=native +CXXFLAGS += $(shell pkg-config --cflags taglib) + + +all: readtags organizemusic + +readtags: AudioFile.cpp AudioFile.h readtags.cpp + +organizemusic: AudioFile.cpp AudioFile.h organizemusic.cpp diff --git a/readtags.cpp b/readtags.cpp new file mode 100644 index 0000000..b5a3ef4 --- /dev/null +++ b/readtags.cpp @@ -0,0 +1,30 @@ +#include "AudioFile.h" + +#include + +using namespace std; + +int main(int argc, char *argv[]) +{ + for (int i = 1; i < argc; ++i) { + AudioFile f(argv[i]); + if (!f.isValid()) { + cout << argv[i] << " is not valid." << endl; + continue; + } + cout << "Filename: " << f.filename() << endl; + cout << "Artist: " << f.artist() << endl; + cout << "Composer: " << f.composer() << endl; + cout << "Album: " << f.album() << endl; + cout << "Album Artist: " << f.albumArtist() << endl; + cout << "Title: " << f.title() << endl; + cout << "Genre: " << f.genre() << endl; + cout << "Comment: " << f.comment() << endl; + cout << "Track: " << f.track() << endl; + cout << "Disc: " << f.disc() << endl; + cout << "Bpm: " << f.bpm() << endl; + cout << "Year: " << f.year() << endl; + cout << "Compilation: " << f.compilation() << endl; + cout << endl; + } +} diff --git a/test-main.cpp b/test-main.cpp deleted file mode 100644 index b5a3ef4..0000000 --- a/test-main.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "AudioFile.h" - -#include - -using namespace std; - -int main(int argc, char *argv[]) -{ - for (int i = 1; i < argc; ++i) { - AudioFile f(argv[i]); - if (!f.isValid()) { - cout << argv[i] << " is not valid." << endl; - continue; - } - cout << "Filename: " << f.filename() << endl; - cout << "Artist: " << f.artist() << endl; - cout << "Composer: " << f.composer() << endl; - cout << "Album: " << f.album() << endl; - cout << "Album Artist: " << f.albumArtist() << endl; - cout << "Title: " << f.title() << endl; - cout << "Genre: " << f.genre() << endl; - cout << "Comment: " << f.comment() << endl; - cout << "Track: " << f.track() << endl; - cout << "Disc: " << f.disc() << endl; - cout << "Bpm: " << f.bpm() << endl; - cout << "Year: " << f.year() << endl; - cout << "Compilation: " << f.compilation() << endl; - cout << endl; - } -} -- cgit v1.2.3-59-g8ed1b