Kinetis Bootloader Host  2.0.0
Host Tools for Kinetis devices
elftosb::GlobMatcher Class Reference

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

#include <GlobMatcher.h>

+ Inheritance diagram for elftosb::GlobMatcher:
+ Collaboration diagram for elftosb::GlobMatcher:

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
trueThe test value does match the glob pattern.
falseThe test value does not match the glob pattern.

Implements elftosb::StringMatcher.

Reimplemented in elftosb::ExcludesListMatcher.


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