MCPcopy Create free account
hub / github.com/SOUI2/soui / writeArrayValue

Method writeArrayValue

third-part/jsoncpp/src/lib_json/json_writer.cpp:484–525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

482}
483
484void StyledWriter::writeArrayValue(const Value& value) {
485 unsigned size = value.size();
486 if (size == 0)
487 pushValue("[]");
488 else {
489 bool isArrayMultiLine = isMultilineArray(value);
490 if (isArrayMultiLine) {
491 writeWithIndent("[");
492 indent();
493 bool hasChildValue = !childValues_.empty();
494 unsigned index = 0;
495 for (;;) {
496 const Value& childValue = value[index];
497 writeCommentBeforeValue(childValue);
498 if (hasChildValue)
499 writeWithIndent(childValues_[index]);
500 else {
501 writeIndent();
502 writeValue(childValue);
503 }
504 if (++index == size) {
505 writeCommentAfterValueOnSameLine(childValue);
506 break;
507 }
508 document_ += ',';
509 writeCommentAfterValueOnSameLine(childValue);
510 }
511 unindent();
512 writeWithIndent("]");
513 } else // output on a single line
514 {
515 assert(childValues_.size() == size);
516 document_ += "[ ";
517 for (unsigned index = 0; index < size; ++index) {
518 if (index > 0)
519 document_ += ", ";
520 document_ += childValues_[index];
521 }
522 document_ += " ]";
523 }
524 }
525}
526
527bool StyledWriter::isMultilineArray(const Value& value) {
528 ArrayIndex const size = value.size();

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected