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

Function removeValueFromArray

source/core/StarFormattedJson.cpp:286–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286void removeValueFromArray(List<JsonElement>& elements, size_t loc) {
287 // Remove the value itself, the comma following and the whitespace up to the
288 // next value.
289 // If it's the last value, it removes the value, and the preceding whitespace
290 // and comma.
291 size_t commaLoc = elements.indexOf(CommaElement{}, loc);
292 if (commaLoc != NPos) {
293 elements.eraseAt(loc, commaLoc + 1);
294 while (loc < elements.size() && elements.at(loc).is<WhitespaceElement>())
295 elements.eraseAt(loc);
296 } else {
297 commaLoc = elements.lastIndexOf(CommaElement{}, loc);
298 if (commaLoc == NPos)
299 commaLoc = 0;
300 elements.eraseAt(commaLoc, loc + 1);
301 }
302}
303
304FormattedJson FormattedJson::eraseKey(String const& key) const {
305 if (type() != Json::Type::Object)

Callers 2

eraseKeyMethod · 0.85
eraseIndexMethod · 0.85

Calls 5

eraseAtMethod · 0.80
lastIndexOfMethod · 0.80
indexOfMethod · 0.45
sizeMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected