aboutsummaryrefslogtreecommitdiffstats
path: root/src/db/upnp/Util.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-22 09:47:32 +0100
committerMax Kellermann <max@duempel.org>2014-01-22 09:55:51 +0100
commit9747cc9e587a9987a7bdeee0ccf9b3b56f3c803e (patch)
treefb45a43c97fbd145908d46647dc36ef2b0055b21 /src/db/upnp/Util.cxx
parent7b44dea4b1dcfcd74b2648e8be0d6e38918cbe0b (diff)
downloadmpd-9747cc9e587a9987a7bdeee0ccf9b3b56f3c803e.tar.gz
mpd-9747cc9e587a9987a7bdeee0ccf9b3b56f3c803e.tar.xz
mpd-9747cc9e587a9987a7bdeee0ccf9b3b56f3c803e.zip
db/upnp/Device: replace std::vector with a std::string pointer
Diffstat (limited to '')
-rw-r--r--src/db/upnp/Util.cxx21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/db/upnp/Util.cxx b/src/db/upnp/Util.cxx
index 9b223aca9..76710c9ab 100644
--- a/src/db/upnp/Util.cxx
+++ b/src/db/upnp/Util.cxx
@@ -18,7 +18,6 @@
*/
#include "Util.hxx"
-#include "util/CharUtil.hxx"
#include <string>
#include <map>
@@ -28,17 +27,19 @@
#include <upnp/ixml.h>
/** Get rid of white space at both ends */
-std::string
-trimstring(const char *p, size_t length)
+void
+trimstring(std::string &s, const char *ws)
{
- while (length > 0 && IsWhitespaceOrNull(p[length - 1]))
- --length;
-
- const char *end = p + length;
- while (p != end && IsWhitespaceOrNull(*p))
- ++p;
+ auto pos = s.find_first_not_of(ws);
+ if (pos == std::string::npos) {
+ s.clear();
+ return;
+ }
+ s.replace(0, pos, std::string());
- return std::string(p, end);
+ pos = s.find_last_not_of(ws);
+ if (pos != std::string::npos && pos != s.length()-1)
+ s.replace(pos + 1, std::string::npos, std::string());
}
std::string