MCPcopy Create free account
hub / github.com/Kitware/VTK / writeArrayValue

Method writeArrayValue

ThirdParty/jsoncpp/vtkjsoncpp/jsoncpp.cpp:4603–4644  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4601}
4602
4603void StyledWriter::writeArrayValue(const Value& value) {
4604 size_t size = value.size();
4605 if (size == 0)
4606 pushValue("[]");
4607 else {
4608 bool isArrayMultiLine = isMultilineArray(value);
4609 if (isArrayMultiLine) {
4610 writeWithIndent("[");
4611 indent();
4612 bool hasChildValue = !childValues_.empty();
4613 ArrayIndex index = 0;
4614 for (;;) {
4615 const Value& childValue = value[index];
4616 writeCommentBeforeValue(childValue);
4617 if (hasChildValue)
4618 writeWithIndent(childValues_[index]);
4619 else {
4620 writeIndent();
4621 writeValue(childValue);
4622 }
4623 if (++index == size) {
4624 writeCommentAfterValueOnSameLine(childValue);
4625 break;
4626 }
4627 document_ += ',';
4628 writeCommentAfterValueOnSameLine(childValue);
4629 }
4630 unindent();
4631 writeWithIndent("]");
4632 } else // output on a single line
4633 {
4634 assert(childValues_.size() == size);
4635 document_ += "[ ";
4636 for (size_t index = 0; index < size; ++index) {
4637 if (index > 0)
4638 document_ += ", ";
4639 document_ += childValues_[index];
4640 }
4641 document_ += " ]";
4642 }
4643 }
4644}
4645
4646bool StyledWriter::isMultilineArray(const Value& value) {
4647 ArrayIndex const size = value.size();

Callers

nothing calls this directly

Calls 4

indentFunction · 0.85
assertFunction · 0.50
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected