| 4669 | } |
| 4670 | |
| 4671 | bool StyledWriter::isMultilineArray(const Value& value) { |
| 4672 | ArrayIndex const size = value.size(); |
| 4673 | bool isMultiLine = size * 3 >= rightMargin_; |
| 4674 | childValues_.clear(); |
| 4675 | for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) { |
| 4676 | const Value& childValue = value[index]; |
| 4677 | isMultiLine = ((childValue.isArray() || childValue.isObject()) && |
| 4678 | childValue.size() > 0); |
| 4679 | } |
| 4680 | if (!isMultiLine) // check if line length > max line length |
| 4681 | { |
| 4682 | childValues_.reserve(size); |
| 4683 | addChildValues_ = true; |
| 4684 | ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]' |
| 4685 | for (ArrayIndex index = 0; index < size; ++index) { |
| 4686 | if (hasCommentForValue(value[index])) { |
| 4687 | isMultiLine = true; |
| 4688 | } |
| 4689 | writeValue(value[index]); |
| 4690 | lineLength += static_cast<ArrayIndex>(childValues_[index].length()); |
| 4691 | } |
| 4692 | addChildValues_ = false; |
| 4693 | isMultiLine = isMultiLine || lineLength >= rightMargin_; |
| 4694 | } |
| 4695 | return isMultiLine; |
| 4696 | } |
| 4697 | |
| 4698 | void StyledWriter::pushValue(const JSONCPP_STRING& value) { |
| 4699 | if (addChildValues_) |