summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2020-04-03 16:38:55 +0200
committerMax Kellermann <max@musicpd.org>2020-04-03 16:47:45 +0200
commit870151214d4a1e0fff5b4a7537a0ae070dac30a5 (patch)
tree85ab9000b6299017b7c099b4a2f92595bf2441cd /src
parentae4fd576bfafca362c35b944cd6fde1d0360dcb2 (diff)
util/SplitString: convert parameter to std::string_view
Diffstat (limited to 'src')
-rw-r--r--src/db/plugins/upnp/UpnpDatabasePlugin.cxx2
-rw-r--r--src/util/SplitString.cxx9
-rw-r--r--src/util/SplitString.hxx5
3 files changed, 9 insertions, 7 deletions
diff --git a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx
index 571f460f3..9c030161a 100644
--- a/src/db/plugins/upnp/UpnpDatabasePlugin.cxx
+++ b/src/db/plugins/upnp/UpnpDatabasePlugin.cxx
@@ -591,7 +591,7 @@ UpnpDatabase::Visit(const DatabaseSelection &selection,
{
DatabaseVisitorHelper helper(CheckSelection(selection), visit_song);
- auto vpath = SplitString(selection.uri.c_str(), '/');
+ auto vpath = SplitString(selection.uri, '/');
if (vpath.empty()) {
for (const auto &server : discovery->GetDirectories()) {
if (visit_directory) {
diff --git a/src/util/SplitString.cxx b/src/util/SplitString.cxx
index 650c6e58e..5676b098f 100644
--- a/src/util/SplitString.cxx
+++ b/src/util/SplitString.cxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2016 Max Kellermann <max.kellermann@gmail.com>
+ * Copyright 2013-2020 Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,13 +32,14 @@
#include "StringStrip.hxx"
std::forward_list<std::string>
-SplitString(const char *s, char separator, bool strip) noexcept
+SplitString(std::string_view _s, char separator, bool strip) noexcept
{
+ StringView s(_s);
if (strip)
- s = StripLeft(s);
+ s.StripLeft();
std::forward_list<std::string> list;
- if (*s == 0)
+ if (s.empty())
return list;
auto i = list.before_begin();
diff --git a/src/util/SplitString.hxx b/src/util/SplitString.hxx
index c22175f2f..7ecc8997e 100644
--- a/src/util/SplitString.hxx
+++ b/src/util/SplitString.hxx
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013-2016 Max Kellermann <max.kellermann@gmail.com>
+ * Copyright 2013-2020 Max Kellermann <max.kellermann@gmail.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,6 +32,7 @@
#include <forward_list>
#include <string>
+#include <string_view>
/**
* Split a string at a certain separator character into sub strings
@@ -44,6 +45,6 @@
* (and not a list with an empty string).
*/
std::forward_list<std::string>
-SplitString(const char *s, char separator, bool strip=true) noexcept;
+SplitString(std::string_view s, char separator, bool strip=true) noexcept;
#endif