MCPcopy Create free account
hub / github.com/ComodoSecurity/openedr / writeArrayValue

Method writeArrayValue

edrav2/eprj/jsoncpp/src/lib_json/json_writer.cpp:504–545  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

502}
503
504void StyledWriter::writeArrayValue(const Value& value) {
505 unsigned size = value.size();
506 if (size == 0)
507 pushValue("[]");
508 else {
509 bool isArrayMultiLine = isMultilineArray(value);
510 if (isArrayMultiLine) {
511 writeWithIndent("[");
512 indent();
513 bool hasChildValue = !childValues_.empty();
514 unsigned index = 0;
515 for (;;) {
516 const Value& childValue = value[index];
517 writeCommentBeforeValue(childValue);
518 if (hasChildValue)
519 writeWithIndent(childValues_[index]);
520 else {
521 writeIndent();
522 writeValue(childValue);
523 }
524 if (++index == size) {
525 writeCommentAfterValueOnSameLine(childValue);
526 break;
527 }
528 document_ += ',';
529 writeCommentAfterValueOnSameLine(childValue);
530 }
531 unindent();
532 writeWithIndent("]");
533 } else // output on a single line
534 {
535 assert(childValues_.size() == size);
536 document_ += "[ ";
537 for (unsigned index = 0; index < size; ++index) {
538 if (index > 0)
539 document_ += ", ";
540 document_ += childValues_[index];
541 }
542 document_ += " ]";
543 }
544 }
545}
546
547bool StyledWriter::isMultilineArray(const Value& value) {
548 ArrayIndex const size = value.size();

Callers

nothing calls this directly

Calls 4

indentFunction · 0.85
assertClass · 0.50
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected