blob: ba848ddc7218399caa5477dc5722ba6e263bf7be (
plain) (
blame)
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
|
#include "pattern_group.h"
namespace NYql {
void TPatternGroup::Add(const TString& pattern, const TString& alias) {
auto it = CompiledPatterns_.find(pattern);
if (it != CompiledPatterns_.end()) {
return;
}
CompiledPatterns_.emplace(pattern, std::make_pair(TRegExMatch(pattern), alias));
}
bool TPatternGroup::IsEmpty() const {
return CompiledPatterns_.empty();
}
TMaybe<TString> TPatternGroup::Match(const TString& s) const {
for (auto& p : CompiledPatterns_) {
if (p.second.first.Match(s.c_str())) {
return p.second.second;
}
}
return Nothing();
}
}
|