8 #include <boost/regex.hpp>
34 if (!myPath.empty()) {
35 init(myPath, triggernames);
59 init(
trim(expression), triggernames);
64 if (expression.empty()) {
68 if (expression.size() == 1 && expression.at(0) ==
'*')
75 using namespace boost;
77 temp = regex_replace(expression, regex(
".AND."),
"&&");
107 return eventSelector_->acceptEvent(array_of_trigger_results, number_of_trigger_paths);
116 for (
int pathIndex = 0; pathIndex < number_of_trigger_paths; ++pathIndex) {
117 int state = array_of_trigger_results[byteIndex] >> (subIndex * 2);
120 tr[pathIndex] = pathStatus;
136 : op_(NonInit), trigBit_(-1) {
142 bool occurrences_ =
false;
147 static const size_t bopsSize_ = 2;
148 static const std::string binaryOperators_[bopsSize_] = {
"||",
"&&"};
150 for (
size_t opr = 0; opr < bopsSize_; opr++) {
151 bool exitloop_ =
false;
156 t_end_ = tmpStr.find(binaryOperators_[opr]);
158 std::cout <<
"offset: " << offset_ <<
" length: " << t_end_ <<
" string: " << tmpStr << std::endl;
160 if (t_end_ == std::string::npos) {
167 if (t_end_ == 0 || t_end_ + 2 >= str_.size())
171 size_t brackets_ = 0;
172 for (
size_t k = offset_;
k < t_end_;
k++) {
173 if (str_.at(
k) ==
'(') {
175 }
else if (str_.at(
k) ==
')') {
176 if (brackets_ == 0) {
183 if (brackets_ == 0) {
187 offset_ = t_end_ + 2;
191 for (
size_t k = offset_;
true;
k++) {
192 if (
k >= str_.size()) {
193 if (bracketcnt_ != 0)
202 if (
k >= t_end_ + 2 && bracketcnt_ == 0) {
204 size_t pos =
temp.find(binaryOperators_[opr]);
205 if (
pos == std::string::npos) {
213 for (
size_t s = 0;
s <
pos;
s++) {
217 }
else if (
temp.at(
pos) ==
')') {
229 offset_ =
k +
pos + 2;
231 if (offset_ >= str_.size())
237 if (str_.at(
k) ==
'(')
239 if (str_.at(
k) ==
')')
257 std::cout <<
"warning: empty element (will return true)" << std::endl;
261 if (str_.at(0) ==
'!') {
267 size_t beginBlock_ = str_.find(
'(');
268 size_t endBlock_ = str_.rfind(
')');
269 bool found_lbracket = (beginBlock_ != std::string::npos);
270 bool found_rbracket = (endBlock_ != std::string::npos);
272 if (found_lbracket != found_rbracket) {
274 }
else if (found_lbracket && found_rbracket) {
275 if (beginBlock_ >= endBlock_) {
278 if (beginBlock_ != 0 || endBlock_ != str_.size() - 1)
281 std::string next = str_.substr(beginBlock_ + 1, endBlock_ - beginBlock_ - 1);
286 }
else if (!found_lbracket && !found_rbracket)
288 bool ignore_if_missing =
true;
289 size_t chr_pos = str_.find(
"@");
290 if (chr_pos != std::string::npos) {
291 ignore_if_missing =
false;
292 str_ = str_.substr(0, chr_pos);
297 if (!ignore_if_missing)
301 std::cout <<
"TriggerSelector: Couldn't match any triggers from: " << str_ << std::endl
302 <<
" Node will not be added " << std::endl;
323 if (!
input.empty()) {
325 if (
pos != std::string::npos)
329 if (
pos != std::string::npos)
337 if (!
input.empty()) {
350 if (children_.empty()) {
351 if (op_ == OR || op_ == NOT)
353 if (op_ ==
AND || op_ == BR)
356 if (trigBit_ < 0 || (
unsigned int)trigBit_ >= trStatus.
size())
366 return !children_[0]->returnStatus(trStatus);
369 return children_[0]->returnStatus(trStatus);
373 for (
size_t i = 0;
i < children_.size();
i++)
376 }
else if (op_ == OR) {
378 for (
size_t i = 0;
i < children_.size();
i++)
383 <<
"Internal error: reached end of returnStatus(...) op:state= " << op_ << std::endl;
388 for (std::vector<TreeElement*>::iterator it = children_.begin(); it != children_.end(); it++)