mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-25 22:54:57 +02:00
parent
520be9513b
commit
162e31b083
@ -159,11 +159,9 @@ void ConfigObject::ModifyAttribute(const String& attr, const Value& value, bool
|
|||||||
const String& key = tokens[i];
|
const String& key = tokens[i];
|
||||||
prefix += "." + key;
|
prefix += "." + key;
|
||||||
|
|
||||||
if (!dict->Contains(key)) {
|
if (!dict->Get(key, ¤t)) {
|
||||||
current = new Dictionary();
|
current = new Dictionary();
|
||||||
dict->Set(key, current);
|
dict->Set(key, current);
|
||||||
} else {
|
|
||||||
current = dict->Get(key);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,14 +36,16 @@ Dictionary::Ptr ScriptGlobal::m_Globals = new Dictionary();
|
|||||||
|
|
||||||
Value ScriptGlobal::Get(const String& name, const Value *defaultValue)
|
Value ScriptGlobal::Get(const String& name, const Value *defaultValue)
|
||||||
{
|
{
|
||||||
if (!m_Globals->Contains(name)) {
|
Value result;
|
||||||
|
|
||||||
|
if (!m_Globals->Get(name, &result)) {
|
||||||
if (defaultValue)
|
if (defaultValue)
|
||||||
return *defaultValue;
|
return *defaultValue;
|
||||||
|
|
||||||
BOOST_THROW_EXCEPTION(std::invalid_argument("Tried to access undefined script variable '" + name + "'"));
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Tried to access undefined script variable '" + name + "'"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_Globals->Get(name);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptGlobal::Set(const String& name, const Value& value)
|
void ScriptGlobal::Set(const String& name, const Value& value)
|
||||||
@ -63,12 +65,14 @@ void ScriptGlobal::Set(const String& name, const Value& value)
|
|||||||
const String& token = tokens[i];
|
const String& token = tokens[i];
|
||||||
|
|
||||||
if (i + 1 != tokens.size()) {
|
if (i + 1 != tokens.size()) {
|
||||||
if (!parent->Contains(token)) {
|
Value vparent;
|
||||||
|
|
||||||
|
if (!parent->Get(token, &vparent)) {
|
||||||
Dictionary::Ptr dict = new Dictionary();
|
Dictionary::Ptr dict = new Dictionary();
|
||||||
parent->Set(token, dict);
|
parent->Set(token, dict);
|
||||||
parent = dict;
|
parent = dict;
|
||||||
} else {
|
} else {
|
||||||
parent = parent->Get(token);
|
parent = vparent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user