HDK
|
#include <patternMatcher.h>
Public Member Functions | |
TF_API | TfPatternMatcher () |
Construct an empty (invalid) TfPatternMatcher. More... | |
TF_API | TfPatternMatcher (TfPatternMatcher &&) noexcept=default |
TF_API TfPatternMatcher & | operator= (TfPatternMatcher &&)=default |
TF_API | TfPatternMatcher (const std::string &pattern, bool caseSensitive=false, bool isGlob=false) |
TF_API | ~TfPatternMatcher () |
Destructor. More... | |
TF_API std::string | GetInvalidReason () const |
If IsValid() returns true, this will return the reason why (if any). More... | |
bool | IsCaseSensitive () const |
bool | IsGlobPattern () const |
TF_API const std::string & | GetPattern () const |
Returns the matcher's pattern string. More... | |
TF_API bool | IsValid () const |
TF_API bool | Match (const std::string &query, std::string *errorMsg=NULL) const |
TF_API void | SetIsCaseSensitive (bool sensitive) |
Set this matcher to match case-sensitively or not. More... | |
TF_API void | SetIsGlobPattern (bool isGlob) |
TF_API void | SetPattern (const std::string &pattern) |
Set the pattern that this matcher will use to match against. More... | |
Class for matching regular expressions.
A matcher is good to use when you have many strings to match against one pattern. This is because the matcher will only compile the regular expression once.
Definition at line 48 of file patternMatcher.h.
TF_API TfPatternMatcher::TfPatternMatcher | ( | ) |
Construct an empty (invalid) TfPatternMatcher.
|
defaultnoexcept |
TF_API TfPatternMatcher::TfPatternMatcher | ( | const std::string & | pattern, |
bool | caseSensitive = false , |
||
bool | isGlob = false |
||
) |
Construct a TfPatternMatcher with a default configuration. Note that pattern compilation will not occur until the first call to Match() or IsValid().
TF_API TfPatternMatcher::~TfPatternMatcher | ( | ) |
Destructor.
TF_API std::string TfPatternMatcher::GetInvalidReason | ( | ) | const |
If IsValid() returns true, this will return the reason why (if any).
|
inline |
Returns the matcher's pattern string.
Definition at line 86 of file patternMatcher.h.
|
inline |
Returns true if the matcher has been set to be case sensitive, false otherwise.
Definition at line 75 of file patternMatcher.h.
|
inline |
Returns true if the matcher has been set to treat patterns as glob patterns, false otherwise.
Definition at line 81 of file patternMatcher.h.
TF_API bool TfPatternMatcher::IsValid | ( | ) | const |
Returns true if the matcher has a valid pattern. Note that empty patterns are considered invalid. This will cause a compile of
TF_API bool TfPatternMatcher::Match | ( | const std::string & | query, |
std::string * | errorMsg = NULL |
||
) | const |
Returns true if query matches the matcher's pattern.
If there is an error in matching and errorMsg is not NULL, it will be set with the error message. If the matcher is not valid, this will return false. Note that this will cause a compile of the matcher's pattern if it was not already compiled.
|
default |
Set this matcher to match case-sensitively or not.
Set this matcher to treat its pattern as a glob pattern. Currently, this means that the pattern will be transformed by replacing all instances of '.' with '.', '*' with '.*', and '?' with '.', in that order before being compiled as a normal regular expression.
TF_API void TfPatternMatcher::SetPattern | ( | const std::string & | pattern | ) |
Set the pattern that this matcher will use to match against.