| 3404 | } |
| 3405 | |
| 3406 | bool StyledWriter::isMultineArray(const Value &value) { |
| 3407 | int size = value.size(); |
| 3408 | bool isMultiLine = size * 3 >= rightMargin_; |
| 3409 | childValues_.clear(); |
| 3410 | for (int index = 0; index < size && !isMultiLine; ++index) { |
| 3411 | const Value &childValue = value[index]; |
| 3412 | isMultiLine = |
| 3413 | isMultiLine || ((childValue.isArray() || childValue.isObject()) && |
| 3414 | childValue.size() > 0); |
| 3415 | } |
| 3416 | if (!isMultiLine) // check if line length > max line length |
| 3417 | { |
| 3418 | childValues_.reserve(size); |
| 3419 | addChildValues_ = true; |
| 3420 | int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]' |
| 3421 | for (int index = 0; index < size; ++index) { |
| 3422 | writeValue(value[index]); |
| 3423 | lineLength += int(childValues_[index].length()); |
| 3424 | } |
| 3425 | addChildValues_ = false; |
| 3426 | isMultiLine = isMultiLine || lineLength >= rightMargin_; |
| 3427 | } |
| 3428 | return isMultiLine; |
| 3429 | } |
| 3430 | |
| 3431 | void StyledWriter::pushValue(const std::string &value) { |
| 3432 | if (addChildValues_) |