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

Method isMultilineArray

Sources/Dependencies/jsoncpp/writer.cpp:526–549  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

524 }
525
526 bool BuiltStyledStreamWriter::isMultilineArray(Value const& value) {
527 ArrayIndex const size = value.size();
528 bool isMultiLine = size * 3 >= rightMargin_;
529 childValues_.clear();
530 for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) {
531 Value const& childValue = value[index];
532 isMultiLine = ((childValue.isArray() || childValue.isObject()) && !childValue.empty());
533 }
534 if (!isMultiLine) { // check if line length > max line length
535 childValues_.reserve(size);
536 addChildValues_ = true;
537 ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]'
538 for (ArrayIndex index = 0; index < size; ++index) {
539 if (hasCommentForValue(value[index])) {
540 isMultiLine = true;
541 }
542 writeValue(value[index]);
543 lineLength += static_cast<ArrayIndex>(childValues_[index].length());
544 }
545 addChildValues_ = false;
546 isMultiLine = isMultiLine || lineLength >= rightMargin_;
547 }
548 return isMultiLine;
549 }
550
551 void BuiltStyledStreamWriter::pushValue(StringContainer const& value) {
552 if (addChildValues_) {

Callers

nothing calls this directly

Calls 7

isArrayMethod · 0.80
isObjectMethod · 0.80
sizeMethod · 0.45
clearMethod · 0.45
emptyMethod · 0.45
reserveMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected