| 4644 | } |
| 4645 | |
| 4646 | bool StyledWriter::isMultilineArray(const Value& value) { |
| 4647 | ArrayIndex const size = value.size(); |
| 4648 | bool isMultiLine = size * 3 >= rightMargin_; |
| 4649 | childValues_.clear(); |
| 4650 | for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) { |
| 4651 | const Value& childValue = value[index]; |
| 4652 | isMultiLine = ((childValue.isArray() || childValue.isObject()) && |
| 4653 | !childValue.empty()); |
| 4654 | } |
| 4655 | if (!isMultiLine) // check if line length > max line length |
| 4656 | { |
| 4657 | childValues_.reserve(size); |
| 4658 | addChildValues_ = true; |
| 4659 | ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]' |
| 4660 | for (ArrayIndex index = 0; index < size; ++index) { |
| 4661 | if (hasCommentForValue(value[index])) { |
| 4662 | isMultiLine = true; |
| 4663 | } |
| 4664 | writeValue(value[index]); |
| 4665 | lineLength += static_cast<ArrayIndex>(childValues_[index].length()); |
| 4666 | } |
| 4667 | addChildValues_ = false; |
| 4668 | isMultiLine = isMultiLine || lineLength >= rightMargin_; |
| 4669 | } |
| 4670 | return isMultiLine; |
| 4671 | } |
| 4672 | |
| 4673 | void StyledWriter::pushValue(const String& value) { |
| 4674 | if (addChildValues_) |