| 349 | |
| 350 | |
| 351 | void |
| 352 | StyledWriter::writeArrayValue( const Value &value ) |
| 353 | { |
| 354 | unsigned size = value.size(); |
| 355 | if ( size == 0 ) |
| 356 | pushValue( "[]" ); |
| 357 | else |
| 358 | { |
| 359 | bool isArrayMultiLine = isMultineArray( value ); |
| 360 | if ( isArrayMultiLine ) |
| 361 | { |
| 362 | writeWithIndent( "[" ); |
| 363 | indent(); |
| 364 | bool hasChildValue = !childValues_.empty(); |
| 365 | unsigned index =0; |
| 366 | while ( true ) |
| 367 | { |
| 368 | const Value &childValue = value[index]; |
| 369 | writeCommentBeforeValue( childValue ); |
| 370 | if ( hasChildValue ) |
| 371 | writeWithIndent( childValues_[index] ); |
| 372 | else |
| 373 | { |
| 374 | writeIndent(); |
| 375 | writeValue( childValue ); |
| 376 | } |
| 377 | if ( ++index == size ) |
| 378 | { |
| 379 | writeCommentAfterValueOnSameLine( childValue ); |
| 380 | break; |
| 381 | } |
| 382 | document_ += ","; |
| 383 | writeCommentAfterValueOnSameLine( childValue ); |
| 384 | } |
| 385 | unindent(); |
| 386 | writeWithIndent( "]" ); |
| 387 | } |
| 388 | else // output on a single line |
| 389 | { |
| 390 | assert( childValues_.size() == size ); |
| 391 | document_ += "[ "; |
| 392 | for ( unsigned index =0; index < size; ++index ) |
| 393 | { |
| 394 | if ( index > 0 ) |
| 395 | document_ += ", "; |
| 396 | document_ += childValues_[index]; |
| 397 | } |
| 398 | document_ += " ]"; |
| 399 | } |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | |
| 404 | bool |