| 4958 | } |
| 4959 | |
| 4960 | void StyledWriter::writeArrayValue(const Value &value) |
| 4961 | { |
| 4962 | size_t size = value.size(); |
| 4963 | if (size == 0) |
| 4964 | pushValue("[]"); |
| 4965 | else |
| 4966 | { |
| 4967 | bool isArrayMultiLine = isMultilineArray(value); |
| 4968 | if (isArrayMultiLine) |
| 4969 | { |
| 4970 | writeWithIndent("["); |
| 4971 | indent(); |
| 4972 | bool hasChildValue = !childValues_.empty(); |
| 4973 | ArrayIndex index = 0; |
| 4974 | for (;;) |
| 4975 | { |
| 4976 | const Value &childValue = value[index]; |
| 4977 | writeCommentBeforeValue(childValue); |
| 4978 | if (hasChildValue) |
| 4979 | writeWithIndent(childValues_[index]); |
| 4980 | else |
| 4981 | { |
| 4982 | writeIndent(); |
| 4983 | writeValue(childValue); |
| 4984 | } |
| 4985 | if (++index == size) |
| 4986 | { |
| 4987 | writeCommentAfterValueOnSameLine(childValue); |
| 4988 | break; |
| 4989 | } |
| 4990 | document_ += ','; |
| 4991 | writeCommentAfterValueOnSameLine(childValue); |
| 4992 | } |
| 4993 | unindent(); |
| 4994 | writeWithIndent("]"); |
| 4995 | } |
| 4996 | else // output on a single line |
| 4997 | { |
| 4998 | assert(childValues_.size() == size); |
| 4999 | document_ += "[ "; |
| 5000 | for (size_t index = 0; index < size; ++index) |
| 5001 | { |
| 5002 | if (index > 0) |
| 5003 | document_ += ", "; |
| 5004 | document_ += childValues_[index]; |
| 5005 | } |
| 5006 | document_ += " ]"; |
| 5007 | } |
| 5008 | } |
| 5009 | } |
| 5010 | |
| 5011 | bool StyledWriter::isMultilineArray(const Value &value) |
| 5012 | { |