MCPcopy Create free account
hub / github.com/Illumina/paragraph / writeArrayValue

Method writeArrayValue

external/jsoncpp/jsoncpp.cpp:4628–4669  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4626}
4627
4628void StyledWriter::writeArrayValue(const Value& value) {
4629 unsigned size = value.size();
4630 if (size == 0)
4631 pushValue("[]");
4632 else {
4633 bool isArrayMultiLine = isMultilineArray(value);
4634 if (isArrayMultiLine) {
4635 writeWithIndent("[");
4636 indent();
4637 bool hasChildValue = !childValues_.empty();
4638 unsigned index = 0;
4639 for (;;) {
4640 const Value& childValue = value[index];
4641 writeCommentBeforeValue(childValue);
4642 if (hasChildValue)
4643 writeWithIndent(childValues_[index]);
4644 else {
4645 writeIndent();
4646 writeValue(childValue);
4647 }
4648 if (++index == size) {
4649 writeCommentAfterValueOnSameLine(childValue);
4650 break;
4651 }
4652 document_ += ',';
4653 writeCommentAfterValueOnSameLine(childValue);
4654 }
4655 unindent();
4656 writeWithIndent("]");
4657 } else // output on a single line
4658 {
4659 assert(childValues_.size() == size);
4660 document_ += "[ ";
4661 for (unsigned index = 0; index < size; ++index) {
4662 if (index > 0)
4663 document_ += ", ";
4664 document_ += childValues_[index];
4665 }
4666 document_ += " ]";
4667 }
4668 }
4669}
4670
4671bool StyledWriter::isMultilineArray(const Value& value) {
4672 ArrayIndex const size = value.size();

Callers

nothing calls this directly

Calls 2

emptyMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected