SongFilter: return "const char *" instead of std::string
This commit is contained in:
parent
c7712e2ef0
commit
eb86fdfbea
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user