| 4549 | } |
| 4550 | |
| 4551 | bool StyledWriter::isMultineArray(const Value& value) { |
| 4552 | int size = value.size(); |
| 4553 | bool isMultiLine = size * 3 >= rightMargin_; |
| 4554 | childValues_.clear(); |
| 4555 | for (int index = 0; index < size && !isMultiLine; ++index) { |
| 4556 | const Value& childValue = value[index]; |
| 4557 | isMultiLine = ((childValue.isArray() || childValue.isObject()) && |
| 4558 | childValue.size() > 0); |
| 4559 | } |
| 4560 | if (!isMultiLine) // check if line length > max line length |
| 4561 | { |
| 4562 | childValues_.reserve(size); |
| 4563 | addChildValues_ = true; |
| 4564 | int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]' |
| 4565 | for (int index = 0; index < size; ++index) { |
| 4566 | if (hasCommentForValue(value[index])) { |
| 4567 | isMultiLine = true; |
| 4568 | } |
| 4569 | writeValue(value[index]); |
| 4570 | lineLength += int(childValues_[index].length()); |
| 4571 | } |
| 4572 | addChildValues_ = false; |
| 4573 | isMultiLine = isMultiLine || lineLength >= rightMargin_; |
| 4574 | } |
| 4575 | return isMultiLine; |
| 4576 | } |
| 4577 | |
| 4578 | void StyledWriter::pushValue(const std::string& value) { |
| 4579 | if (addChildValues_) |