util/StringUtil: add StringArrayContainsCase() overload with StringView
This commit is contained in:
parent
74380d2ae4
commit
1a7e3bb358
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2018 The Music Player Daemon Project
|
||||
* Copyright 2003-2019 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "StringUtil.hxx"
|
||||
#include "StringView.hxx"
|
||||
#include "CharUtil.hxx"
|
||||
#include "ASCII.hxx"
|
||||
|
||||
@ -37,6 +38,20 @@ StringArrayContainsCase(const char *const*haystack,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
StringArrayContainsCase(const char *const*haystack,
|
||||
StringView needle) noexcept
|
||||
{
|
||||
assert(haystack != nullptr);
|
||||
assert(needle != nullptr);
|
||||
|
||||
for (; *haystack != nullptr; ++haystack)
|
||||
if (needle.EqualsIgnoreCase(*haystack))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
ToUpperASCII(char *dest, const char *src, size_t size) noexcept
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2018 The Music Player Daemon Project
|
||||
* Copyright 2003-2019 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -24,6 +24,8 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
struct StringView;
|
||||
|
||||
/**
|
||||
* Checks whether a string array contains the specified string.
|
||||
*
|
||||
@ -37,6 +39,11 @@ bool
|
||||
StringArrayContainsCase(const char *const*haystack,
|
||||
const char *needle) noexcept;
|
||||
|
||||
gcc_pure
|
||||
bool
|
||||
StringArrayContainsCase(const char *const*haystack,
|
||||
StringView needle) noexcept;
|
||||
|
||||
/**
|
||||
* Convert the specified ASCII string (0x00..0x7f) to upper case.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user