summaryrefslogtreecommitdiff
path: root/mask.h
blob: eb729901545e3902d77e798530c60ab2a8939df7 (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
#ifndef _MASK_H
#define _MASK_H

#include "utils.h"

#include <boost/regex.hpp>

namespace ledger {

class mask_t
{
 public:
  bool	       exclude;
  boost::regex expr;

  explicit mask_t(const string& pattern);
  mask_t(const mask_t& m) : exclude(m.exclude), expr(m.expr) {}

  bool match(const string& str) const {
    return boost::regex_match(str, expr) && ! exclude;
  }
};

class mask_error : public error {
 public:
  mask_error(const string& _reason) throw() : error(_reason) {}
  virtual ~mask_error() throw() {}
};

} // namespace ledger

#endif // _MASK_H