2017-05-21 19:51:15 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-05-21 21:00:48 +00:00
|
|
|
#include <optional.h>
|
|
|
|
|
2017-05-21 19:51:15 +00:00
|
|
|
#include <regex>
|
2017-05-21 21:00:48 +00:00
|
|
|
#include <string>
|
2017-05-21 19:51:15 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
struct Matcher {
|
2017-05-21 21:00:48 +00:00
|
|
|
static optional<Matcher> Create(const std::string& search);
|
2017-05-21 19:51:15 +00:00
|
|
|
|
|
|
|
bool IsMatch(const std::string& value) const;
|
|
|
|
|
|
|
|
std::string regex_string;
|
|
|
|
std::regex regex;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Check multiple |Matcher| instances at the same time.
|
|
|
|
struct GroupMatch {
|
|
|
|
GroupMatch(const std::vector<std::string>& whitelist,
|
|
|
|
const std::vector<std::string>& blacklist);
|
|
|
|
|
2017-09-22 01:14:57 +00:00
|
|
|
bool IsMatch(const std::string& value,
|
|
|
|
std::string* match_failure_reason = nullptr) const;
|
2017-05-21 19:51:15 +00:00
|
|
|
|
|
|
|
std::vector<Matcher> whitelist;
|
|
|
|
std::vector<Matcher> blacklist;
|
|
|
|
};
|