MCPcopy Create free account
hub / github.com/ComodoSecurity/openedr / writeValue

Method writeValue

edrav2/eprj/jsoncpp/src/lib_json/json_writer.cpp:372–425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

370}
371
372void FastWriter::writeValue(const Value& value) {
373 switch (value.type()) {
374 case nullValue:
375 if (!dropNullPlaceholders_)
376 document_ += "null";
377 break;
378 case intValue:
379 document_ += valueToString(value.asLargestInt());
380 break;
381 case uintValue:
382 document_ += valueToString(value.asLargestUInt());
383 break;
384 case realValue:
385 document_ += valueToString(value.asDouble());
386 break;
387 case stringValue: {
388 // Is NULL possible for value.string_? No.
389 char const* str;
390 char const* end;
391 bool ok = value.getString(&str, &end);
392 if (ok)
393 document_ += valueToQuotedStringN(str, static_cast<unsigned>(end - str));
394 break;
395 }
396 case booleanValue:
397 document_ += valueToString(value.asBool());
398 break;
399 case arrayValue: {
400 document_ += '[';
401 ArrayIndex size = value.size();
402 for (ArrayIndex index = 0; index < size; ++index) {
403 if (index > 0)
404 document_ += ',';
405 writeValue(value[index]);
406 }
407 document_ += ']';
408 } break;
409 case objectValue: {
410 Value::Members members(value.getMemberNames());
411 document_ += '{';
412 for (auto it = members.begin(); it != members.end();
413 ++it) {
414 const JSONCPP_STRING& name = *it;
415 if (it != members.begin())
416 document_ += ',';
417 document_ += valueToQuotedStringN(name.data(),
418 static_cast<unsigned>(name.length()));
419 document_ += yamlCompatibilityEnabled_ ? ": " : ":";
420 writeValue(value[name]);
421 }
422 document_ += '}';
423 } break;
424 }
425}
426
427// Class StyledWriter
428// //////////////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 15

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

Tested by

no test coverage detected