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

Method GetFieldByName

lib/base/array.cpp:353–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351}
352
353Value Array::GetFieldByName(const String& field, bool sandboxed, const DebugInfo& debugInfo) const
354{
355 int index;
356
357 try {
358 index = Convert::ToLong(field);
359 } catch (...) {
360 return Object::GetFieldByName(field, sandboxed, debugInfo);
361 }
362
363 ObjectLock olock(this);
364
365 if (index < 0 || static_cast<size_t>(index) >= GetLength())
366 BOOST_THROW_EXCEPTION(ScriptError("Array index '" + Convert::ToString(index) + "' is out of bounds.", debugInfo));
367
368 return Get(index);
369}
370
371void Array::SetFieldByName(const String& field, const Value& value, const DebugInfo& debugInfo)
372{

Callers 2

GetMethod · 0.45
GetFieldMethod · 0.45

Calls 1

ScriptErrorClass · 0.85

Tested by

no test coverage detected