MCPcopy Create free account
hub / github.com/Illumina/hap.py / writeArrayValue

Method writeArrayValue

external/jsoncpp/jsoncpp.cpp:3363–3404  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3361}
3362
3363void StyledWriter::writeArrayValue(const Value &value) {
3364 unsigned size = value.size();
3365 if (size == 0)
3366 pushValue("[]");
3367 else {
3368 bool isArrayMultiLine = isMultineArray(value);
3369 if (isArrayMultiLine) {
3370 writeWithIndent("[");
3371 indent();
3372 bool hasChildValue = !childValues_.empty();
3373 unsigned index = 0;
3374 for (;;) {
3375 const Value &childValue = value[index];
3376 writeCommentBeforeValue(childValue);
3377 if (hasChildValue)
3378 writeWithIndent(childValues_[index]);
3379 else {
3380 writeIndent();
3381 writeValue(childValue);
3382 }
3383 if (++index == size) {
3384 writeCommentAfterValueOnSameLine(childValue);
3385 break;
3386 }
3387 document_ += ",";
3388 writeCommentAfterValueOnSameLine(childValue);
3389 }
3390 unindent();
3391 writeWithIndent("]");
3392 } else // output on a single line
3393 {
3394 assert(childValues_.size() == size);
3395 document_ += "[ ";
3396 for (unsigned index = 0; index < size; ++index) {
3397 if (index > 0)
3398 document_ += ", ";
3399 document_ += childValues_[index];
3400 }
3401 document_ += " ]";
3402 }
3403 }
3404}
3405
3406bool StyledWriter::isMultineArray(const Value &value) {
3407 int size = value.size();

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.80
emptyMethod · 0.80

Tested by

no test coverage detected