blfwk::GlobMatcher Class Reference

This class uses glob pattern matching to match strings. More...

`#include <GlobMatcher.h>`

Inheritance diagram for blfwk::GlobMatcher:
[legend]
Collaboration diagram for blfwk::GlobMatcher:
[legend]

## Public Member Functions

| GlobMatcher (const std::string &pattern)
| Constructor.
virtual bool | match (const std::string &testValue)
| Returns whether testValue matches the glob pattern. More...

## Protected Member Functions

bool | globMatch (const char *str, const char *p)
| Glob implementation. More...

## Protected Attributes

std::string | m_pattern
| The glob pattern to match against.

## Detailed Description

This class uses glob pattern matching to match strings.

Glob patterns:

- * matches zero or more characters
- ? matches any single character
- [set] matches any character in the set
- [^set] matches any character NOT in the set where a set is a group of characters or ranges. a range is written as two characters seperated with a hyphen: a-z denotes all characters between a to z inclusive.
- [-set] set matches a literal hypen and any character in the set
- []set] matches a literal close bracket and any character in the set
- char matches itself except where char is '*' or '?' or '['
- \char matches char, including any pattern character

Examples:

- a*c ac abc abbc ...
- a?c acc abc aXc ...
- a[a-z]c aac abc acc ...
- a[-a-z]c a-c aac abc ...

## Member Function Documentation

bool GlobMatcher::globMatch | ( | const char * | str,
|  | const char * | p
| ) |  |

protected

Glob implementation.

Note
  This glob implementation was originally written by ozan s. yigit in December 1994. This is public domain source code.

bool GlobMatcher::match | ( | const std::string & | testValue | ) |

virtual

Returns whether testValue matches the glob pattern.

The glob pattern must match the entire test value argument in order for the match to be considered successful. Thus, even if, for example, the pattern matches all but the last character the result will be false.

Return values

  true | The test value does match the glob pattern.
  false | The test value does not match the glob pattern.

Implements blfwk::StringMatcher.

Reimplemented in blfwk::ExcludesListMatcher.

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

- src/blfwk/GlobMatcher.h
- src/blfwk/src/GlobMatcher.cpp