Matches various fields of an object. More...
#include <cmatchexpression.h>
Classes | |
class | Matchable |
Objects to be matched must implement this interface. More... | |
Public Member Functions | |
cMatchExpression () | |
cMatchExpression (const char *pattern, bool dottedpath, bool fullstring, bool casesensitive) | |
~cMatchExpression () | |
void | setPattern (const char *pattern, bool dottedpath, bool fullstring, bool casesensitive) |
bool | matches (const Matchable *object) |
Matches various fields of an object.
By default, a pattern must match the "default field" of the object, which will usually be its name. Other fields can be matched with the fieldname(pattern) syntax. These elements can be combined with the AND, OR, NOT operators, accepted in both lowercase and uppercase. AND has higher precedence than OR, but parentheses can be used to change the evaluation order.
Patterns are those accepted by cPatternMatcher, that is, "*", "?", character ranges as "{a-z}", numeric ranges as "{0..999}", or bracketed numeric ranges as "[0..999]" (e.g. "*[90..100] matching "foo[95]") are accepted.
Pattern examples:
bool cMatchExpression::matches | ( | const Matchable * | object | ) |
Returns true if the line matches the pattern with the given settings.
See setPattern().
void cMatchExpression::setPattern | ( | const char * | pattern, | |
bool | dottedpath, | |||
bool | fullstring, | |||
bool | casesensitive | |||
) |
Sets the pattern to be used by subsequent calls to matches().
See the general class description for the meaning of the rest of the arguments. Throws cException if the pattern is bogus.