blob: 21203fb4e90c6755a428db60c553ff5c833d8bf6 [file] [log] [blame]
Mike Dodd8cfa7022010-11-17 11:12:26 -08001/**
2 * @file path_filter.h
3 * Filter paths based on globbed exclude/include list
4 *
5 * @remark Copyright 2002 OProfile authors
6 * @remark Read the file COPYING
7 *
8 * @author Philippe Elie
9 * @author John Levon
10 */
11
12#ifndef PATH_FILTER_H
13#define PATH_FILTER_H
14
15#include "glob_filter.h"
16
17/**
18 * path_filter - filtering of a string based on globbed include/exclude list
19 *
20 * This class is an oracle on whether a particular string matches
21 * the given list of included and excluded strings.
22 *
23 * This class gives glob-based matches on each pattern, as with fnmatch(3),
24 * where each component of the candidate path is considered separately.
25 */
26class path_filter : public glob_filter {
27public:
28 /**
29 * Initialise the filter with the include and exclude list,
30 * comma-separated.
31 */
32 path_filter(std::string const & include_patterns = std::string(),
33 std::string const & exclude_patterns = std::string())
34 : glob_filter(include_patterns, exclude_patterns) {}
35
36 /**
37 * Initialise the filter with the include and exclude list.
38 */
39 path_filter(std::vector<std::string> const & include_patterns,
40 std::vector<std::string> const & exclude_patterns)
41 : glob_filter(include_patterns, exclude_patterns) {}
42
43
44 /// Returns true if the given string matches
45 virtual bool match(std::string const & str) const;
46};
47
48#endif /* PATH_FILTER_H */