mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-21 20:54:35 +02:00
parent
173f5241c4
commit
fec8e15d9e
@ -417,6 +417,14 @@ Returns a copy of the array where all items are sorted. The items are
|
|||||||
compared using the `<` (less-than) operator. A custom comparator function
|
compared using the `<` (less-than) operator. A custom comparator function
|
||||||
can be specified with the `less_cmp` argument.
|
can be specified with the `less_cmp` argument.
|
||||||
|
|
||||||
|
### <a id="array-join"></a> Array#join
|
||||||
|
|
||||||
|
Signature:
|
||||||
|
|
||||||
|
function join(separator);
|
||||||
|
|
||||||
|
Joins all elements of the array using the specified separator.
|
||||||
|
|
||||||
## <a id="dictionary-type"></a> Dictionary type
|
## <a id="dictionary-type"></a> Dictionary type
|
||||||
|
|
||||||
### <a id="dictionary-clone"></a> Dictionary#clone
|
### <a id="dictionary-clone"></a> Dictionary#clone
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "base/functionwrapper.hpp"
|
#include "base/functionwrapper.hpp"
|
||||||
#include "base/scriptframe.hpp"
|
#include "base/scriptframe.hpp"
|
||||||
#include "base/objectlock.hpp"
|
#include "base/objectlock.hpp"
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
@ -100,6 +101,28 @@ static Array::Ptr ArrayClone(void)
|
|||||||
return self->ShallowClone();
|
return self->ShallowClone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Value ArrayJoin(const Value& separator)
|
||||||
|
{
|
||||||
|
ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
|
||||||
|
Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
|
||||||
|
|
||||||
|
Value result;
|
||||||
|
bool first = true;
|
||||||
|
|
||||||
|
ObjectLock olock(self);
|
||||||
|
BOOST_FOREACH(const Value& item, self) {
|
||||||
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
} else {
|
||||||
|
result = result + separator;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = result + item;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
Object::Ptr Array::GetPrototype(void)
|
Object::Ptr Array::GetPrototype(void)
|
||||||
{
|
{
|
||||||
static Dictionary::Ptr prototype;
|
static Dictionary::Ptr prototype;
|
||||||
@ -114,6 +137,7 @@ Object::Ptr Array::GetPrototype(void)
|
|||||||
prototype->Set("clear", new Function(WrapFunction(ArrayClear)));
|
prototype->Set("clear", new Function(WrapFunction(ArrayClear)));
|
||||||
prototype->Set("sort", new Function(WrapFunction(ArraySort)));
|
prototype->Set("sort", new Function(WrapFunction(ArraySort)));
|
||||||
prototype->Set("clone", new Function(WrapFunction(ArrayClone)));
|
prototype->Set("clone", new Function(WrapFunction(ArrayClone)));
|
||||||
|
prototype->Set("join", new Function(WrapFunction(ArrayJoin)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return prototype;
|
return prototype;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user