Cosmetics: Using VariableValues instead of std::vector<...>

Making the code more readable.
This commit is contained in:
Felipe Zimmerle
2020-08-24 12:57:47 -03:00
committed by Felipe Zimmerle
parent d5cae10d3a
commit 64bffdebc4
54 changed files with 123 additions and 119 deletions

View File

@@ -92,18 +92,18 @@ class AnchoredSetVariable : public std::unordered_multimap<std::string,
void setCopy(std::string key, std::string value, size_t offset);
void resolve(std::vector<std::shared_ptr<const VariableValue>> *l);
void resolve(std::vector<std::shared_ptr<const VariableValue>> *l,
void resolve(VariableValues *l);
void resolve(VariableValues *l,
variables::KeyExclusions &ke);
void resolve(const std::string &key,
std::vector<std::shared_ptr<const VariableValue>> *l);
VariableValues *l);
void resolveRegularExpression(Utils::Regex *r,
std::vector<std::shared_ptr<const VariableValue>> *l);
VariableValues *l);
void resolveRegularExpression(Utils::Regex *r,
std::vector<std::shared_ptr<const VariableValue>> *l,
VariableValues *l,
variables::KeyExclusions &ke);
std::unique_ptr<std::string> resolveFirst(const std::string &key);

View File

@@ -69,7 +69,7 @@ class AnchoredVariable {
void append(const std::string &a, size_t offset,
bool spaceSeparator, int size);
void evaluate(std::vector<std::shared_ptr<const VariableValue>> *l);
void evaluate(VariableValues *l);
std::string * evaluate();
std::unique_ptr<std::string> resolveFirst();

View File

@@ -60,12 +60,12 @@ class Collection {
const std::string& var) = 0;
virtual void resolveSingleMatch(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l) = 0;
VariableValues *l) = 0;
virtual void resolveMultiMatches(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l,
VariableValues *l,
variables::KeyExclusions &ke) = 0;
virtual void resolveRegularExpression(const std::string& var,
std::vector<std::shared_ptr<const VariableValue>> *l,
VariableValues *l,
variables::KeyExclusions &ke) = 0;
@@ -146,7 +146,7 @@ class Collection {
/* resolveSingleMatch */
virtual void resolveSingleMatch(const std::string& var,
std::string compartment, std::vector<std::shared_ptr<const VariableValue>> *l) {
std::string compartment, VariableValues *l) {
std::string nkey = compartment + "::" + var;
resolveSingleMatch(nkey, l);
}
@@ -154,7 +154,7 @@ class Collection {
virtual void resolveSingleMatch(const std::string& var,
std::string compartment, std::string compartment2,
std::vector<std::shared_ptr<const VariableValue>> *l) {
VariableValues *l) {
std::string nkey = compartment + "::" + compartment2 + "::" + var;
resolveSingleMatch(nkey, l);
}
@@ -162,7 +162,7 @@ class Collection {
/* resolveMultiMatches */
virtual void resolveMultiMatches(const std::string& var,
std::string compartment, std::vector<std::shared_ptr<const VariableValue>> *l,
std::string compartment, VariableValues *l,
variables::KeyExclusions &ke) {
std::string nkey = compartment + "::" + var;
resolveMultiMatches(nkey, l, ke);
@@ -171,7 +171,7 @@ class Collection {
virtual void resolveMultiMatches(const std::string& var,
std::string compartment, std::string compartment2,
std::vector<std::shared_ptr<const VariableValue>> *l,
VariableValues *l,
variables::KeyExclusions &ke) {
std::string nkey = compartment + "::" + compartment2 + "::" + var;
resolveMultiMatches(nkey, l, ke);
@@ -180,7 +180,7 @@ class Collection {
/* resolveRegularExpression */
virtual void resolveRegularExpression(const std::string& var,
std::string compartment, std::vector<std::shared_ptr<const VariableValue>> *l,
std::string compartment, VariableValues *l,
variables::KeyExclusions &ke) {
std::string nkey = compartment + "::" + var;
resolveRegularExpression(nkey, l, ke);
@@ -189,7 +189,7 @@ class Collection {
virtual void resolveRegularExpression(const std::string& var,
std::string compartment, std::string compartment2,
std::vector<std::shared_ptr<const VariableValue>> *l, variables::KeyExclusions &ke) {
VariableValues *l, variables::KeyExclusions &ke) {
std::string nkey = compartment + "::" + compartment2 + "::" + var;
resolveRegularExpression(nkey, l, ke);
}

View File

@@ -34,10 +34,14 @@ typedef struct Variable_t VariableValue;
#ifdef __cplusplus
namespace modsecurity {
class VariableValue;
using VariableValues = std::vector<std::shared_ptr<const VariableValue>>;
using Origins = std::vector<VariableOrigin>;
class Collection;
class VariableValue {
public:
using Origins = std::vector<VariableOrigin>;
explicit VariableValue(const std::string *key,
const std::string *value = nullptr)