diff options
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | src/DatabaseCommands.cxx | 5 | ||||
-rw-r--r-- | src/DatabaseGlue.cxx | 1 | ||||
-rw-r--r-- | src/DatabasePlaylist.cxx | 8 | ||||
-rw-r--r-- | src/DatabasePlugin.hxx | 8 | ||||
-rw-r--r-- | src/DatabasePrint.cxx | 22 | ||||
-rw-r--r-- | src/DatabasePrint.hxx | 4 | ||||
-rw-r--r-- | src/DatabaseQueue.cxx | 11 | ||||
-rw-r--r-- | src/DatabaseSelection.hxx (renamed from src/db_selection.h) | 26 | ||||
-rw-r--r-- | src/Stats.cxx | 5 | ||||
-rw-r--r-- | src/db/SimpleDatabasePlugin.cxx | 4 | ||||
-rw-r--r-- | src/db/SimpleDatabasePlugin.hxx | 2 | ||||
-rw-r--r-- | test/DumpDatabase.cxx | 5 |
13 files changed, 39 insertions, 64 deletions
diff --git a/Makefile.am b/Makefile.am index 7b4f11d9a..8ce408879 100644 --- a/Makefile.am +++ b/Makefile.am @@ -262,7 +262,7 @@ src_mpd_SOURCES = \ src/db_visitor.h \ src/DatabasePlugin.hxx \ src/DatabaseVisitor.hxx \ - src/db_selection.h \ + src/DatabaseSelection.hxx \ src/exclude.c \ src/fd_util.c \ src/fifo_buffer.c src/fifo_buffer.h \ diff --git a/src/DatabaseCommands.cxx b/src/DatabaseCommands.cxx index f2f9c4885..40ba88052 100644 --- a/src/DatabaseCommands.cxx +++ b/src/DatabaseCommands.cxx @@ -22,13 +22,13 @@ #include "DatabaseQueue.hxx" #include "DatabasePlaylist.hxx" #include "DatabasePrint.hxx" +#include "DatabaseSelection.hxx" #include "CommandError.h" #include "client_internal.h" #include "tag.h" #include "uri.h" extern "C" { -#include "db_selection.h" #include "locate.h" #include "protocol/result.h" } @@ -47,8 +47,7 @@ handle_lsinfo2(struct client *client, int argc, char *argv[]) /* default is root directory */ uri = ""; - struct db_selection selection; - db_selection_init(&selection, uri, false); + const DatabaseSelection selection(uri, false); GError *error = NULL; if (!db_selection_print(client, selection, true, &error)) diff --git a/src/DatabaseGlue.cxx b/src/DatabaseGlue.cxx index a9b5e240a..68ab11ab3 100644 --- a/src/DatabaseGlue.cxx +++ b/src/DatabaseGlue.cxx @@ -24,7 +24,6 @@ extern "C" { #include "database.h" #include "db_error.h" #include "db_save.h" -#include "db_selection.h" #include "db_visitor.h" #include "stats.h" #include "conf.h" diff --git a/src/DatabasePlaylist.cxx b/src/DatabasePlaylist.cxx index eb59a5084..e8d569877 100644 --- a/src/DatabasePlaylist.cxx +++ b/src/DatabasePlaylist.cxx @@ -19,11 +19,11 @@ #include "config.h" #include "DatabasePlaylist.hxx" +#include "DatabaseSelection.hxx" extern "C" { #include "dbUtils.h" #include "locate.h" -#include "db_selection.h" #include "stored_playlist.h" } @@ -43,8 +43,7 @@ bool addAllInToStoredPlaylist(const char *uri_utf8, const char *playlist_path_utf8, GError **error_r) { - struct db_selection selection; - db_selection_init(&selection, uri_utf8, true); + const DatabaseSelection selection(uri_utf8, true); using namespace std::placeholders; const auto f = std::bind(AddSong, playlist_path_utf8, _1, _2); @@ -65,8 +64,7 @@ search_add_to_playlist(const char *uri, const char *playlist_path_utf8, const struct locate_item_list *criteria, GError **error_r) { - struct db_selection selection; - db_selection_init(&selection, uri, true); + const DatabaseSelection selection(uri, true); struct locate_item_list *new_list = locate_item_list_casefold(criteria); diff --git a/src/DatabasePlugin.hxx b/src/DatabasePlugin.hxx index c24896fce..31b2a1024 100644 --- a/src/DatabasePlugin.hxx +++ b/src/DatabasePlugin.hxx @@ -30,7 +30,7 @@ #include "gcc.h" struct config_param; -struct db_selection; +struct DatabaseSelection; struct db_visitor; class Database { @@ -64,13 +64,13 @@ public: /** * Visit the selected entities. */ - virtual bool Visit(const db_selection &selection, + virtual bool Visit(const DatabaseSelection &selection, VisitDirectory visit_directory, VisitSong visit_song, VisitPlaylist visit_playlist, GError **error_r) const = 0; - bool Visit(const db_selection &selection, + bool Visit(const DatabaseSelection &selection, VisitDirectory visit_directory, VisitSong visit_song, GError **error_r) const { @@ -78,7 +78,7 @@ public: VisitPlaylist(), error_r); } - bool Visit(const db_selection &selection, VisitSong visit_song, + bool Visit(const DatabaseSelection &selection, VisitSong visit_song, GError **error_r) const { return Visit(selection, VisitDirectory(), visit_song, error_r); } diff --git a/src/DatabasePrint.cxx b/src/DatabasePrint.cxx index b8f6d6f49..318bca8a4 100644 --- a/src/DatabasePrint.cxx +++ b/src/DatabasePrint.cxx @@ -19,9 +19,9 @@ #include "config.h" #include "DatabasePrint.hxx" +#include "DatabaseSelection.hxx" extern "C" { -#include "db_selection.h" #include "locate.h" #include "database.h" #include "client.h" @@ -125,7 +125,7 @@ PrintPlaylistFull(struct client *client, } bool -db_selection_print(struct client *client, const db_selection &selection, +db_selection_print(struct client *client, const DatabaseSelection &selection, bool full, GError **error_r) { using namespace std::placeholders; @@ -153,8 +153,7 @@ searchForSongsIn(struct client *client, const char *uri, const struct locate_item_list *criteria, GError **error_r) { - struct db_selection selection; - db_selection_init(&selection, uri, true); + const DatabaseSelection selection(uri, true); struct locate_item_list *new_list = locate_item_list_casefold(criteria); @@ -183,8 +182,7 @@ findSongsIn(struct client *client, const char *uri, const struct locate_item_list *criteria, GError **error_r) { - struct db_selection selection; - db_selection_init(&selection, uri, true); + const DatabaseSelection selection(uri, true); using namespace std::placeholders; const auto f = std::bind(MatchPrintSong, client, criteria, _1); @@ -219,8 +217,7 @@ searchStatsForSongsIn(struct client *client, const char *name, const struct locate_item_list *criteria, GError **error_r) { - struct db_selection selection; - db_selection_init(&selection, name, true); + const DatabaseSelection selection(name, true); SearchStats stats; stats.numberOfSongs = 0; @@ -239,8 +236,7 @@ searchStatsForSongsIn(struct client *client, const char *name, bool printAllIn(struct client *client, const char *uri_utf8, GError **error_r) { - struct db_selection selection; - db_selection_init(&selection, uri_utf8, true); + const DatabaseSelection selection(uri_utf8, true); return db_selection_print(client, selection, false, error_r); } @@ -248,8 +244,7 @@ bool printInfoForAllIn(struct client *client, const char *uri_utf8, GError **error_r) { - struct db_selection selection; - db_selection_init(&selection, uri_utf8, true); + const DatabaseSelection selection(uri_utf8, true); return db_selection_print(client, selection, true, error_r); } @@ -305,8 +300,7 @@ listAllUniqueTags(struct client *client, int type, const struct locate_item_list *criteria, GError **error_r) { - struct db_selection selection; - db_selection_init(&selection, "", true); + const DatabaseSelection selection("", true); StringSet set; diff --git a/src/DatabasePrint.hxx b/src/DatabasePrint.hxx index 65e0c988c..b06d77165 100644 --- a/src/DatabasePrint.hxx +++ b/src/DatabasePrint.hxx @@ -27,12 +27,12 @@ struct client; struct locate_item_list; -struct db_selection; +struct DatabaseSelection; struct db_visitor; gcc_nonnull(1) bool -db_selection_print(struct client *client, const db_selection &selection, +db_selection_print(struct client *client, const DatabaseSelection &selection, bool full, GError **error_r); gcc_nonnull(1,2) diff --git a/src/DatabaseQueue.cxx b/src/DatabaseQueue.cxx index 1c24e0aad..e9a47a761 100644 --- a/src/DatabaseQueue.cxx +++ b/src/DatabaseQueue.cxx @@ -19,11 +19,11 @@ #include "config.h" #include "DatabaseQueue.hxx" +#include "DatabaseSelection.hxx" extern "C" { #include "dbUtils.h" #include "locate.h" -#include "db_selection.h" #include "playlist.h" } @@ -49,8 +49,7 @@ AddToQueue(struct player_control *pc, song &song, GError **error_r) bool addAllIn(struct player_control *pc, const char *uri, GError **error_r) { - struct db_selection selection; - db_selection_init(&selection, uri, true); + const DatabaseSelection selection(uri, true); using namespace std::placeholders; const auto f = std::bind(AddToQueue, pc, _1, _2); @@ -70,8 +69,7 @@ bool findAddIn(struct player_control *pc, const char *uri, const struct locate_item_list *criteria, GError **error_r) { - struct db_selection selection; - db_selection_init(&selection, uri, true); + const DatabaseSelection selection(uri, true); using namespace std::placeholders; const auto f = std::bind(MatchAddSong, pc, criteria, _1, _2); @@ -92,8 +90,7 @@ search_add_songs(struct player_control *pc, const char *uri, const struct locate_item_list *criteria, GError **error_r) { - struct db_selection selection; - db_selection_init(&selection, uri, true); + const DatabaseSelection selection(uri, true); struct locate_item_list *new_list = locate_item_list_casefold(criteria); diff --git a/src/db_selection.h b/src/DatabaseSelection.hxx index 002acdc73..3e5232288 100644 --- a/src/db_selection.h +++ b/src/DatabaseSelection.hxx @@ -17,18 +17,15 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#ifndef MPD_DB_SELECTION_H -#define MPD_DB_SELECTION_H +#ifndef MPD_DATABASE_SELECTION_HXX +#define MPD_DATABASE_SELECTION_HXX #include "gcc.h" #include <assert.h> #include <stddef.h> -struct directory; -struct song; - -struct db_selection { +struct DatabaseSelection { /** * The base URI of the search (UTF-8). Must not begin or end * with a slash. NULL or an empty string searches the whole @@ -40,18 +37,11 @@ struct db_selection { * Recursively search all sub directories? */ bool recursive; -}; -gcc_nonnull(1,2) -static inline void -db_selection_init(struct db_selection *selection, - const char *uri, bool recursive) -{ - assert(selection != NULL); - assert(uri != NULL); - - selection->uri = uri; - selection->recursive = recursive; -} + DatabaseSelection(const char *_uri, bool _recursive) + :uri(_uri), recursive(_recursive) { + assert(uri != NULL); + } +}; #endif diff --git a/src/Stats.cxx b/src/Stats.cxx index 07e62498b..5b5008cee 100644 --- a/src/Stats.cxx +++ b/src/Stats.cxx @@ -22,7 +22,6 @@ extern "C" { #include "stats.h" #include "database.h" -#include "db_selection.h" #include "tag.h" #include "song.h" #include "client.h" @@ -31,6 +30,7 @@ extern "C" { #include "client_internal.h" } +#include "DatabaseSelection.hxx" #include "DatabaseGlue.hxx" #include "DatabasePlugin.hxx" @@ -99,8 +99,7 @@ void stats_update(void) stats.song_duration = 0; stats.artist_count = 0; - struct db_selection selection; - db_selection_init(&selection, "", true); + const DatabaseSelection selection("", true); StringSet artists, albums; using namespace std::placeholders; diff --git a/src/db/SimpleDatabasePlugin.cxx b/src/db/SimpleDatabasePlugin.cxx index 0f0bedf54..e1cf0167b 100644 --- a/src/db/SimpleDatabasePlugin.cxx +++ b/src/db/SimpleDatabasePlugin.cxx @@ -19,10 +19,10 @@ #include "config.h" #include "SimpleDatabasePlugin.hxx" +#include "DatabaseSelection.hxx" extern "C" { #include "db_error.h" -#include "db_selection.h" #include "db_visitor.h" #include "db_save.h" #include "db_lock.h" @@ -237,7 +237,7 @@ SimpleDatabase::LookupDirectory(const char *uri) const } bool -SimpleDatabase::Visit(const db_selection &selection, +SimpleDatabase::Visit(const DatabaseSelection &selection, VisitDirectory visit_directory, VisitSong visit_song, VisitPlaylist visit_playlist, diff --git a/src/db/SimpleDatabasePlugin.hxx b/src/db/SimpleDatabasePlugin.hxx index d37738dd9..1e990de13 100644 --- a/src/db/SimpleDatabasePlugin.hxx +++ b/src/db/SimpleDatabasePlugin.hxx @@ -60,7 +60,7 @@ public: virtual void Close() override; virtual struct song *GetSong(const char *uri_utf8, GError **error_r) const override; - virtual bool Visit(const db_selection &selection, + virtual bool Visit(const DatabaseSelection &selection, VisitDirectory visit_directory, VisitSong visit_song, VisitPlaylist visit_playlist, diff --git a/test/DumpDatabase.cxx b/test/DumpDatabase.cxx index 2e629172a..b0a9c933c 100644 --- a/test/DumpDatabase.cxx +++ b/test/DumpDatabase.cxx @@ -20,7 +20,7 @@ #include "config.h" #include "DatabaseRegistry.hxx" #include "DatabasePlugin.hxx" -#include "db_selection.h" +#include "DatabaseSelection.hxx" #include "directory.h" #include "song.h" #include "playlist_vector.h" @@ -130,8 +130,7 @@ main(int argc, char **argv) return EXIT_FAILURE; } - db_selection selection; - db_selection_init(&selection, "", true); + const DatabaseSelection selection("", true); if (!db->Visit(selection, DumpDirectory, DumpSong, DumpPlaylist, &error)) { |