MCPcopy Create free account
hub / github.com/Icinga/icinga2 / ArrayMap

Function ArrayMap

lib/base/array-script.cpp:121–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121static Array::Ptr ArrayMap(const Function::Ptr& function)
122{
123 ScriptFrame *vframe = ScriptFrame::GetCurrentFrame();
124 Array::Ptr self = static_cast<Array::Ptr>(vframe->Self);
125 REQUIRE_NOT_NULL(self);
126 REQUIRE_NOT_NULL(function);
127
128 if (vframe->Sandboxed && !function->IsSideEffectFree())
129 BOOST_THROW_EXCEPTION(ScriptError("Map function must be side-effect free."));
130
131 ArrayData result;
132
133 ObjectLock olock(self);
134 for (const Value& item : self) {
135 result.push_back(function->Invoke({ item }));
136 }
137
138 return new Array(std::move(result));
139}
140
141static Value ArrayReduce(const Function::Ptr& function)
142{

Callers

nothing calls this directly

Calls 4

ScriptErrorClass · 0.85
IsSideEffectFreeMethod · 0.80
push_backMethod · 0.80
InvokeMethod · 0.45

Tested by

no test coverage detected