mirror of https://github.com/Icinga/icinga2.git
parent
95a7473643
commit
29083ec22c
|
@ -633,6 +633,14 @@ Signature:
|
||||||
Retrieves the value for the specified `key`. Returns `null` if they `key` does not exist
|
Retrieves the value for the specified `key`. Returns `null` if they `key` does not exist
|
||||||
in the dictionary.
|
in the dictionary.
|
||||||
|
|
||||||
|
### <a id="dictionary-keys"></a> Dictionary#keys
|
||||||
|
|
||||||
|
Signature:
|
||||||
|
|
||||||
|
function keys();
|
||||||
|
|
||||||
|
Returns a list of keys for all items that are currently in the dictionary.
|
||||||
|
|
||||||
## <a id="scriptfunction-type"></a> Function type
|
## <a id="scriptfunction-type"></a> Function type
|
||||||
|
|
||||||
### <a id="scriptfunction-call"></a> Function#call
|
### <a id="scriptfunction-call"></a> Function#call
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
#include "base/function.hpp"
|
#include "base/function.hpp"
|
||||||
#include "base/functionwrapper.hpp"
|
#include "base/functionwrapper.hpp"
|
||||||
#include "base/scriptframe.hpp"
|
#include "base/scriptframe.hpp"
|
||||||
|
#include "base/array.hpp"
|
||||||
|
#include "base/objectlock.hpp"
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
|
@ -66,6 +69,18 @@ static Dictionary::Ptr DictionaryClone(void)
|
||||||
return self->ShallowClone();
|
return self->ShallowClone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Array::Ptr DictionaryKeys(void)
|
||||||
|
{
|
||||||
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
|
Dictionary::Ptr self = static_cast<Dictionary::Ptr>(vframe->Self);
|
||||||
|
Array::Ptr keys = new Array();
|
||||||
|
ObjectLock olock(self);
|
||||||
|
BOOST_FOREACH(const Dictionary::Pair& kv, self) {
|
||||||
|
keys->Add(kv.first);
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
Object::Ptr Dictionary::GetPrototype(void)
|
Object::Ptr Dictionary::GetPrototype(void)
|
||||||
{
|
{
|
||||||
static Dictionary::Ptr prototype;
|
static Dictionary::Ptr prototype;
|
||||||
|
@ -78,6 +93,7 @@ Object::Ptr Dictionary::GetPrototype(void)
|
||||||
prototype->Set("remove", new Function(WrapFunction(DictionaryRemove)));
|
prototype->Set("remove", new Function(WrapFunction(DictionaryRemove)));
|
||||||
prototype->Set("contains", new Function(WrapFunction(DictionaryContains)));
|
prototype->Set("contains", new Function(WrapFunction(DictionaryContains)));
|
||||||
prototype->Set("clone", new Function(WrapFunction(DictionaryClone)));
|
prototype->Set("clone", new Function(WrapFunction(DictionaryClone)));
|
||||||
|
prototype->Set("keys", new Function(WrapFunction(DictionaryKeys)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return prototype;
|
return prototype;
|
||||||
|
|
Loading…
Reference in New Issue