| 4594 | } |
| 4595 | |
| 4596 | bool StyledWriter::isMultineArray(const Value& value) { |
| 4597 | ArrayIndex const size = value.size(); |
| 4598 | bool isMultiLine = size * 3 >= rightMargin_; |
| 4599 | childValues_.clear(); |
| 4600 | for (ArrayIndex index = 0; index < size && !isMultiLine; ++index) { |
| 4601 | const Value& childValue = value[index]; |
| 4602 | isMultiLine = ((childValue.isArray() || childValue.isObject()) && |
| 4603 | childValue.size() > 0); |
| 4604 | } |
| 4605 | if (!isMultiLine) // check if line length > max line length |
| 4606 | { |
| 4607 | childValues_.reserve(size); |
| 4608 | addChildValues_ = true; |
| 4609 | ArrayIndex lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]' |
| 4610 | for (ArrayIndex index = 0; index < size; ++index) { |
| 4611 | if (hasCommentForValue(value[index])) { |
| 4612 | isMultiLine = true; |
| 4613 | } |
| 4614 | writeValue(value[index]); |
| 4615 | lineLength += static_cast<ArrayIndex>(childValues_[index].length()); |
| 4616 | } |
| 4617 | addChildValues_ = false; |
| 4618 | isMultiLine = isMultiLine || lineLength >= rightMargin_; |
| 4619 | } |
| 4620 | return isMultiLine; |
| 4621 | } |
| 4622 | |
| 4623 | void StyledWriter::pushValue(const JSONCPP_STRING& value) { |
| 4624 | if (addChildValues_) |