diff --git a/src/db/plugins/upnp/Directory.cxx b/src/db/plugins/upnp/Directory.cxx index b31b99901..6f1d2b7db 100644 --- a/src/db/plugins/upnp/Directory.cxx +++ b/src/db/plugins/upnp/Directory.cxx @@ -216,8 +216,8 @@ protected: }; void -UPnPDirContent::Parse(const char *input) +UPnPDirContent::Parse(std::string_view input) { UPnPDirParser parser(*this); - parser.Parse(input, strlen(input), true); + parser.Parse(input, true); } diff --git a/src/db/plugins/upnp/Directory.hxx b/src/db/plugins/upnp/Directory.hxx index a2803e221..cdd31dd29 100644 --- a/src/db/plugins/upnp/Directory.hxx +++ b/src/db/plugins/upnp/Directory.hxx @@ -1,12 +1,11 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright The Music Player Daemon Project -#ifndef MPD_UPNP_DIRECTORY_HXX -#define MPD_UPNP_DIRECTORY_HXX +#pragma once #include "Object.hxx" -#include +#include #include /** @@ -44,7 +43,5 @@ public: * actually global, nothing really bad will happen if you mix * up... */ - void Parse(const char *didltext); + void Parse(std::string_view didltext); }; - -#endif /* _UPNPDIRCONTENT_H_X_INCLUDED_ */ diff --git a/src/lib/expat/ExpatParser.cxx b/src/lib/expat/ExpatParser.cxx index 8c26e66e9..a620e760b 100644 --- a/src/lib/expat/ExpatParser.cxx +++ b/src/lib/expat/ExpatParser.cxx @@ -7,9 +7,9 @@ #include void -ExpatParser::Parse(const char *data, size_t length, bool is_final) +ExpatParser::Parse(std::string_view src, bool is_final) { - if (XML_Parse(parser, data, length, is_final) != XML_STATUS_OK) + if (XML_Parse(parser, src.data(), src.size(), is_final) != XML_STATUS_OK) throw ExpatError(parser); } diff --git a/src/lib/expat/ExpatParser.hxx b/src/lib/expat/ExpatParser.hxx index 0a49b06a0..0ea814248 100644 --- a/src/lib/expat/ExpatParser.hxx +++ b/src/lib/expat/ExpatParser.hxx @@ -1,12 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright The Music Player Daemon Project -#ifndef MPD_EXPAT_HXX -#define MPD_EXPAT_HXX +#pragma once #include #include +#include #include class InputStream; @@ -54,10 +54,10 @@ public: XML_SetCharacterDataHandler(parser, charhndl); } - void Parse(const char *data, size_t length, bool is_final=false); + void Parse(std::string_view src, bool is_final=false); void CompleteParse() { - Parse("", 0, true); + Parse({}, true); } void Parse(InputStream &is); @@ -135,5 +135,3 @@ private: p.CharacterData(s, len); } }; - -#endif diff --git a/src/lib/upnp/Device.cxx b/src/lib/upnp/Device.cxx index 3221642fd..266bcd29c 100644 --- a/src/lib/upnp/Device.cxx +++ b/src/lib/upnp/Device.cxx @@ -79,11 +79,11 @@ protected: }; void -UPnPDevice::Parse(const std::string_view url, const char *description) +UPnPDevice::Parse(const std::string_view url, const std::string_view description) { { UPnPDeviceParser mparser(*this); - mparser.Parse(description, strlen(description), true); + mparser.Parse(description, true); } if (URLBase.empty()) { diff --git a/src/lib/upnp/Device.hxx b/src/lib/upnp/Device.hxx index d0f739701..2098515f0 100644 --- a/src/lib/upnp/Device.hxx +++ b/src/lib/upnp/Device.hxx @@ -56,5 +56,5 @@ public: * @param url where the description came from * @param description the xml device description */ - void Parse(std::string_view url, const char *description); + void Parse(std::string_view url, std::string_view description); }; diff --git a/src/lib/upnp/Discovery.cxx b/src/lib/upnp/Discovery.cxx index 0cefc3fe8..68cc5a6a3 100644 --- a/src/lib/upnp/Discovery.cxx +++ b/src/lib/upnp/Discovery.cxx @@ -63,7 +63,7 @@ UPnPDeviceDirectory::Downloader::OnEnd() expires); try { - d.Parse(url, data.c_str()); + d.Parse(url, data); } catch (...) { LogError(std::current_exception()); } diff --git a/src/lib/upnp/Discovery.hxx b/src/lib/upnp/Discovery.hxx index 9fcaf4b2d..0cc85fd89 100644 --- a/src/lib/upnp/Discovery.hxx +++ b/src/lib/upnp/Discovery.hxx @@ -55,7 +55,7 @@ class UPnPDeviceDirectory final : UpnpCallback { :id(std::move(_id)), expires(last + exp + std::chrono::seconds(20)) {} - void Parse(std::string_view url, const char *description) { + void Parse(std::string_view url, std::string_view description) { device.Parse(url, description); } }; diff --git a/src/storage/plugins/CurlStorage.cxx b/src/storage/plugins/CurlStorage.cxx index 1f9987939..3fa88f9d9 100644 --- a/src/storage/plugins/CurlStorage.cxx +++ b/src/storage/plugins/CurlStorage.cxx @@ -297,9 +297,8 @@ private: throw std::runtime_error("Unexpected Content-Type from WebDAV server"); } - void OnData(std::span _src) final { - auto src = ToStringView(_src); - Parse(src.data(), src.size()); + void OnData(std::span src) final { + Parse(ToStringView(src)); } void OnEnd() final {