blob: c9e564124d7a5eef2679448254c985e6e8461a3b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/*
* File: GlobMatcher.h
*
* Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
* See included license file for license details.
*/
#if !defined(_GlobMatcher_h_)
#define _GlobMatcher_h_
#include "StringMatcher.h"
namespace elftosb
{
/*!
* \brief 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 ...
*/
class GlobMatcher : public StringMatcher
{
public:
//! \brief Constructor.
GlobMatcher(const std::string & pattern)
: StringMatcher(), m_pattern(pattern)
{
}
//! \brief Returns whether \a testValue matches the glob pattern.
virtual bool match(const std::string & testValue);
protected:
std::string m_pattern; //!< The glob pattern to match against.
//! \brief Glob implementation.
bool globMatch(const char * str, const char * p);
};
}; // namespace elftosb
#endif // _GlobMatcher_h_
|