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

Method eraseKey

source/core/StarFormattedJson.cpp:304–317  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302}
303
304FormattedJson FormattedJson::eraseKey(String const& key) const {
305 if (type() != Json::Type::Object)
306 throw JsonException::format("Cannot call erase with key on FormattedJson type {}, must be Object type", typeName());
307
308 Maybe<pair<ElementLocation, ElementLocation>> maybeEntry = m_objectEntryLocations.maybe(key);
309 if (maybeEntry.isNothing())
310 return *this;
311
312 ElementLocation loc = maybeEntry->first;
313 ElementList elements = m_elements;
314 elements.eraseAt(loc, maybeEntry->second); // Remove key, colon and whitespace up to the value
315 removeValueFromArray(elements, loc);
316 return object(elements);
317}
318
319FormattedJson FormattedJson::insert(size_t index, FormattedJson const& value) const {
320 if (type() != Json::Type::Array)

Callers

nothing calls this directly

Calls 6

removeValueFromArrayFunction · 0.85
isNothingMethod · 0.80
eraseAtMethod · 0.80
formatFunction · 0.70
typeFunction · 0.50
maybeMethod · 0.45

Tested by

no test coverage detected