MySQL 9.1.0
Source Code Documentation
Pattern_matcher Class Reference

Enables comparison of strings against particular set of patterns. More...

#include <pattern_matcher.h>

Public Member Functions

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...
 

Private Attributes

std::unordered_set< std::string > m_patterns
 used for storing matcher patterns More...
 

Static Private Attributes

static const char WILD_ONE = '?'
 any (single) character wild card More...
 
static const char WILD_MANY = '*'
 zero or many characters wild card More...
 
static const char WILD_ESCAPE = '\\'
 escape sequence character More...
 

Detailed Description

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.

Member Function Documentation

◆ 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]patternsconcatenated patterns
[in]delimiterdelimiter 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]textstring to search for patterns
[in]infocharset information for comparison rules
Returns
result of matching the text to internal patterns
Return values
trueat least one pattern matches provided string
falsestring does not match any of the patterns

Member Data Documentation

◆ 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: