MCPcopy Create free account
hub / github.com/Samsung/UTopia / writeValue

Method writeValue

external/jsoncpp/jsoncpp.cpp:4441–4493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4439}
4440
4441void FastWriter::writeValue(const Value &value) {
4442 switch (value.type()) {
4443 case nullValue:
4444 if (!dropNullPlaceholders_)
4445 document_ += "null";
4446 break;
4447 case intValue:
4448 document_ += valueToString(value.asLargestInt());
4449 break;
4450 case uintValue:
4451 document_ += valueToString(value.asLargestUInt());
4452 break;
4453 case realValue:
4454 document_ += valueToString(value.asDouble());
4455 break;
4456 case stringValue: {
4457 // Is NULL possible for value.string_? No.
4458 char const *str;
4459 char const *end;
4460 bool ok = value.getString(&str, &end);
4461 if (ok)
4462 document_ += valueToQuotedStringN(str, static_cast<unsigned>(end - str));
4463 break;
4464 }
4465 case booleanValue:
4466 document_ += valueToString(value.asBool());
4467 break;
4468 case arrayValue: {
4469 document_ += '[';
4470 ArrayIndex size = value.size();
4471 for (ArrayIndex index = 0; index < size; ++index) {
4472 if (index > 0)
4473 document_ += ',';
4474 writeValue(value[index]);
4475 }
4476 document_ += ']';
4477 } break;
4478 case objectValue: {
4479 Value::Members members(value.getMemberNames());
4480 document_ += '{';
4481 for (auto it = members.begin(); it != members.end(); ++it) {
4482 const String &name = *it;
4483 if (it != members.begin())
4484 document_ += ',';
4485 document_ += valueToQuotedStringN(name.data(),
4486 static_cast<unsigned>(name.length()));
4487 document_ += yamlCompatibilityEnabled_ ? ": " : ":";
4488 writeValue(value[name]);
4489 }
4490 document_ += '}';
4491 } break;
4492 }
4493}
4494
4495// Class StyledWriter
4496// //////////////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 15

valueToStringFunction · 0.85
valueToQuotedStringNFunction · 0.85
valueToQuotedStringFunction · 0.85
typeMethod · 0.80
asLargestIntMethod · 0.80
asLargestUIntMethod · 0.80
asDoubleMethod · 0.80
getStringMethod · 0.80
asBoolMethod · 0.80
sizeMethod · 0.80
getMemberNamesMethod · 0.80
beginMethod · 0.80

Tested by

no test coverage detected