SongFilter: return "const char *" instead of std::string

This commit is contained in:
Max Kellermann 2015-06-25 23:14:40 +02:00
parent c7712e2ef0
commit eb86fdfbea
5 changed files with 18 additions and 15 deletions

View File

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

View File

@ -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;
};
/**

View File

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

View File

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

View File

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