| 4720 | } |
| 4721 | |
| 4722 | bool StyledWriter::isMultilineArray(const Value& value) { |
| 4723 | ArrayIndex const size = value.size(); |
| 4724 | bool isMultiLine = size * 3 >= rightMargin_; |
| 4725 | childValues_.clear(); |
| 4726 | for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) { |
| 4727 | const Value& childValue = value[index]; |
| 4728 | isMultiLine = ((childValue.isArray() || childValue.isObject()) && |
| 4729 | childValue.size() > 0); |
| 4730 | } |
| 4731 | if (!isMultiLine) // check if line length > max line length |
| 4732 | { |
| 4733 | childValues_.reserve(size); |
| 4734 | addChildValues_ = true; |
| 4735 | ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]' |
| 4736 | for (ArrayIndex index = 0; index < size; ++index) { |
| 4737 | if (hasCommentForValue(value[index])) { |
| 4738 | isMultiLine = true; |
| 4739 | } |
| 4740 | writeValue(value[index]); |
| 4741 | lineLength += static_cast<ArrayIndex>(childValues_[index].length()); |
| 4742 | } |
| 4743 | addChildValues_ = false; |
| 4744 | isMultiLine = isMultiLine || lineLength >= rightMargin_; |
| 4745 | } |
| 4746 | return isMultiLine; |
| 4747 | } |
| 4748 | |
| 4749 | void StyledWriter::pushValue(const JSONCPP_STRING& value) { |
| 4750 | if (addChildValues_) |