lib/upnp/Util: pass single delimiter character to stringToTokens()

This commit is contained in:
Max Kellermann 2017-01-23 19:34:55 +01:00
parent d3013d4f8c
commit 44dd9af276
3 changed files with 6 additions and 7 deletions

View File

@ -180,7 +180,7 @@ UpnpDatabase::ReturnSong(const LightSong *_song) const
const LightSong *
UpnpDatabase::GetSong(const char *uri) const
{
auto vpath = stringToTokens(uri, "/");
auto vpath = stringToTokens(uri, '/');
if (vpath.size() < 2)
throw DatabaseError(DatabaseErrorCode::NOT_FOUND,
"No such song");
@ -577,7 +577,7 @@ UpnpDatabase::Visit(const DatabaseSelection &selection,
VisitSong visit_song,
VisitPlaylist visit_playlist) const
{
auto vpath = stringToTokens(selection.uri, "/");
auto vpath = stringToTokens(selection.uri, '/');
if (vpath.empty()) {
for (const auto &server : discovery->GetDirectories()) {
if (visit_directory) {

View File

@ -71,11 +71,11 @@ path_getfather(const std::string &s)
std::list<std::string>
stringToTokens(const std::string &str,
const char *delims)
const char delim)
{
std::list<std::string> tokens;
std::string::size_type startPos = str.find_first_not_of(delims, 0);
std::string::size_type startPos = str.find_first_not_of(delim, 0);
// Skip initial delims, return empty if this eats all.
if (startPos == std::string::npos)
@ -83,7 +83,7 @@ stringToTokens(const std::string &str,
while (startPos < str.size()) {
// Find next delimiter or end of string (end of token)
auto pos = str.find_first_of(delims, startPos);
auto pos = str.find_first_of(delim, startPos);
// Add token to the vector and adjust start
if (pos == std::string::npos) {

View File

@ -33,8 +33,7 @@ path_getfather(const std::string &s);
gcc_pure
std::list<std::string>
stringToTokens(const std::string &str,
const char *delims = "/");
stringToTokens(const std::string &str, char delim);
template <class T>
bool