44 TagConditionNode(std::string expression,
const std::vector<TagCondition>& conditions);
52 bool evaluate(
const std::vector<std::pair<std::string, std::string>>& files)
const;
98 bool evaluateOnce(
const std::vector<std::pair<std::string, std::string>>& files,
99 std::map<int, bool>& results)
const;
110 std::map<int, bool>& results)
const;
118 bool containsOperator(
const std::string& expression,
const std::string& op)
const;
125 std::vector<std::pair<int, int>>
tokenize(
const std::string& expression)
const;
143 std::vector<std::string>
splitString(
const std::string& input)
const;
155 static void removeSubstring(std::string&
string, std::string substring);
int condition_id_
If this is a leaf: Represents the condition in the tree. Used to avoid evaluating conditions multiple...
Definition tagconditionnode.h:83
bool use_regex_
If true: Use regex to compare against the condition string. Else: Use a simple string matcher with * ...
Definition tagconditionnode.h:88
Type type_
Type of this node.
Definition tagconditionnode.h:74
static void removeSubstring(std::string &string, std::string substring)
Removes all occurrences of substring from string.
Definition tagconditionnode.cpp:437
static bool expressionIsValid(std::string expression, int num_conditions)
Checks if the given string is a syntactically valid boolean expression.
Definition tagconditionnode.cpp:159
void removeWhitespaces(std::string &expression) const
Removes all whitespaces in the given string.
Definition tagconditionnode.cpp:266
bool evaluate(const std::vector< std::pair< std::string, std::string > > &files) const
Checks if files in the given vector satisfy the boolean expression modeled by this tree node.
Definition tagconditionnode.cpp:80
bool containsOperator(const std::string &expression, const std::string &op) const
Checks if the given expression contains the given boolean operator. Only checks the top level part of...
Definition tagconditionnode.cpp:209
bool evaluateOnce(const std::vector< std::pair< std::string, std::string > > &files, std::map< int, bool > &results) const
Checks if files in the given vector satisfy the boolean expression modeled by this tree node....
Definition tagconditionnode.cpp:88
Type
Type of this node.
Definition tagconditionnode.h:23
@ and_connector
Node evaluates to true only if all children evaluate to true.
Definition tagconditionnode.h:25
@ file_matcher
Leaf node. Evaluates to true if a file name matches a pattern.
Definition tagconditionnode.h:29
@ empty
Dummy node. Always evaluates to false.
Definition tagconditionnode.h:33
@ or_connector
Node evaluates to true if at least one child evaluates to true.
Definition tagconditionnode.h:27
@ path_matcher
Leaf node. Evaluates to true if a file path matches a pattern.
Definition tagconditionnode.h:31
std::vector< TagConditionNode > children_
Child nodes of this node.
Definition tagconditionnode.h:72
std::string condition_
String used to comparisons in leaf nodes.
Definition tagconditionnode.h:76
std::vector< std::pair< int, int > > tokenize(const std::string &expression) const
Splits the given expression into tokens. Tokens are either condition ids, boolean operators or a sube...
Definition tagconditionnode.cpp:231
TagConditionNode()
Constructs a node of type empty.
Definition tagconditionnode.cpp:11
static bool operatorOrderIsValid(std::string expression)
Checks if the order of operators in the given boolean expression is valid.
Definition tagconditionnode.cpp:321
std::vector< std::string > splitString(const std::string &input) const
Splits the given string into substrings seperated by the * wildcard.
Definition tagconditionnode.cpp:301
std::vector< std::string > condition_strings_
Used to store substrings of the expression. Split by the * wildcard.
Definition tagconditionnode.h:78
static void removeEnclosingParentheses(std::string &expression)
Removes all outer parentheses that serve no semantic purpose in the given expression.
Definition tagconditionnode.cpp:140
bool evaluateWithoutInversion(const std::vector< std::pair< std::string, std::string > > &files, std::map< int, bool > &results) const
Checks if files in the given vector satisfy the boolean expression modeled by this tree node....
Definition tagconditionnode.cpp:95
bool invert_
If true: Invert the evaluation result.
Definition tagconditionnode.h:70
bool wildcardMatch(const std::string &target) const
Checks if the given string matches this nodes condition_ string. Uses * as a wildcard.
Definition tagconditionnode.cpp:276
std::string expression_
The boolean expression modeled by this tree.
Definition tagconditionnode.h:68
Contains the TagCondition struct.