| 1 |
// Scintilla source code edit control |
| 2 |
/** @file InList.cxx |
| 3 |
** Check if a string is in a list. |
| 4 |
**/ |
| 5 |
// Copyright 2024 by Neil Hodgson <[email protected]> |
| 6 |
// The License.txt file describes the conditions under which this software may be distributed. |
| 7 |
|
| 8 |
#include <cassert> |
| 9 |
|
| 10 |
#include <string> |
| 11 |
#include <string_view> |
| 12 |
#include <initializer_list> |
| 13 |
|
| 14 |
#include "InList.h" |
| 15 |
#include "CharacterSet.h" |
| 16 |
|
| 17 |
namespace Lexilla { |
| 18 |
|
| 19 |
bool InList(std::string_view value, std::initializer_list<std::string_view> list) noexcept { |
| 20 |
for (const std::string_view element : list) { |
| 21 |
if (value == element) { |
| 22 |
return true; |
| 23 |
} |
| 24 |
} |
| 25 |
return false; |
| 26 |
} |
| 27 |
|
| 28 |
bool InListCaseInsensitive(std::string_view value, std::initializer_list<std::string_view> list) noexcept { |
| 29 |
for (const std::string_view element : list) { |
| 30 |
if (EqualCaseInsensitive(value, element)) { |
| 31 |
return true; |
| 32 |
} |
| 33 |
} |
| 34 |
return false; |
| 35 |
} |
| 36 |
|
| 37 |
} |