From 8a1f1fbe060e9606ad3f1fc2ad1b3d63e6e25e8b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 13 Mar 2020 20:17:53 +0100 Subject: [PATCH] util/ASCII: migrate to std::string_view --- src/input/plugins/CurlInputPlugin.cxx | 1 + src/tag/ReplayGain.cxx | 1 + src/tag/Table.cxx | 1 + src/util/ASCII.hxx | 12 +++++++----- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/input/plugins/CurlInputPlugin.cxx b/src/input/plugins/CurlInputPlugin.cxx index 9fc1710d5..60d3df8c1 100644 --- a/src/input/plugins/CurlInputPlugin.cxx +++ b/src/input/plugins/CurlInputPlugin.cxx @@ -36,6 +36,7 @@ #include "event/Loop.hxx" #include "util/ASCII.hxx" #include "util/StringFormat.hxx" +#include "util/StringView.hxx" #include "util/NumberParser.hxx" #include "util/Domain.hxx" #include "Log.hxx" diff --git a/src/tag/ReplayGain.cxx b/src/tag/ReplayGain.cxx index bd8d65fda..72fbd54d4 100644 --- a/src/tag/ReplayGain.cxx +++ b/src/tag/ReplayGain.cxx @@ -22,6 +22,7 @@ #include "ReplayGainInfo.hxx" #include "util/ASCII.hxx" #include "util/NumberParser.hxx" +#include "util/StringView.hxx" #include diff --git a/src/tag/Table.cxx b/src/tag/Table.cxx index 4e1bd4958..188cd58bc 100644 --- a/src/tag/Table.cxx +++ b/src/tag/Table.cxx @@ -19,6 +19,7 @@ #include "Table.hxx" #include "util/ASCII.hxx" +#include "util/StringView.hxx" #include diff --git a/src/util/ASCII.hxx b/src/util/ASCII.hxx index ad063db77..df51d8650 100644 --- a/src/util/ASCII.hxx +++ b/src/util/ASCII.hxx @@ -30,10 +30,10 @@ #ifndef ASCII_HXX #define ASCII_HXX -#include "StringView.hxx" #include "Compiler.h" #include +#include #include @@ -73,17 +73,19 @@ StringEqualsCaseASCII(const char *a, const char *b, size_t n) noexcept gcc_pure gcc_nonnull_all static inline bool -StringStartsWithCaseASCII(const char *haystack, StringView needle) noexcept +StringStartsWithCaseASCII(const char *haystack, + std::string_view needle) noexcept { - return StringEqualsCaseASCII(haystack, needle.data, needle.size); + return StringEqualsCaseASCII(haystack, needle.data(), needle.length()); } gcc_pure gcc_nonnull_all static inline const char * -StringAfterPrefixCaseASCII(const char *haystack, StringView needle) noexcept +StringAfterPrefixCaseASCII(const char *haystack, + std::string_view needle) noexcept { return StringStartsWithCaseASCII(haystack, needle) - ? haystack + needle.size + ? haystack + needle.length() : nullptr; }