Makes @pm compatible with the brand new capture schema

This commit is contained in:
Felipe Zimmerle 2016-11-23 17:10:06 -03:00
parent eecb90cfd0
commit 7a36499f22
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277
2 changed files with 17 additions and 2 deletions

View File

@ -88,7 +88,8 @@ void Pm::replaceAll(std::string str, const std::string& from,
}
}
bool Pm::evaluate(Transaction *transaction, const std::string &input) {
bool Pm::evaluate(Transaction *transaction, Rule *rule,
const std::string &input) {
int rc = 0;
ACMPT pt;
pt.parser = m_p;
@ -96,10 +97,19 @@ bool Pm::evaluate(Transaction *transaction, const std::string &input) {
const char *match = NULL;
rc = acmp_process_quick(&pt, &match, input.c_str(), input.length());
bool capture = rule && rule->getActionsByName("capture").size() > 0;
if (rc == 1 && transaction) {
transaction->m_matched.push_back(std::string(match));
}
if (capture && transaction && rc) {
transaction->m_collections.storeOrUpdateFirst("TX", "0",
std::string(match));
transaction->debug(7, "Added pm match TX.0: " + \
std::string(match));
}
return rc == 1;
}

View File

@ -37,7 +37,12 @@ class Pm : public Operator {
~Pm();
void replaceAll(std::string str, const std::string& from,
const std::string& to);
bool evaluate(Transaction *transaction, const std::string &input) override;
bool evaluate(Transaction *transaction, Rule *rule,
const std::string &input) override;
bool evaluate(Transaction *transaction,
const std::string &input) override {
return evaluate(transaction, NULL, input);
}
bool init(const std::string &file, std::string *error) override;
void postOrderTraversal(acmp_btree_node_t *node);