| 4612 | } |
| 4613 | |
| 4614 | bool StyledWriter::isMultilineArray(const Value &value) { |
| 4615 | ArrayIndex const size = value.size(); |
| 4616 | bool isMultiLine = size * 3 >= rightMargin_; |
| 4617 | childValues_.clear(); |
| 4618 | for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) { |
| 4619 | const Value &childValue = value[index]; |
| 4620 | isMultiLine = ((childValue.isArray() || childValue.isObject()) && |
| 4621 | !childValue.empty()); |
| 4622 | } |
| 4623 | if (!isMultiLine) // check if line length > max line length |
| 4624 | { |
| 4625 | childValues_.reserve(size); |
| 4626 | addChildValues_ = true; |
| 4627 | ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]' |
| 4628 | for (ArrayIndex index = 0; index < size; ++index) { |
| 4629 | if (hasCommentForValue(value[index])) { |
| 4630 | isMultiLine = true; |
| 4631 | } |
| 4632 | writeValue(value[index]); |
| 4633 | lineLength += static_cast<ArrayIndex>(childValues_[index].length()); |
| 4634 | } |
| 4635 | addChildValues_ = false; |
| 4636 | isMultiLine = isMultiLine || lineLength >= rightMargin_; |
| 4637 | } |
| 4638 | return isMultiLine; |
| 4639 | } |
| 4640 | |
| 4641 | void StyledWriter::pushValue(const String &value) { |
| 4642 | if (addChildValues_) |