2023-03-06 14:42:04 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
// Copyright The Music Player Daemon Project
|
2010-12-23 16:13:11 +01:00
|
|
|
|
2013-04-09 01:08:20 +02:00
|
|
|
#include "StringUtil.hxx"
|
2020-03-13 20:38:40 +01:00
|
|
|
#include "StringCompare.hxx"
|
2013-10-19 15:25:32 +02:00
|
|
|
#include "CharUtil.hxx"
|
2010-12-23 16:13:11 +01:00
|
|
|
|
2020-03-12 23:20:59 +01:00
|
|
|
#include <cassert>
|
2014-02-17 22:37:43 +01:00
|
|
|
|
2010-12-23 16:13:11 +01:00
|
|
|
bool
|
2017-05-08 14:44:49 +02:00
|
|
|
StringArrayContainsCase(const char *const*haystack,
|
2020-03-13 20:38:40 +01:00
|
|
|
std::string_view needle) noexcept
|
2010-12-23 16:13:11 +01:00
|
|
|
{
|
2013-04-09 01:08:20 +02:00
|
|
|
assert(haystack != nullptr);
|
2010-12-23 16:13:11 +01:00
|
|
|
|
2013-04-09 01:08:20 +02:00
|
|
|
for (; *haystack != nullptr; ++haystack)
|
2020-03-13 20:38:40 +01:00
|
|
|
if (StringIsEqualIgnoreCase(*haystack, needle))
|
2019-06-11 19:29:40 +02:00
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-12-04 17:43:01 +01:00
|
|
|
void
|
2017-05-08 14:44:49 +02:00
|
|
|
ToUpperASCII(char *dest, const char *src, size_t size) noexcept
|
2014-12-04 17:43:01 +01:00
|
|
|
{
|
|
|
|
assert(dest != nullptr);
|
|
|
|
assert(src != nullptr);
|
|
|
|
assert(size > 1);
|
|
|
|
|
|
|
|
char *const end = dest + size - 1;
|
|
|
|
|
|
|
|
do {
|
|
|
|
char ch = *src++;
|
|
|
|
if (ch == 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
*dest++ = ToUpperASCII(ch);
|
|
|
|
} while (dest < end);
|
|
|
|
|
|
|
|
*dest = 0;
|
|
|
|
}
|