4 * Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
5 * See included license file for license details.
7 #if !defined(_GlobMatcher_h_)
8 #define _GlobMatcher_h_
10 #include "StringMatcher.h"
16 * \brief This class uses glob pattern matching to match strings.
19 * - * matches zero or more characters
20 * - ? matches any single character
21 * - [set] matches any character in the set
22 * - [^set] matches any character NOT in the set
23 * where a set is a group of characters or ranges. a range
24 * is written as two characters seperated with a hyphen: a-z denotes
25 * all characters between a to z inclusive.
26 * - [-set] set matches a literal hypen and any character in the set
27 * - []set] matches a literal close bracket and any character in the set
29 * - char matches itself except where char is '*' or '?' or '['
30 * - \\char matches char, including any pattern character
33 * - a*c ac abc abbc ...
34 * - a?c acc abc aXc ...
35 * - a[a-z]c aac abc acc ...
36 * - a[-a-z]c a-c aac abc ...
38 class GlobMatcher : public StringMatcher
41 //! \brief Constructor.
42 GlobMatcher(const std::string & pattern)
43 : StringMatcher(), m_pattern(pattern)
47 //! \brief Returns whether \a testValue matches the glob pattern.
48 virtual bool match(const std::string & testValue);
51 std::string m_pattern; //!< The glob pattern to match against.
53 //! \brief Glob implementation.
54 bool globMatch(const char * str, const char * p);
57 }; // namespace elftosb
59 #endif // _GlobMatcher_h_