Enables comparison of strings against particular set of patterns.
More...
#include <pattern_matcher.h>
|
size_t | add_patterns (const std::string &patterns, char delimiter=':') |
| Parses concatenated patterns and adds them to internal pattern list. More...
|
|
bool | is_matching (const std::string &text, const CHARSET_INFO *info) const |
| Verifies whether text matches any of the matcher internal patterns. More...
|
|
void | clear () |
| Removes all previously stored patterns from pattern matcher. More...
|
|
|
std::unordered_set< std::string > | m_patterns |
| used for storing matcher patterns More...
|
|
Enables comparison of strings against particular set of patterns.
Patterns may contain wildcards (WILD_ONE/WILD_MANY/WILD_ESCAPE). Pattern strings may be added to the class through a special method. Matching method traverses all of the patterns within pattern matcher in search for a match.
◆ add_patterns()
size_t Pattern_matcher::add_patterns |
( |
const std::string & |
patterns, |
|
|
char |
delimiter = ':' |
|
) |
| |
Parses concatenated patterns and adds them to internal pattern list.
- Parameters
-
[in] | patterns | concatenated patterns |
[in] | delimiter | delimiter for pattern concatenation |
- Returns
- number of added patterns
◆ clear()
void Pattern_matcher::clear |
( |
| ) |
|
Removes all previously stored patterns from pattern matcher.
◆ is_matching()
bool Pattern_matcher::is_matching |
( |
const std::string & |
text, |
|
|
const CHARSET_INFO * |
info |
|
) |
| const |
Verifies whether text matches any of the matcher internal patterns.
- Parameters
-
[in] | text | string to search for patterns |
[in] | info | charset information for comparison rules |
- Returns
- result of matching the text to internal patterns
- Return values
-
true | at least one pattern matches provided string |
false | string does not match any of the patterns |
◆ m_patterns
std::unordered_set<std::string> Pattern_matcher::m_patterns |
|
private |
used for storing matcher patterns
◆ WILD_ESCAPE
const char Pattern_matcher::WILD_ESCAPE = '\\' |
|
staticprivate |
escape sequence character
◆ WILD_MANY
const char Pattern_matcher::WILD_MANY = '*' |
|
staticprivate |
zero or many characters wild card
◆ WILD_ONE
const char Pattern_matcher::WILD_ONE = '?' |
|
staticprivate |
any (single) character wild card
The documentation for this class was generated from the following files: