mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 07:34:15 +02:00
parent
b78a8b6c77
commit
978aeed741
@ -46,6 +46,7 @@ REGISTER_SCRIPTFUNCTION(typeof, &ScriptUtils::TypeOf);
|
|||||||
REGISTER_SCRIPTFUNCTION(keys, &ScriptUtils::Keys);
|
REGISTER_SCRIPTFUNCTION(keys, &ScriptUtils::Keys);
|
||||||
REGISTER_SCRIPTFUNCTION(random, &Utility::Random);
|
REGISTER_SCRIPTFUNCTION(random, &Utility::Random);
|
||||||
REGISTER_SCRIPTFUNCTION(__get_object, &ScriptUtils::GetObject);
|
REGISTER_SCRIPTFUNCTION(__get_object, &ScriptUtils::GetObject);
|
||||||
|
REGISTER_SCRIPTFUNCTION(__get_objects, &ScriptUtils::GetObjects);
|
||||||
REGISTER_SCRIPTFUNCTION(assert, &ScriptUtils::Assert);
|
REGISTER_SCRIPTFUNCTION(assert, &ScriptUtils::Assert);
|
||||||
REGISTER_SCRIPTFUNCTION(string, &ScriptUtils::CastString);
|
REGISTER_SCRIPTFUNCTION(string, &ScriptUtils::CastString);
|
||||||
REGISTER_SCRIPTFUNCTION(number, &ScriptUtils::CastNumber);
|
REGISTER_SCRIPTFUNCTION(number, &ScriptUtils::CastNumber);
|
||||||
@ -253,6 +254,21 @@ DynamicObject::Ptr ScriptUtils::GetObject(const String& type, const String& name
|
|||||||
return dtype->GetObject(name);
|
return dtype->GetObject(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Array::Ptr ScriptUtils::GetObjects(const String& type)
|
||||||
|
{
|
||||||
|
DynamicType::Ptr dtype = DynamicType::GetByName(type);
|
||||||
|
|
||||||
|
if (!dtype)
|
||||||
|
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid type name"));
|
||||||
|
|
||||||
|
Array::Ptr result = new Array();
|
||||||
|
|
||||||
|
BOOST_FOREACH(const DynamicObject::Ptr& object, dtype->GetObjects())
|
||||||
|
result->Add(object);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptUtils::Assert(const Value& arg)
|
void ScriptUtils::Assert(const Value& arg)
|
||||||
{
|
{
|
||||||
if (!arg.ToBool())
|
if (!arg.ToBool())
|
||||||
|
@ -48,6 +48,7 @@ public:
|
|||||||
static Type::Ptr TypeOf(const Value& value);
|
static Type::Ptr TypeOf(const Value& value);
|
||||||
static Array::Ptr Keys(const Dictionary::Ptr& dict);
|
static Array::Ptr Keys(const Dictionary::Ptr& dict);
|
||||||
static DynamicObject::Ptr GetObject(const String& type, const String& name);
|
static DynamicObject::Ptr GetObject(const String& type, const String& name);
|
||||||
|
static Array::Ptr GetObjects(const String& type);
|
||||||
static void Assert(const Value& arg);
|
static void Assert(const Value& arg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user