util/ASCII: migrate to std::string_view

This commit is contained in:
Max Kellermann 2020-03-13 20:17:53 +01:00
parent 45b60b3d38
commit 8a1f1fbe06
4 changed files with 10 additions and 5 deletions

View File

@ -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"

View File

@ -22,6 +22,7 @@
#include "ReplayGainInfo.hxx"
#include "util/ASCII.hxx"
#include "util/NumberParser.hxx"
#include "util/StringView.hxx"
#include <cassert>

View File

@ -19,6 +19,7 @@
#include "Table.hxx"
#include "util/ASCII.hxx"
#include "util/StringView.hxx"
#include <string.h>

View File

@ -30,10 +30,10 @@
#ifndef ASCII_HXX
#define ASCII_HXX
#include "StringView.hxx"
#include "Compiler.h"
#include <cassert>
#include <string_view>
#include <strings.h>
@ -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;
}