20 static const WChar STATE_WHITESPACE =
' ';
21 static const WChar STATE_WORD =
'w';
22 static const WChar STATE_QUOTE1 =
'\'';
23 static const WChar STATE_QUOTE2 =
'"';
36 assert(str !=
nullptr);
38 char *dest = MallocT<char>(strlen(str) + 1);
41 WChar state = STATE_WHITESPACE;
42 const char *pos = str;
49 if (c == 0 || (state == STATE_WORD &&
IsWhitespace(c))) {
51 if (word !=
nullptr) {
55 state = STATE_WHITESPACE;
56 if (c != 0)
continue;
else break;
59 if (state == STATE_WHITESPACE) {
65 if (c == STATE_QUOTE1 || c == STATE_QUOTE2) {
70 }
else if (state == STATE_WORD) {
78 if (word ==
nullptr) {
83 memcpy(dest, pos, len);
109 if (str ==
nullptr)
return;
114 if ((match_case ? strstr(str, ws.start) : strcasestr(str, ws.start)) !=
nullptr) {
133 GetString(buffer, str,
lastof(buffer));
Functions related to OTTD's strings.
void ResetState()
Reset the matching state to process a new item.
static bool IsWhitespace(WChar c)
Check whether UNICODE character is whitespace or not, i.e.
static const int DRAW_STRING_BUFFER
Size of the buffer used for drawing strings.
size_t Utf8Decode(WChar *c, const char *s)
Decode and consume the next UTF-8 encoded character.
#define lastof(x)
Get the last element of an fixed size array.
const char * filter_buffer
Parsed filter string. Words separated by 0.
void SetFilterTerm(const char *str)
Set the term to filter on.
Functions related to low-level strings.
Functions related to the gfx engine.
Definition of base types and functions in a cross-platform compatible way.
A number of safeguards to prevent using unsafe methods.
uint word_matches
Summary of filter state: Number of words matched.
State of a single filter word.
uint32 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.
Searching and filtering using a stringterm.
std::vector< WordState > word_index
Word index and filter state.
const bool * case_sensitive
Match case-sensitively (usually a static variable).
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
uint32 WChar
Type for wide characters, i.e.