MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / insert

Method insert

source/core/StarFormattedJson.cpp:319–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

317}
318
319FormattedJson FormattedJson::insert(size_t index, FormattedJson const& value) const {
320 if (type() != Json::Type::Array)
321 throw JsonException::format(
322 "Cannot call insert with index on FormattedJson type {}, must be Array type", typeName());
323
324 if (index > m_arrayElementLocations.size())
325 throw JsonException::format("FormattedJson::insert({}) out of range", index);
326
327 ElementList elements = m_elements;
328 ElementLocation insertPosition = elements.size();
329 if (index < m_arrayElementLocations.size())
330 insertPosition = m_arrayElementLocations.at(index);
331
332 insertWithCommaAndFormatting(elements, insertPosition, true, {ValueElement{value}});
333 return array(elements);
334}
335
336FormattedJson FormattedJson::append(FormattedJson const& value) const {
337 if (type() != Json::Type::Array)

Callers

nothing calls this directly

Calls 5

formatFunction · 0.70
typeFunction · 0.50
sizeMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected