OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
19 static const char32_t STATE_WHITESPACE =
' ';
20 static const char32_t STATE_WORD =
'w';
21 static const char32_t STATE_QUOTE1 =
'\'';
22 static const char32_t STATE_QUOTE2 =
'"';
35 assert(str !=
nullptr);
37 char *dest = MallocT<char>(strlen(str) + 1);
40 char32_t state = STATE_WHITESPACE;
41 const char *pos = str;
48 if (c == 0 || (state == STATE_WORD &&
IsWhitespace(c))) {
50 if (word !=
nullptr) {
54 state = STATE_WHITESPACE;
55 if (c != 0)
continue;
else break;
58 if (state == STATE_WHITESPACE) {
64 if (c == STATE_QUOTE1 || c == STATE_QUOTE2) {
69 }
else if (state == STATE_WORD) {
77 if (word ==
nullptr) {
81 memcpy(dest, pos, len);
116 if (str ==
nullptr)
return;
127 if ((match_case ? strstr(str, ws.start) : strcasestr(str, ws.start)) !=
nullptr) {
void SetFilterTerm(const char *str)
Set the term to filter on.
uint32_t StringID
Numeric value that represents a string, independent of the selected language.
void AddLine(const char *str)
Pass another text line from the current item to the filter.
void free(const void *ptr)
Version of the standard free that accepts const pointers.
State of a single filter word.
const bool * case_sensitive
Match case-sensitively (usually a static variable).
uint word_matches
Summary of filter state: Number of words matched.
void ResetState()
Reset the matching state to process a new item.
std::string GetString(StringID string)
Resolve the given StringID into a std::string with all the associated DParam lookups and formatting.
const char * filter_buffer
Parsed filter string. Words separated by 0.
bool IsWhitespace(char32_t c)
Check whether UNICODE character is whitespace or not, i.e.
bool locale_aware
Match words using the current locale.
std::vector< WordState > word_index
Word index and filter state.
size_t Utf8Decode(char32_t *c, const char *s)
Decode and consume the next UTF-8 encoded character.
bool StrNaturalContains(const std::string_view str, const std::string_view value)
Checks if a string is contained in another string with a locale-aware comparison that is case sensiti...
bool StrNaturalContainsIgnoreCase(const std::string_view str, const std::string_view value)
Checks if a string is contained in another string with a locale-aware comparison that is case insensi...