filter/chain: pass std::string_view to filter_chain_append()
This commit is contained in:
parent
eeaec99c59
commit
f2b9785a67
|
@ -27,10 +27,13 @@
|
|||
|
||||
static void
|
||||
filter_chain_append_new(PreparedFilter &chain, FilterFactory &factory,
|
||||
const char *template_name)
|
||||
std::string_view template_name)
|
||||
{
|
||||
filter_chain_append(chain, template_name,
|
||||
factory.MakeFilter(template_name));
|
||||
/* unfortunately, MakeFilter() wants a
|
||||
null-terminated string, so we need to
|
||||
copy it here */
|
||||
factory.MakeFilter(std::string(template_name).c_str()));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -42,7 +45,6 @@ filter_chain_parse(PreparedFilter &chain,
|
|||
if (i.empty())
|
||||
continue;
|
||||
|
||||
const std::string name(i);
|
||||
filter_chain_append_new(chain, factory, name.c_str());
|
||||
filter_chain_append_new(chain, factory, i);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ class PreparedChainFilter final : public PreparedFilter {
|
|||
const std::string name;
|
||||
std::unique_ptr<PreparedFilter> filter;
|
||||
|
||||
Child(const char *_name,
|
||||
Child(std::string_view _name,
|
||||
std::unique_ptr<PreparedFilter> _filter)
|
||||
:name(_name), filter(std::move(_filter)) {}
|
||||
|
||||
|
@ -89,7 +89,7 @@ class PreparedChainFilter final : public PreparedFilter {
|
|||
std::list<Child> children;
|
||||
|
||||
public:
|
||||
void Append(const char *name,
|
||||
void Append(std::string_view name,
|
||||
std::unique_ptr<PreparedFilter> filter) noexcept {
|
||||
children.emplace_back(name, std::move(filter));
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ filter_chain_new() noexcept
|
|||
}
|
||||
|
||||
void
|
||||
filter_chain_append(PreparedFilter &_chain, const char *name,
|
||||
filter_chain_append(PreparedFilter &_chain, std::string_view name,
|
||||
std::unique_ptr<PreparedFilter> filter) noexcept
|
||||
{
|
||||
auto &chain = (PreparedChainFilter &)_chain;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#define MPD_FILTER_CHAIN_HXX
|
||||
|
||||
#include <memory>
|
||||
#include <string_view>
|
||||
|
||||
class PreparedFilter;
|
||||
|
||||
|
@ -45,7 +46,7 @@ filter_chain_new() noexcept;
|
|||
* @param filter the filter to be appended to #chain
|
||||
*/
|
||||
void
|
||||
filter_chain_append(PreparedFilter &chain, const char *name,
|
||||
filter_chain_append(PreparedFilter &chain, std::string_view name,
|
||||
std::unique_ptr<PreparedFilter> filter) noexcept;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue