All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TfPatternMatcher Class Reference

#include <patternMatcher.h>

Public Member Functions

TF_API TfPatternMatcher ()
 Construct an empty (invalid) TfPatternMatcher. More...
TF_API TfPatternMatcher (TfPatternMatcher &&) noexcept=default
TF_API TfPatternMatcheroperator= (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::stringGetPattern () 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...

Detailed Description

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.

Constructor & Destructor Documentation

TF_API TfPatternMatcher::TfPatternMatcher ( )

Construct an empty (invalid) TfPatternMatcher.

TF_API TfPatternMatcher::TfPatternMatcher ( TfPatternMatcher &&  )
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 ( )


Member Function Documentation

TF_API std::string TfPatternMatcher::GetInvalidReason ( ) const

If IsValid() returns true, this will return the reason why (if any).

TF_API const std::string& TfPatternMatcher::GetPattern ( ) const

Returns the matcher's pattern string.

Definition at line 86 of file patternMatcher.h.

bool TfPatternMatcher::IsCaseSensitive ( ) const

Returns true if the matcher has been set to be case sensitive, false otherwise.

Definition at line 75 of file patternMatcher.h.

bool TfPatternMatcher::IsGlobPattern ( ) const

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.

Unlike 'match' functions in other regular expression libraries, this method does not implicitly anchor the pattern. If a partial match is not acceptable, it is necessary to anchor the pattern passed to the constructor, e.g. "^mypattern$".
TF_API TfPatternMatcher& TfPatternMatcher::operator= ( TfPatternMatcher &&  )
TF_API void TfPatternMatcher::SetIsCaseSensitive ( bool  sensitive)

Set this matcher to match case-sensitively or not.

TF_API void TfPatternMatcher::SetIsGlobPattern ( bool  isGlob)

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.

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