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