diff options
author | Max Kellermann <max@duempel.org> | 2014-04-26 22:59:21 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-04-26 22:59:21 +0200 |
commit | fcb55f841ae4772ee94f80eed5b45947ef644337 (patch) | |
tree | 3f3b2f09d055439febb9b3a973578f60ad25d823 /src/db/DatabasePrint.cxx | |
parent | 154e601f4e99e5334005279eb64ba6a541d9e844 (diff) |
DatabasePrint: move PrintSongCount() to Count.cxx
Diffstat (limited to 'src/db/DatabasePrint.cxx')
-rw-r--r-- | src/db/DatabasePrint.cxx | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/src/db/DatabasePrint.cxx b/src/db/DatabasePrint.cxx index c65de373f..f6663311e 100644 --- a/src/db/DatabasePrint.cxx +++ b/src/db/DatabasePrint.cxx @@ -168,54 +168,6 @@ db_selection_print(Client &client, const DatabaseSelection &selection, return db->Visit(selection, d, s, p, error); } -struct SearchStats { - unsigned n_songs; - unsigned long total_time_s; -}; - -static void -PrintSearchStats(Client &client, const SearchStats &stats) -{ - client_printf(client, - "songs: %u\n" - "playtime: %lu\n", - stats.n_songs, stats.total_time_s); -} - -static bool -stats_visitor_song(SearchStats &stats, const LightSong &song) -{ - stats.n_songs++; - stats.total_time_s += song.GetDuration(); - - return true; -} - -bool -PrintSongCount(Client &client, const char *name, - const SongFilter *filter, - Error &error) -{ - const Database *db = client.GetDatabase(error); - if (db == nullptr) - return false; - - const DatabaseSelection selection(name, true, filter); - - SearchStats stats; - stats.n_songs = 0; - stats.total_time_s = 0; - - using namespace std::placeholders; - const auto f = std::bind(stats_visitor_song, std::ref(stats), - _1); - if (!db->Visit(selection, f, error)) - return false; - - PrintSearchStats(client, stats); - return true; -} - static bool PrintSongURIVisitor(Client &client, const LightSong &song) { |