Go to the documentation of this file.
18 static const WChar STATE_WHITESPACE =
' ';
19 static const WChar STATE_WORD =
'w';
20 static const WChar STATE_QUOTE1 =
'\'';
21 static const WChar STATE_QUOTE2 =
'"';
34 assert(str !=
nullptr);
36 char *dest = MallocT<char>(strlen(str) + 1);
39 WChar state = STATE_WHITESPACE;
40 const char *pos = str;
47 if (c == 0 || (state == STATE_WORD &&
IsWhitespace(c))) {
49 if (word !=
nullptr) {
53 state = STATE_WHITESPACE;
54 if (c != 0)
continue;
else break;
57 if (state == STATE_WHITESPACE) {
63 if (c == STATE_QUOTE1 || c == STATE_QUOTE2) {
68 }
else if (state == STATE_WORD) {
76 if (word ==
nullptr) {
80 memcpy(dest, pos, len);
106 if (str ==
nullptr)
return;
111 if ((match_case ? strstr(str, ws.start) : strcasestr(str, ws.start)) !=
nullptr) {
130 GetString(buffer, str,
lastof(buffer));
char32_t WChar
Type for wide characters, i.e.
void SetFilterTerm(const char *str)
Set the term to filter on.
void AddLine(const char *str)
Pass another text line from the current item to the filter.
static const int DRAW_STRING_BUFFER
Size of the buffer used for drawing strings.
State of a single filter word.
size_t Utf8Decode(WChar *c, const char *s)
Decode and consume the next UTF-8 encoded character.
uint32 StringID
Numeric value that represents a string, independent of the selected language.
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.
const char * filter_buffer
Parsed filter string. Words separated by 0.
static bool IsWhitespace(WChar c)
Check whether UNICODE character is whitespace or not, i.e.
std::vector< WordState > word_index
Word index and filter state.
static void free(const void *ptr)
Version of the standard free that accepts const pointers.
#define lastof(x)
Get the last element of an fixed size array.