db_selection: rename to DatabaseSelection
This commit is contained in:
parent
b3d76b7e5c
commit
ff58207034
@ -262,7 +262,7 @@ src_mpd_SOURCES = \
|
|||||||
src/db_visitor.h \
|
src/db_visitor.h \
|
||||||
src/DatabasePlugin.hxx \
|
src/DatabasePlugin.hxx \
|
||||||
src/DatabaseVisitor.hxx \
|
src/DatabaseVisitor.hxx \
|
||||||
src/db_selection.h \
|
src/DatabaseSelection.hxx \
|
||||||
src/exclude.c \
|
src/exclude.c \
|
||||||
src/fd_util.c \
|
src/fd_util.c \
|
||||||
src/fifo_buffer.c src/fifo_buffer.h \
|
src/fifo_buffer.c src/fifo_buffer.h \
|
||||||
|
@ -22,13 +22,13 @@
|
|||||||
#include "DatabaseQueue.hxx"
|
#include "DatabaseQueue.hxx"
|
||||||
#include "DatabasePlaylist.hxx"
|
#include "DatabasePlaylist.hxx"
|
||||||
#include "DatabasePrint.hxx"
|
#include "DatabasePrint.hxx"
|
||||||
|
#include "DatabaseSelection.hxx"
|
||||||
#include "CommandError.h"
|
#include "CommandError.h"
|
||||||
#include "client_internal.h"
|
#include "client_internal.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "uri.h"
|
#include "uri.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "db_selection.h"
|
|
||||||
#include "locate.h"
|
#include "locate.h"
|
||||||
#include "protocol/result.h"
|
#include "protocol/result.h"
|
||||||
}
|
}
|
||||||
@ -47,8 +47,7 @@ handle_lsinfo2(struct client *client, int argc, char *argv[])
|
|||||||
/* default is root directory */
|
/* default is root directory */
|
||||||
uri = "";
|
uri = "";
|
||||||
|
|
||||||
struct db_selection selection;
|
const DatabaseSelection selection(uri, false);
|
||||||
db_selection_init(&selection, uri, false);
|
|
||||||
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
if (!db_selection_print(client, selection, true, &error))
|
if (!db_selection_print(client, selection, true, &error))
|
||||||
|
@ -24,7 +24,6 @@ extern "C" {
|
|||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "db_error.h"
|
#include "db_error.h"
|
||||||
#include "db_save.h"
|
#include "db_save.h"
|
||||||
#include "db_selection.h"
|
|
||||||
#include "db_visitor.h"
|
#include "db_visitor.h"
|
||||||
#include "stats.h"
|
#include "stats.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
@ -19,11 +19,11 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "DatabasePlaylist.hxx"
|
#include "DatabasePlaylist.hxx"
|
||||||
|
#include "DatabaseSelection.hxx"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "dbUtils.h"
|
#include "dbUtils.h"
|
||||||
#include "locate.h"
|
#include "locate.h"
|
||||||
#include "db_selection.h"
|
|
||||||
#include "stored_playlist.h"
|
#include "stored_playlist.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,8 +43,7 @@ bool
|
|||||||
addAllInToStoredPlaylist(const char *uri_utf8, const char *playlist_path_utf8,
|
addAllInToStoredPlaylist(const char *uri_utf8, const char *playlist_path_utf8,
|
||||||
GError **error_r)
|
GError **error_r)
|
||||||
{
|
{
|
||||||
struct db_selection selection;
|
const DatabaseSelection selection(uri_utf8, true);
|
||||||
db_selection_init(&selection, uri_utf8, true);
|
|
||||||
|
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
const auto f = std::bind(AddSong, playlist_path_utf8, _1, _2);
|
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,
|
const struct locate_item_list *criteria,
|
||||||
GError **error_r)
|
GError **error_r)
|
||||||
{
|
{
|
||||||
struct db_selection selection;
|
const DatabaseSelection selection(uri, true);
|
||||||
db_selection_init(&selection, uri, true);
|
|
||||||
|
|
||||||
struct locate_item_list *new_list
|
struct locate_item_list *new_list
|
||||||
= locate_item_list_casefold(criteria);
|
= locate_item_list_casefold(criteria);
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include "gcc.h"
|
#include "gcc.h"
|
||||||
|
|
||||||
struct config_param;
|
struct config_param;
|
||||||
struct db_selection;
|
struct DatabaseSelection;
|
||||||
struct db_visitor;
|
struct db_visitor;
|
||||||
|
|
||||||
class Database {
|
class Database {
|
||||||
@ -64,13 +64,13 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Visit the selected entities.
|
* Visit the selected entities.
|
||||||
*/
|
*/
|
||||||
virtual bool Visit(const db_selection &selection,
|
virtual bool Visit(const DatabaseSelection &selection,
|
||||||
VisitDirectory visit_directory,
|
VisitDirectory visit_directory,
|
||||||
VisitSong visit_song,
|
VisitSong visit_song,
|
||||||
VisitPlaylist visit_playlist,
|
VisitPlaylist visit_playlist,
|
||||||
GError **error_r) const = 0;
|
GError **error_r) const = 0;
|
||||||
|
|
||||||
bool Visit(const db_selection &selection,
|
bool Visit(const DatabaseSelection &selection,
|
||||||
VisitDirectory visit_directory,
|
VisitDirectory visit_directory,
|
||||||
VisitSong visit_song,
|
VisitSong visit_song,
|
||||||
GError **error_r) const {
|
GError **error_r) const {
|
||||||
@ -78,7 +78,7 @@ public:
|
|||||||
VisitPlaylist(), error_r);
|
VisitPlaylist(), error_r);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Visit(const db_selection &selection, VisitSong visit_song,
|
bool Visit(const DatabaseSelection &selection, VisitSong visit_song,
|
||||||
GError **error_r) const {
|
GError **error_r) const {
|
||||||
return Visit(selection, VisitDirectory(), visit_song, error_r);
|
return Visit(selection, VisitDirectory(), visit_song, error_r);
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "DatabasePrint.hxx"
|
#include "DatabasePrint.hxx"
|
||||||
|
#include "DatabaseSelection.hxx"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "db_selection.h"
|
|
||||||
#include "locate.h"
|
#include "locate.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
@ -125,7 +125,7 @@ PrintPlaylistFull(struct client *client,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
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)
|
bool full, GError **error_r)
|
||||||
{
|
{
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
@ -153,8 +153,7 @@ searchForSongsIn(struct client *client, const char *uri,
|
|||||||
const struct locate_item_list *criteria,
|
const struct locate_item_list *criteria,
|
||||||
GError **error_r)
|
GError **error_r)
|
||||||
{
|
{
|
||||||
struct db_selection selection;
|
const DatabaseSelection selection(uri, true);
|
||||||
db_selection_init(&selection, uri, true);
|
|
||||||
|
|
||||||
struct locate_item_list *new_list
|
struct locate_item_list *new_list
|
||||||
= locate_item_list_casefold(criteria);
|
= locate_item_list_casefold(criteria);
|
||||||
@ -183,8 +182,7 @@ findSongsIn(struct client *client, const char *uri,
|
|||||||
const struct locate_item_list *criteria,
|
const struct locate_item_list *criteria,
|
||||||
GError **error_r)
|
GError **error_r)
|
||||||
{
|
{
|
||||||
struct db_selection selection;
|
const DatabaseSelection selection(uri, true);
|
||||||
db_selection_init(&selection, uri, true);
|
|
||||||
|
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
const auto f = std::bind(MatchPrintSong, client, criteria, _1);
|
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,
|
const struct locate_item_list *criteria,
|
||||||
GError **error_r)
|
GError **error_r)
|
||||||
{
|
{
|
||||||
struct db_selection selection;
|
const DatabaseSelection selection(name, true);
|
||||||
db_selection_init(&selection, name, true);
|
|
||||||
|
|
||||||
SearchStats stats;
|
SearchStats stats;
|
||||||
stats.numberOfSongs = 0;
|
stats.numberOfSongs = 0;
|
||||||
@ -239,8 +236,7 @@ searchStatsForSongsIn(struct client *client, const char *name,
|
|||||||
bool
|
bool
|
||||||
printAllIn(struct client *client, const char *uri_utf8, GError **error_r)
|
printAllIn(struct client *client, const char *uri_utf8, GError **error_r)
|
||||||
{
|
{
|
||||||
struct db_selection selection;
|
const DatabaseSelection selection(uri_utf8, true);
|
||||||
db_selection_init(&selection, uri_utf8, true);
|
|
||||||
return db_selection_print(client, selection, false, error_r);
|
return db_selection_print(client, selection, false, error_r);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,8 +244,7 @@ bool
|
|||||||
printInfoForAllIn(struct client *client, const char *uri_utf8,
|
printInfoForAllIn(struct client *client, const char *uri_utf8,
|
||||||
GError **error_r)
|
GError **error_r)
|
||||||
{
|
{
|
||||||
struct db_selection selection;
|
const DatabaseSelection selection(uri_utf8, true);
|
||||||
db_selection_init(&selection, uri_utf8, true);
|
|
||||||
return db_selection_print(client, selection, true, error_r);
|
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,
|
const struct locate_item_list *criteria,
|
||||||
GError **error_r)
|
GError **error_r)
|
||||||
{
|
{
|
||||||
struct db_selection selection;
|
const DatabaseSelection selection("", true);
|
||||||
db_selection_init(&selection, "", true);
|
|
||||||
|
|
||||||
StringSet set;
|
StringSet set;
|
||||||
|
|
||||||
|
@ -27,12 +27,12 @@
|
|||||||
|
|
||||||
struct client;
|
struct client;
|
||||||
struct locate_item_list;
|
struct locate_item_list;
|
||||||
struct db_selection;
|
struct DatabaseSelection;
|
||||||
struct db_visitor;
|
struct db_visitor;
|
||||||
|
|
||||||
gcc_nonnull(1)
|
gcc_nonnull(1)
|
||||||
bool
|
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);
|
bool full, GError **error_r);
|
||||||
|
|
||||||
gcc_nonnull(1,2)
|
gcc_nonnull(1,2)
|
||||||
|
@ -19,11 +19,11 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "DatabaseQueue.hxx"
|
#include "DatabaseQueue.hxx"
|
||||||
|
#include "DatabaseSelection.hxx"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "dbUtils.h"
|
#include "dbUtils.h"
|
||||||
#include "locate.h"
|
#include "locate.h"
|
||||||
#include "db_selection.h"
|
|
||||||
#include "playlist.h"
|
#include "playlist.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,8 +49,7 @@ AddToQueue(struct player_control *pc, song &song, GError **error_r)
|
|||||||
bool
|
bool
|
||||||
addAllIn(struct player_control *pc, const char *uri, GError **error_r)
|
addAllIn(struct player_control *pc, const char *uri, GError **error_r)
|
||||||
{
|
{
|
||||||
struct db_selection selection;
|
const DatabaseSelection selection(uri, true);
|
||||||
db_selection_init(&selection, uri, true);
|
|
||||||
|
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
const auto f = std::bind(AddToQueue, pc, _1, _2);
|
const auto f = std::bind(AddToQueue, pc, _1, _2);
|
||||||
@ -70,8 +69,7 @@ bool
|
|||||||
findAddIn(struct player_control *pc, const char *uri,
|
findAddIn(struct player_control *pc, const char *uri,
|
||||||
const struct locate_item_list *criteria, GError **error_r)
|
const struct locate_item_list *criteria, GError **error_r)
|
||||||
{
|
{
|
||||||
struct db_selection selection;
|
const DatabaseSelection selection(uri, true);
|
||||||
db_selection_init(&selection, uri, true);
|
|
||||||
|
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
const auto f = std::bind(MatchAddSong, pc, criteria, _1, _2);
|
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,
|
const struct locate_item_list *criteria,
|
||||||
GError **error_r)
|
GError **error_r)
|
||||||
{
|
{
|
||||||
struct db_selection selection;
|
const DatabaseSelection selection(uri, true);
|
||||||
db_selection_init(&selection, uri, true);
|
|
||||||
|
|
||||||
struct locate_item_list *new_list =
|
struct locate_item_list *new_list =
|
||||||
locate_item_list_casefold(criteria);
|
locate_item_list_casefold(criteria);
|
||||||
|
@ -17,18 +17,15 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MPD_DB_SELECTION_H
|
#ifndef MPD_DATABASE_SELECTION_HXX
|
||||||
#define MPD_DB_SELECTION_H
|
#define MPD_DATABASE_SELECTION_HXX
|
||||||
|
|
||||||
#include "gcc.h"
|
#include "gcc.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
struct directory;
|
struct DatabaseSelection {
|
||||||
struct song;
|
|
||||||
|
|
||||||
struct db_selection {
|
|
||||||
/**
|
/**
|
||||||
* The base URI of the search (UTF-8). Must not begin or end
|
* The base URI of the search (UTF-8). Must not begin or end
|
||||||
* with a slash. NULL or an empty string searches the whole
|
* with a slash. NULL or an empty string searches the whole
|
||||||
@ -40,18 +37,11 @@ struct db_selection {
|
|||||||
* Recursively search all sub directories?
|
* Recursively search all sub directories?
|
||||||
*/
|
*/
|
||||||
bool recursive;
|
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
|
#endif
|
@ -22,7 +22,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#include "stats.h"
|
#include "stats.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "db_selection.h"
|
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
#include "song.h"
|
#include "song.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
@ -31,6 +30,7 @@ extern "C" {
|
|||||||
#include "client_internal.h"
|
#include "client_internal.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "DatabaseSelection.hxx"
|
||||||
#include "DatabaseGlue.hxx"
|
#include "DatabaseGlue.hxx"
|
||||||
#include "DatabasePlugin.hxx"
|
#include "DatabasePlugin.hxx"
|
||||||
|
|
||||||
@ -99,8 +99,7 @@ void stats_update(void)
|
|||||||
stats.song_duration = 0;
|
stats.song_duration = 0;
|
||||||
stats.artist_count = 0;
|
stats.artist_count = 0;
|
||||||
|
|
||||||
struct db_selection selection;
|
const DatabaseSelection selection("", true);
|
||||||
db_selection_init(&selection, "", true);
|
|
||||||
|
|
||||||
StringSet artists, albums;
|
StringSet artists, albums;
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
|
@ -19,10 +19,10 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "SimpleDatabasePlugin.hxx"
|
#include "SimpleDatabasePlugin.hxx"
|
||||||
|
#include "DatabaseSelection.hxx"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "db_error.h"
|
#include "db_error.h"
|
||||||
#include "db_selection.h"
|
|
||||||
#include "db_visitor.h"
|
#include "db_visitor.h"
|
||||||
#include "db_save.h"
|
#include "db_save.h"
|
||||||
#include "db_lock.h"
|
#include "db_lock.h"
|
||||||
@ -237,7 +237,7 @@ SimpleDatabase::LookupDirectory(const char *uri) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
SimpleDatabase::Visit(const db_selection &selection,
|
SimpleDatabase::Visit(const DatabaseSelection &selection,
|
||||||
VisitDirectory visit_directory,
|
VisitDirectory visit_directory,
|
||||||
VisitSong visit_song,
|
VisitSong visit_song,
|
||||||
VisitPlaylist visit_playlist,
|
VisitPlaylist visit_playlist,
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
virtual void Close() override;
|
virtual void Close() override;
|
||||||
virtual struct song *GetSong(const char *uri_utf8,
|
virtual struct song *GetSong(const char *uri_utf8,
|
||||||
GError **error_r) const override;
|
GError **error_r) const override;
|
||||||
virtual bool Visit(const db_selection &selection,
|
virtual bool Visit(const DatabaseSelection &selection,
|
||||||
VisitDirectory visit_directory,
|
VisitDirectory visit_directory,
|
||||||
VisitSong visit_song,
|
VisitSong visit_song,
|
||||||
VisitPlaylist visit_playlist,
|
VisitPlaylist visit_playlist,
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "DatabaseRegistry.hxx"
|
#include "DatabaseRegistry.hxx"
|
||||||
#include "DatabasePlugin.hxx"
|
#include "DatabasePlugin.hxx"
|
||||||
#include "db_selection.h"
|
#include "DatabaseSelection.hxx"
|
||||||
#include "directory.h"
|
#include "directory.h"
|
||||||
#include "song.h"
|
#include "song.h"
|
||||||
#include "playlist_vector.h"
|
#include "playlist_vector.h"
|
||||||
@ -130,8 +130,7 @@ main(int argc, char **argv)
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
db_selection selection;
|
const DatabaseSelection selection("", true);
|
||||||
db_selection_init(&selection, "", true);
|
|
||||||
|
|
||||||
if (!db->Visit(selection, DumpDirectory, DumpSong, DumpPlaylist,
|
if (!db->Visit(selection, DumpDirectory, DumpSong, DumpPlaylist,
|
||||||
&error)) {
|
&error)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user