From 2d5413fc3ba2dc77189bed3dfbbc65ad4243e477 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 29 Oct 2013 20:33:20 +0100 Subject: [PATCH] DatabaseSelection: use std::string --- src/DatabaseSelection.hxx | 8 +++----- src/db/ProxyDatabasePlugin.cxx | 2 +- src/db/SimpleDatabasePlugin.cxx | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/DatabaseSelection.hxx b/src/DatabaseSelection.hxx index 8ef5b6d9c..67a88b945 100644 --- a/src/DatabaseSelection.hxx +++ b/src/DatabaseSelection.hxx @@ -22,7 +22,7 @@ #include "Compiler.h" -#include +#include class SongFilter; struct Song; @@ -30,10 +30,9 @@ struct Song; struct DatabaseSelection { /** * The base URI of the search (UTF-8). Must not begin or end - * with a slash. nullptr or an empty string searches the whole - * database. + * with a slash. An empty string searches the whole database. */ - const char *uri; + std::string uri; /** * Recursively search all sub directories? @@ -45,7 +44,6 @@ struct DatabaseSelection { DatabaseSelection(const char *_uri, bool _recursive, const SongFilter *_filter=nullptr) :uri(_uri), recursive(_recursive), filter(_filter) { - assert(uri != nullptr); } gcc_pure diff --git a/src/db/ProxyDatabasePlugin.cxx b/src/db/ProxyDatabasePlugin.cxx index 3293c26b5..e859e11eb 100644 --- a/src/db/ProxyDatabasePlugin.cxx +++ b/src/db/ProxyDatabasePlugin.cxx @@ -398,7 +398,7 @@ ProxyDatabase::Visit(const DatabaseSelection &selection, // TODO: match // TODO: auto-reconnect - return ::Visit(connection, selection.uri, selection.recursive, + return ::Visit(connection, selection.uri.c_str(), selection.recursive, visit_directory, visit_song, visit_playlist, error); } diff --git a/src/db/SimpleDatabasePlugin.cxx b/src/db/SimpleDatabasePlugin.cxx index 55c9d47a8..4a6d203b3 100644 --- a/src/db/SimpleDatabasePlugin.cxx +++ b/src/db/SimpleDatabasePlugin.cxx @@ -239,10 +239,10 @@ SimpleDatabase::Visit(const DatabaseSelection &selection, { ScopeDatabaseLock protect; - const Directory *directory = root->LookupDirectory(selection.uri); + const Directory *directory = root->LookupDirectory(selection.uri.c_str()); if (directory == nullptr) { if (visit_song) { - Song *song = root->LookupSong(selection.uri); + Song *song = root->LookupSong(selection.uri.c_str()); if (song != nullptr) return !selection.Match(*song) || visit_song(*song, error);