MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / writeArrayValue

Method writeArrayValue

Sources/Dependencies/jsoncpp/writer.cpp:477–524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475 }
476
477 void BuiltStyledStreamWriter::writeArrayValue(Value const& value) {
478 unsigned size = value.size();
479 if (size == 0)
480 pushValue("[]");
481 else {
482 bool isMultiLine = (cs_ == CommentStyle::All) || isMultilineArray(value);
483 if (isMultiLine) {
484 writeWithIndent("[");
485 indent();
486 bool hasChildValue = !childValues_.empty();
487 unsigned index = 0;
488 for (;;) {
489 Value const& childValue = value[index];
490 writeCommentBeforeValue(childValue);
491 if (hasChildValue)
492 writeWithIndent(childValues_[index]);
493 else {
494 if (!indented_)
495 writeIndent();
496 indented_ = true;
497 writeValue(childValue);
498 indented_ = false;
499 }
500 if (++index == size) {
501 writeCommentAfterValueOnSameLine(childValue);
502 break;
503 }
504 *sout_ << ",";
505 writeCommentAfterValueOnSameLine(childValue);
506 }
507 unindent();
508 writeWithIndent("]");
509 } else { // output on a single line
510 assert(childValues_.size() == size);
511 *sout_ << "[";
512 if (!indentation_.empty())
513 *sout_ << " ";
514 for (unsigned index = 0; index < size; ++index) {
515 if (index > 0)
516 *sout_ << ((!indentation_.empty()) ? ", " : ",");
517 *sout_ << childValues_[index];
518 }
519 if (!indentation_.empty())
520 *sout_ << " ";
521 *sout_ << "]";
522 }
523 }
524 }
525
526 bool BuiltStyledStreamWriter::isMultilineArray(Value const& value) {
527 ArrayIndex const size = value.size();

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected