36 #include <unordered_set> 37 #include <unordered_map> 49 typedef std::pair<std::regex, tagset_t>
rule_t;
53 tagset_t
match(
const tag_t&
tag,
const rule_t& rs);
59 bool match(
const tag_t&
tag,
const ruleset_t& rs, tagset_t& ret,
bool all_rules =
true);
63 tagset_t
transform(
const tagset_t& ts,
const ruleset_t& rs,
bool all_rules =
true);
71 std::unordered_map< std::string, std::vector<ruleset_t> >
m_rulesets;
82 template<
typename Tags>
84 const auto& rsv = m_rulesets[
name];
85 if (rsv.empty() or ind >= rsv.size()) {
89 const auto& rs = rsv[ind];
91 return Tags(out.begin(), out.end());
103 if (cfg.isString()) {
104 ret.insert(cfg.asString());
108 for (
auto one : cfg) {
109 ret.insert(one.asString());
120 for (
auto key : cfg.getMemberNames()) {
121 auto ts = convert<tagrules::tagset_t>(cfg[
key]);
125 ret.push_back(make_pair(std::regex(
key), ts));
std::pair< std::regex, tagset_t > rule_t
tagrules::ruleset_t convert< tagrules::ruleset_t >(const Configuration &cfg, const tagrules::ruleset_t &def)
std::unordered_set< tag_t > tagset_t
tagset_t match(const tag_t &tag, const rule_t &rs)
tagrules::tagset_t convert< tagrules::tagset_t >(const Configuration &cfg, const tagrules::tagset_t &def)
tagset_t transform(const tagset_t &ts, const ruleset_t &rs, bool all_rules=true)
std::vector< rule_t > ruleset_t
std::unordered_map< std::string, std::vector< ruleset_t > > m_rulesets
tagset_t transform(size_t ind, const std::string &name, const tag_t &tag)
Tags transform(size_t ind, const std::string &name, const Tags &tags)
Json::Value Configuration
void configure(const Configuration &cfg)