| 3385 | } |
| 3386 | |
| 3387 | bool StyledWriter::isMultineArray(const Value& value) { |
| 3388 | int size = value.size(); |
| 3389 | bool isMultiLine = size * 3 >= rightMargin_; |
| 3390 | childValues_.clear(); |
| 3391 | for (int index = 0; index < size && !isMultiLine; ++index) { |
| 3392 | const Value& childValue = value[index]; |
| 3393 | isMultiLine = |
| 3394 | isMultiLine || ((childValue.isArray() || childValue.isObject()) && |
| 3395 | childValue.size() > 0); |
| 3396 | } |
| 3397 | if (!isMultiLine) // check if line length > max line length |
| 3398 | { |
| 3399 | childValues_.reserve(size); |
| 3400 | addChildValues_ = true; |
| 3401 | int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]' |
| 3402 | for (int index = 0; index < size; ++index) { |
| 3403 | writeValue(value[index]); |
| 3404 | lineLength += int(childValues_[index].length()); |
| 3405 | } |
| 3406 | addChildValues_ = false; |
| 3407 | isMultiLine = isMultiLine || lineLength >= rightMargin_; |
| 3408 | } |
| 3409 | return isMultiLine; |
| 3410 | } |
| 3411 | |
| 3412 | void StyledWriter::pushValue(const std::string& value) { |
| 3413 | if (addChildValues_) |