2 * File: ExcludesListMatcher.h
4 * Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
5 * See included license file for license details.
7 #if !defined(_ExcludesListMatcher_h_)
8 #define _ExcludesListMatcher_h_
10 #include "GlobMatcher.h"
18 * \brief Matches strings using a series of include and exclude glob patterns.
20 * This string matcher class uses a sequential, ordered list of glob patterns to
21 * determine whether a string matches. Attached to each pattern is an include/exclude
22 * action. The patterns in the list effectively form a Boolean expression. Includes
23 * act as an OR operator while excludes act as an AND NOT operator.
25 * Examples (plus prefix is include, minus prefix is exclude):
28 * - +foo, +bar: foo || bar
29 * - +foo, -bar: foo && !bar
30 * - +foo, -bar, +baz: foo && !bar || baz
32 * The only reason for inheriting from GlobMatcher is so we can access the protected
35 class ExcludesListMatcher : public GlobMatcher
38 //! \brief Default constructor.
39 ExcludesListMatcher();
41 //! \brief Destructor.
42 ~ExcludesListMatcher();
44 //! \name Pattern list
46 //! \brief Add one include or exclude pattern to the end of the match list.
47 void addPattern(bool isInclude, const std::string & pattern);
50 //! \brief Performs a single string match test against testValue.
51 virtual bool match(const std::string & testValue);
54 //! \brief Information about one glob pattern entry in a match list.
55 struct glob_list_item_t
57 bool m_isInclude; //!< True if include, false if exclude.
58 std::string m_glob; //!< The glob pattern to match.
61 typedef std::vector<glob_list_item_t> glob_list_t;
62 glob_list_t m_patterns; //!< Ordered list of include and exclude patterns.
65 }; // namespace elftosb
67 #endif // _ExcludesListMatcher_h_