ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Public Methods | Private Fields | List of all members
TWildcardMatcher< TChar > Class Template Reference

#include <wildcardmatcher.hpp>

Collaboration diagram for TWildcardMatcher< TChar >:
[legend]

Class Description

template<typename TChar>
class aworx::lib::strings::util::TWildcardMatcher< TChar >


This utility class implements so called wildcard string matching. Wildcard characters are

Method Compile accepts the pattern string and translates it to an internal (simple) list of "matching commands". This way, the class is optimized for performance, because after compilation, subsequent invocations of Match do not need to parse the pattern string.

Template Parameters
TCharThe character type. Implementations for nchar and wchar are provided with type definitions aworx::WildcardMatcherN and aworx::WildcardMatcherW.

Definition at line 37 of file wildcardmatcher.hpp.

Public Methods

 TWildcardMatcher (const TString< TChar > &pattern=NullString())
 
ALIB_API void Compile (const TString< TChar > &pattern)
 
ALIB_API bool Match (const TString< TChar > &haystack, Case sensitivity=Case::Sensitive)
 

Private Fields

std::vector< std::pair< int, TString< TChar > > > commands
 

Constructor & Destructor Documentation

◆ TWildcardMatcher()

TWildcardMatcher ( const TString< TChar > &  pattern = NullString())
inline

Constructs a WildcardMatcher to work on a given string. Passes the optional parameters to method Compile.

Parameters
patternThe string pattern to match. Defaults to NullString() to allow parameterless construction, with later invocation of Compile.

Definition at line 51 of file wildcardmatcher.hpp.

Here is the call graph for this function:

Member Function Documentation

◆ Compile()

template ALIB_API void Compile ( const TString< TChar > &  pattern)

Resets this object to use the given pattern.

Parameters
patternThe string pattern to match.

Definition at line 25 of file wildcardmatcher.cpp.

Here is the call graph for this function:

◆ Match()

template ALIB_API bool Match ( const TString< TChar > &  haystack,
Case  sensitivity = Case::Sensitive 
)

Tests if given haystack matches the actual pattern. If Compile was not invoked or an empty pattern string was given, true is returned.

Parameters
haystackThe string to test.
sensitivityDenotes whether the matching is performed case sensitive. Defaults to Case::Sensitive.
Returns
true if given haystack matches the actual pattern, false otherwise.

Definition at line 90 of file wildcardmatcher.cpp.

Here is the call graph for this function:

Member Data Documentation

◆ commands

std::vector<std::pair<int,TString<TChar> > > commands
private

The result list of commands created with Compile and executed with Match.

Definition at line 40 of file wildcardmatcher.hpp.


The documentation for this class was generated from the following files: