1
2
3
4
5
6 #include <cpp2cm/cpp2cm/NothrowList.hpp>
7 #include <soulng/rex/Match.hpp>
8
9 namespace cpp2cm {
10
11 Item::Item(Type type_, const std::u32string& text_, bool default_) : type(type_), text(text_), include(default_)
12 {
13 }
14
15 NothrowPattern::NothrowPattern(soulng::rex::Context& context_, Kind kind_, Item::Type type_, const std::u32string& pattern_) :
16 kind(kind_), type(type_), pattern(pattern_), nfa(soulng::rex::CompileFilePattern(context_, pattern_))
17 {
18 }
19
20 void NothrowPattern::ApplyTo(Item& item)
21 {
22 if (item.type == type)
23 {
24 bool match = soulng::rex::PatternMatch(item.text, nfa);
25 if (match)
26 {
27 if (kind == Kind::include)
28 {
29 item.include = true;
30 }
31 else if (kind == Kind::exclude)
32 {
33 item.include = false;
34 }
35 }
36 }
37 }
38
39 NothrowList::NothrowList(bool verbose_) : verbose(verbose_)
40 {
41 }
42
43 void NothrowList::AddPattern(const NothrowPattern& pattern)
44 {
45 patterns.push_back(pattern);
46 }
47
48 void NothrowList::ApplyTo(Item& item)
49 {
50 for (auto& pattern : patterns)
51 {
52 pattern.ApplyTo(item);
53 }
54 }
55
56 }