From ff58207034e63e9f87402f7e3c78080638cb1e2f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 7 Aug 2012 23:06:41 +0200 Subject: db_selection: rename to DatabaseSelection --- src/DatabaseCommands.cxx | 5 ++-- src/DatabaseGlue.cxx | 1 - src/DatabasePlaylist.cxx | 8 +++--- src/DatabasePlugin.hxx | 8 +++--- src/DatabasePrint.cxx | 22 ++++++---------- src/DatabasePrint.hxx | 4 +-- src/DatabaseQueue.cxx | 11 +++----- src/DatabaseSelection.hxx | 47 +++++++++++++++++++++++++++++++++ src/Stats.cxx | 5 ++-- src/db/SimpleDatabasePlugin.cxx | 4 +-- src/db/SimpleDatabasePlugin.hxx | 2 +- src/db_selection.h | 57 ----------------------------------------- 12 files changed, 75 insertions(+), 99 deletions(-) create mode 100644 src/DatabaseSelection.hxx delete mode 100644 src/db_selection.h (limited to 'src') 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/DatabaseSelection.hxx b/src/DatabaseSelection.hxx new file mode 100644 index 000000000..3e5232288 --- /dev/null +++ b/src/DatabaseSelection.hxx @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2003-2011 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_DATABASE_SELECTION_HXX +#define MPD_DATABASE_SELECTION_HXX + +#include "gcc.h" + +#include +#include + +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 + * database. + */ + const char *uri; + + /** + * Recursively search all sub directories? + */ + bool 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/src/db_selection.h b/src/db_selection.h deleted file mode 100644 index 002acdc73..000000000 --- a/src/db_selection.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (C) 2003-2011 The Music Player Daemon Project - * http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef MPD_DB_SELECTION_H -#define MPD_DB_SELECTION_H - -#include "gcc.h" - -#include -#include - -struct directory; -struct song; - -struct db_selection { - /** - * The base URI of the search (UTF-8). Must not begin or end - * with a slash. NULL or an empty string searches the whole - * database. - */ - const char *uri; - - /** - * 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; -} - -#endif -- cgit v1.2.3