MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / writeValue

Method writeValue

Sources/Dependencies/jsoncpp/writer.cpp:375–475  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

373 return 0;
374 }
375 void BuiltStyledStreamWriter::writeValue(Value const& value) {
376 switch (value.type()) {
377 case nullValue:
378 pushValue("null");
379 break;
380 case intValue:
381 pushValue(valueToString(value.asLargestInt()));
382 break;
383 case uintValue:
384 pushValue(valueToString(value.asLargestUInt()));
385 break;
386 case realValue:
387 pushValue(valueToString(value.asDouble(), useSpecialFloats_, precision_,
388 precisionType_));
389 break;
390 case stringValue: {
391 char const* str; char const* end;
392 bool ok = value.getString(&str, &end);
393 if (ok)
394 pushValue(valueToQuotedStringN(str, static_cast<size_t>(end - str), emitUTF8_));
395 else
396 pushValue("");
397 break;
398 }
399 case booleanValue:
400 pushValue(valueToString(value.asBool()));
401 break;
402 case arrayValue:
403 writeArrayValue(value);
404 break;
405 case objectValue: {
406 Value::Members members(value.getMemberNames());
407
408 bool isEmpty = members.empty();
409 if (!isEmpty && dropNullPlaceholders_) {
410 isEmpty = true;
411 for (auto& childValue : value) {
412 if (childValue.type() != nullValue || childValue.hasComment()) {
413 isEmpty = false;
414 break;
415 }
416 }
417 }
418
419 if (isEmpty) {
420 pushValue("{}");
421 } else {
422 ptrdiff_t maxOffset = 0;
423 for (const auto& member : members) {
424 Value const& childValue = value[member];
425 ptrdiff_t offset = childValue.getOffsetStart();
426 if (maxOffset < offset) {
427 maxOffset = offset;
428 }
429 }
430 std::map<std::string, ptrdiff_t> offsets;
431 for (const auto& member : members) {
432 Value const& childValue = value[member];

Callers

nothing calls this directly

Calls 15

valueToStringFunction · 0.85
valueToQuotedStringNFunction · 0.85
sortFunction · 0.85
asLargestIntMethod · 0.80
asLargestUIntMethod · 0.80
asDoubleMethod · 0.80
getStringMethod · 0.80
asBoolMethod · 0.80
getMemberNamesMethod · 0.80
hasCommentMethod · 0.80
getOffsetStartMethod · 0.80
typeMethod · 0.45

Tested by

no test coverage detected