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

Method appendElement

source/core/StarFormattedJson.cpp:471–497  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

469}
470
471void FormattedJson::appendElement(JsonElement const& elem) {
472 ElementLocation loc = m_elements.size();
473 m_elements.append(elem);
474
475 if (elem.is<ObjectKeyElement>()) {
476 starAssert(isType(Json::Type::Object));
477 m_lastKey = loc;
478
479 } else if (elem.is<ValueElement>()) {
480 m_lastValue = loc;
481
482 if (m_lastKey.isValid()) {
483 starAssert(isType(Json::Type::Object));
484 String key = m_elements[*m_lastKey].get<ObjectKeyElement>().key;
485
486 m_objectEntryLocations[key] = make_pair(*m_lastKey, loc);
487 m_jsonValue = m_jsonValue.set(key, elemToJson(elem));
488
489 m_lastKey = {};
490 } else {
491 starAssert(isType(Json::Type::Array));
492 m_arrayElementLocations.append(loc);
493
494 m_jsonValue = m_jsonValue.append(elemToJson(elem));
495 }
496 }
497}
498
499FormattedJson const& FormattedJson::getFormattedJson(ElementLocation loc) const {
500 return *m_elements[loc].get<ValueElement>().value;

Callers 9

objectMethod · 0.80
arrayMethod · 0.80
objectKeyMethod · 0.80
endObjectMethod · 0.80
endArrayMethod · 0.80
putWhitespaceMethod · 0.80
putColonMethod · 0.80
putCommaMethod · 0.80
putValueMethod · 0.80

Calls 5

elemToJsonFunction · 0.85
isValidMethod · 0.80
sizeMethod · 0.45
appendMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected