| 556 | } |
| 557 | |
| 558 | bool StyledWriter::isMultilineArray(const Value& value) { |
| 559 | ArrayIndex const size = value.size(); |
| 560 | bool isMultiLine = size * 3 >= rightMargin_; |
| 561 | childValues_.clear(); |
| 562 | for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) { |
| 563 | const Value& childValue = value[index]; |
| 564 | isMultiLine = ((childValue.isArray() || childValue.isObject()) && |
| 565 | !childValue.empty()); |
| 566 | } |
| 567 | if (!isMultiLine) // check if line length > max line length |
| 568 | { |
| 569 | childValues_.reserve(size); |
| 570 | addChildValues_ = true; |
| 571 | ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]' |
| 572 | for (ArrayIndex index = 0; index < size; ++index) { |
| 573 | if (hasCommentForValue(value[index])) { |
| 574 | isMultiLine = true; |
| 575 | } |
| 576 | writeValue(value[index]); |
| 577 | lineLength += static_cast<ArrayIndex>(childValues_[index].length()); |
| 578 | } |
| 579 | addChildValues_ = false; |
| 580 | isMultiLine = isMultiLine || lineLength >= rightMargin_; |
| 581 | } |
| 582 | return isMultiLine; |
| 583 | } |
| 584 | |
| 585 | void StyledWriter::pushValue(const String& value) { |
| 586 | if (addChildValues_) |