HDK
|
#include <PDG_AttributePattern.h>
Classes | |
struct | ComponentMatch |
Public Types | |
enum | MatchType : uint8 { eMatchAll, eMatchPrefix, eMatchSuffix, eMatchBoth, eMatchPlain } |
For compound matching, e.g. foobar or bin*:float. More... | |
using | ComponentMap = UT_StringMap< ComponentMatch > |
Map of attribute name to ComponentMatch. More... | |
Public Member Functions | |
PDG_AttributePattern () | |
Constructs a default-initialized, invalid pattern. More... | |
PDG_AttributePattern (const UT_StringHolder &pattern, MatchType default_match_type=eMatchPlain, bool strict=true) | |
Parses a pattern into a PDG_AttributePattern instance. More... | |
bool | reset (const UT_StringHolder &pattern, MatchType default_match_type=eMatchPlain, bool strict=true) |
Clears the pattern and recompiles it from the specified pattern string. More... | |
bool | tryReset (const UT_StringHolder &pattern, MatchType default_match_type=eMatchPlain, bool strict=true) |
bool | contains (const UT_StringHolder &name, PDG_AttributeType type=PDG_AttributeType::eUndefined) const |
Returns true if the attribute/type is include in the pattern. More... | |
bool | components (ComponentMatch &components, const UT_StringHolder &name, PDG_AttributeType type=PDG_AttributeType::eUndefined) const |
void | multiMatch (UT_StringArray &match_results, const UT_StringArray &input_names, bool keep_plain) const |
void | multiMatch (ComponentMap &match_components, const UT_StringArray &input_names, bool keep_plain) const |
Public Member Functions inherited from PDG_BasePattern | |
PDG_BasePattern (const UT_StringHolder &pattern) | |
Constructs a default-initialized, invalid pattern. More... | |
bool | isValid () const |
const UT_WorkBuffer & | errors () const |
If the pattern is invalid, contains parse errors. More... | |
const UT_StringHolder & | pattern () const |
Returns the pattern used to construct this object. More... | |
bool | hasPattern () const |
Returns true if there is a pattern set. More... | |
void | reset (const UT_StringHolder &pattern) |
Resets the pattern. More... | |
Additional Inherited Members | |
Protected Types inherited from PDG_BasePattern | |
enum | ParseTokens : uint8 { eStarToken = '*', eExcludeToken = '^', eSeparatorToken = ':', eRangeToken = '-', eQuoteToken = '"', eEscapeToken = '\\', eRangeBeginToken = '[', eRangeEndToken = ']', eAttributeToken = '@', eComponentToken = '.' } |
Special tokens, in addition to alphanumeric and whitespace. More... | |
Protected Attributes inherited from PDG_BasePattern | |
UT_WorkBuffer | myErrors |
Parse errors. More... | |
UT_StringHolder | myPattern |
The pattern used to construct this object. More... | |
bool | myIsValid |
Whether or not the pattern is valid. More... | |
Pattern for matching a list of attributes. A pattern object is constructed from a valid pattern string, such as: * ^foo.
A pattern is a whitespace seperated sequence of match conditions. Each condition can:
The following are valid:
* * ^foo:float * ^*foo ^bar* ^*foobar* ^*:string *:integer foo ^bar *:python
The following are not: ^ foo*bar ** f*o ^:integer ^*:foobar
Pattern rules are applied left to right when checking if an attribute name matches.
If the pattern matcher is constructed with the strict option set to false, then all characters except for * an ^ are valid for attribute names. This also disables the type specifier : character, and type name parsing.
Definition at line 62 of file PDG_AttributePattern.h.
Map of attribute name to ComponentMatch.
Definition at line 98 of file PDG_AttributePattern.h.
For compound matching, e.g. foobar or bin*:float.
Definition at line 66 of file PDG_AttributePattern.h.
PDG_AttributePattern::PDG_AttributePattern | ( | ) |
Constructs a default-initialized, invalid pattern.
PDG_AttributePattern::PDG_AttributePattern | ( | const UT_StringHolder & | pattern, |
MatchType | default_match_type = eMatchPlain , |
||
bool | strict = true |
||
) |
Parses a pattern into a PDG_AttributePattern instance.
bool PDG_AttributePattern::components | ( | ComponentMatch & | components, |
const UT_StringHolder & | name, | ||
PDG_AttributeType | type = PDG_AttributeType::eUndefined |
||
) | const |
Returns true if the attribute/type is included in the pattern, and writes the match components.
bool PDG_AttributePattern::contains | ( | const UT_StringHolder & | name, |
PDG_AttributeType | type = PDG_AttributeType::eUndefined |
||
) | const |
Returns true if the attribute/type is include in the pattern.
void PDG_AttributePattern::multiMatch | ( | UT_StringArray & | match_results, |
const UT_StringArray & | input_names, | ||
bool | keep_plain | ||
) | const |
Applies the pattern to the specified list of input names, and returns the final list of names that matched the pattern. If keep_plain is true, then any non-glob pattern pattern entries are always included even if they don't appear in the input names list.
void PDG_AttributePattern::multiMatch | ( | ComponentMap & | match_components, |
const UT_StringArray & | input_names, | ||
bool | keep_plain | ||
) | const |
Applies the pattern to the specified list of input names, and returns a map of matched components for each name. If keep_plain is true, then any non-glob pattern entries are always included even if they don't appear in the input names list.
bool PDG_AttributePattern::reset | ( | const UT_StringHolder & | pattern, |
MatchType | default_match_type = eMatchPlain , |
||
bool | strict = true |
||
) |
Clears the pattern and recompiles it from the specified pattern string.
bool PDG_AttributePattern::tryReset | ( | const UT_StringHolder & | pattern, |
MatchType | default_match_type = eMatchPlain , |
||
bool | strict = true |
||
) |
Resets the pattern if doesn't match the specified pattern string and configuration arguments.