diff options
author | Max Kellermann <max@duempel.org> | 2015-06-25 23:14:40 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-06-25 23:15:36 +0200 |
commit | eb86fdfbea6254d6966e59d80b43af3e5152fe3f (patch) | |
tree | c41d5e1a2b3750ec2c5b34155fbfb6bbdeb0dc5d | |
parent | c7712e2ef0232a39786075dbf6683120cfe5cc0a (diff) | |
download | mpd-eb86fdfbea6254d6966e59d80b43af3e5152fe3f.tar.gz mpd-eb86fdfbea6254d6966e59d80b43af3e5152fe3f.tar.xz mpd-eb86fdfbea6254d6966e59d80b43af3e5152fe3f.zip |
SongFilter: return "const char *" instead of std::string
Diffstat (limited to '')
-rw-r--r-- | src/SongFilter.cxx | 4 | ||||
-rw-r--r-- | src/SongFilter.hxx | 10 | ||||
-rw-r--r-- | src/db/Selection.cxx | 7 | ||||
-rw-r--r-- | src/db/plugins/ProxyDatabasePlugin.cxx | 8 | ||||
-rw-r--r-- | src/db/plugins/upnp/UpnpDatabasePlugin.cxx | 4 |
5 files changed, 18 insertions, 15 deletions
diff --git a/src/SongFilter.cxx b/src/SongFilter.cxx index d979267ef..5e24b143a 100644 --- a/src/SongFilter.cxx +++ b/src/SongFilter.cxx @@ -300,12 +300,12 @@ SongFilter::HasOtherThanBase() const return false; } -std::string +const char * SongFilter::GetBase() const { for (const auto &i : items) if (i.GetTag() == LOCATE_TAG_BASE_TYPE) return i.GetValue(); - return std::string(); + return nullptr; } diff --git a/src/SongFilter.hxx b/src/SongFilter.hxx index 8801f35ea..ba5433df8 100644 --- a/src/SongFilter.hxx +++ b/src/SongFilter.hxx @@ -76,8 +76,8 @@ public: return fold_case; } - const std::string &GetValue() const { - return value; + const char *GetValue() const { + return value.c_str(); } gcc_pure gcc_nonnull(2) @@ -149,11 +149,11 @@ public: bool HasOtherThanBase() const; /** - * Returns the "base" specification (if there is one) or an - * empty string. + * Returns the "base" specification (if there is one) or + * nullptr. */ gcc_pure - std::string GetBase() const; + const char *GetBase() const; }; /** diff --git a/src/db/Selection.cxx b/src/db/Selection.cxx index 4a4016485..4c941823a 100644 --- a/src/db/Selection.cxx +++ b/src/db/Selection.cxx @@ -26,8 +26,11 @@ DatabaseSelection::DatabaseSelection(const char *_uri, bool _recursive, { /* optimization: if the caller didn't specify a base URI, pick the one from SongFilter */ - if (uri.empty() && filter != nullptr) - uri = filter->GetBase(); + if (uri.empty() && filter != nullptr) { + auto base = filter->GetBase(); + if (base != nullptr) + uri = base; + } } bool diff --git a/src/db/plugins/ProxyDatabasePlugin.cxx b/src/db/plugins/ProxyDatabasePlugin.cxx index 67c651e83..78ad7f603 100644 --- a/src/db/plugins/ProxyDatabasePlugin.cxx +++ b/src/db/plugins/ProxyDatabasePlugin.cxx @@ -263,18 +263,18 @@ SendConstraints(mpd_connection *connection, const SongFilter::Item &item) return mpd_search_add_base_constraint(connection, MPD_OPERATOR_DEFAULT, - item.GetValue().c_str()); + item.GetValue()); #endif case LOCATE_TAG_FILE_TYPE: return mpd_search_add_uri_constraint(connection, MPD_OPERATOR_DEFAULT, - item.GetValue().c_str()); + item.GetValue()); case LOCATE_TAG_ANY_TYPE: return mpd_search_add_any_tag_constraint(connection, MPD_OPERATOR_DEFAULT, - item.GetValue().c_str()); + item.GetValue()); default: tag = Convert(TagType(item.GetTag())); @@ -284,7 +284,7 @@ SendConstraints(mpd_connection *connection, const SongFilter::Item &item) return mpd_search_add_tag_constraint(connection, MPD_OPERATOR_DEFAULT, tag, - item.GetValue().c_str()); + item.GetValue()); } } diff --git a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx index 9d2d00eb6..035c310f9 100644 --- a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx +++ b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx @@ -303,7 +303,7 @@ UpnpDatabase::SearchSongs(const ContentDirectoryService &server, } else { cond += " = "; } - dquote(cond, item.GetValue().c_str()); + dquote(cond, item.GetValue()); } cond += ')'; } @@ -339,7 +339,7 @@ UpnpDatabase::SearchSongs(const ContentDirectoryService &server, } else { cond += " = "; } - dquote(cond, item.GetValue().c_str()); + dquote(cond, item.GetValue()); } } |