MCPcopy Create free account
hub / github.com/cuberite/cuberite / writeArrayValue

Method writeArrayValue

lib/jsoncpp/src/lib_json/json_writer.cpp:351–401  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349
350
351void
352StyledWriter::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
404bool

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.80
emptyMethod · 0.80

Tested by

no test coverage detected