db_selection: rename to DatabaseSelection

This commit is contained in:
Max Kellermann 2012-08-07 23:06:41 +02:00
parent b3d76b7e5c
commit ff58207034
13 changed files with 39 additions and 64 deletions

View File

@ -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 \

View File

@ -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))

View File

@ -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"

View File

@ -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);

View File

@ -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);
}

View File

@ -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;

View File

@ -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)

View File

@ -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);

View File

@ -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;
DatabaseSelection(const char *_uri, bool _recursive)
:uri(_uri), recursive(_recursive) {
assert(uri != NULL);
}
};
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

View File

@ -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;

View File

@ -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,

View File

@ -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,

View File

@ -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)) {