Uses shared_ptr on variable names

This commit is contained in:
Felipe Zimmerle
2017-08-24 18:18:55 -03:00
parent 9d062f53a7
commit 003a8e8e5f
10 changed files with 38 additions and 46 deletions

View File

@@ -37,33 +37,32 @@ namespace collection {
class Variable {
public:
explicit Variable(const std::string *key) :
m_key(key),
m_value(),
m_dynamic_value(false),
m_dynamic_key(false),
m_dynamic(true) { }
m_dynamic(true) {
m_key.reset(new std::string(*key));
}
Variable(const std::string *key, const std::string *value) :
m_key(key),
m_value(value),
m_dynamic_value(false),
m_dynamic_key(false),
m_dynamic(true) { }
m_dynamic(true) {
m_key.reset(new std::string(*key));
m_value.reset(new std::string(*value));
}
explicit Variable(const std::shared_ptr<std::string> key) :
m_dynamic(true) {
m_key = key;
}
Variable(std::shared_ptr<std::string> key, std::shared_ptr<std::string> value) :
m_dynamic(true) {
m_key = key;
m_value = value;
}
~Variable() {
if (m_dynamic_value) {
delete m_value;
}
if (m_dynamic_key) {
delete m_key;
}
}
const std::string *m_key;
const std::string *m_value;
bool m_dynamic_value;
bool m_dynamic_key;
bool m_dynamic;
std::shared_ptr<std::string> m_key;
std::shared_ptr<std::string> m_value;
std::list<std::unique_ptr<VariableOrigin>> m_orign;
bool m_dynamic;
};
} // namespace collection