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