@@ -37,59 +37,31 @@ namespace modsecurity {
3737class Collection ;
3838class VariableValue {
3939 public:
40- explicit VariableValue (const std::string *key)
41- : m_key(" " ),
42- m_value(" " ) {
43- m_key.assign (*key);
44- m_keyWithCollection = std::make_shared<std::string>(*key);
45- }
46-
47- VariableValue (const std::string *key, const std::string *value)
48- : m_key(" " ),
49- m_value (" " ) {
50- m_key.assign (*key);
51- m_value.assign (*value);
52- m_keyWithCollection = std::make_shared<std::string>(*key);
53- }
54-
55- VariableValue ()
56- : m_key(" " ),
57- m_value(" " ) {
58- m_keyWithCollection = std::make_shared<std::string>(m_key);
59- }
60-
61- VariableValue (const std::string *a, const std::string *b,
62- const std::string *c)
63- : m_key(*a + " :" + *b),
64- m_value(*c) {
65- m_keyWithCollection = std::make_shared<std::string>(*a + " :" + *b);
66- }
67-
68- explicit VariableValue (std::shared_ptr<std::string> fullName)
69- : m_key(" " ),
70- m_value(" " ) {
71- m_keyWithCollection = fullName;
72- m_key.assign (*fullName.get ());
73- }
74-
75- VariableValue (std::shared_ptr<std::string> fullName,
40+ using Origins = std::list<std::unique_ptr<VariableOrigin>>;
41+
42+ VariableValue (const std::string *key,
43+ const std::string *value = nullptr )
44+ : m_key(*key),
45+ m_keyWithCollection (*key),
46+ m_collection(" " ),
47+ m_value(value != nullptr ?*value:" " )
48+ { }
49+
50+ VariableValue (const std::string *collection,
51+ const std::string *key,
7652 const std::string *value)
77- : m_key(" " ),
78- m_value(" " ) {
79- m_value.assign (*value);
80- m_keyWithCollection = fullName;
81- m_key.assign (*fullName.get ());
82- }
83-
53+ : m_key(*key),
54+ m_keyWithCollection(*collection + " :" + *key),
55+ m_collection(*collection),
56+ m_value(*value)
57+ { }
8458
8559 explicit VariableValue (const VariableValue *o) :
86- m_key(" " ),
87- m_value(" " ) {
88- m_key.assign (o->m_key );
89- m_value.assign (o->m_value );
90- m_col.assign (o->m_col );
91- m_keyWithCollection = o->m_keyWithCollection ;
92-
60+ m_key(o->m_key),
61+ m_value(o->m_value),
62+ m_collection(o->m_collection),
63+ m_keyWithCollection(o->m_keyWithCollection)
64+ {
9365 for (auto &i : o->m_orign ) {
9466 std::unique_ptr<VariableOrigin> origin (new VariableOrigin ());
9567 origin->m_offset = i->m_offset ;
@@ -98,11 +70,47 @@ class VariableValue {
9870 }
9971 }
10072
73+
74+ const std::string& getKey () const {
75+ return m_key;
76+ }
77+
78+
79+ const std::string& getKeyWithCollection () const {
80+ return m_keyWithCollection;
81+ }
82+
83+
84+ const std::string& getCollection () const {
85+ return m_collection;
86+ }
87+
88+
89+ const std::string& getValue () const {
90+ return m_value;
91+ }
92+
93+
94+ void setValue (const std::string &value) {
95+ m_value = value;
96+ }
97+
98+
99+ void addOrigin (std::unique_ptr<VariableOrigin> origin) {
100+ m_orign.push_back (std::move (origin));
101+ }
102+
103+
104+ const Origins& getOrigin () const {
105+ return m_orign;
106+ }
107+
108+ private:
109+ Origins m_orign;
110+ std::string m_collection;
101111 std::string m_key;
112+ std::string m_keyWithCollection;
102113 std::string m_value;
103- std::string m_col;
104- std::shared_ptr<std::string> m_keyWithCollection;
105- std::list<std::unique_ptr<VariableOrigin>> m_orign;
106114};
107115
108116} // namespace modsecurity
0 commit comments