Line data Source code
1 : #ifndef MFEXTENSIONS_SUPPRESS_H
2 : #define MFEXTENSIONS_SUPPRESS_H
3 :
4 : #include <boost/regex.hpp>
5 : #include <string>
6 :
7 : typedef boost::regex regex_t;
8 : typedef boost::smatch smatch_t;
9 :
10 : /// <summary>
11 : /// Suppress messages based on a regular expression
12 : /// </summary>
13 : class suppress
14 : {
15 : public:
16 : /// <summary>
17 : /// Construct a suppression using the given name for regex matching
18 : /// </summary>
19 : /// <param name="name">Name to suppress</param>
20 : explicit suppress(std::string const& name);
21 :
22 : /// <summary>
23 : /// Check if the name matches this suppression
24 : /// </summary>
25 : /// <param name="name">Name to check</param>
26 : /// <returns>True if name should be suppressed</returns>
27 : bool match(std::string const& name);
28 :
29 : /// <summary>
30 : /// Set whether the suppression is active
31 : /// </summary>
32 : /// <param name="flag">Whether the suppression should be active</param>
33 2 : void use(bool flag) { in_use_ = flag; }
34 :
35 : private:
36 : std::string name_;
37 : regex_t expr_;
38 : smatch_t what_;
39 : bool in_use_;
40 : };
41 :
42 : #endif
|