MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / writeValue

Method writeValue

Libraries/jsoncpp-0.y.z/src/lib_json/json_writer.cpp:303–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301}
302
303void FastWriter::writeValue(const Value& value) {
304 switch (value.type()) {
305 case nullValue:
306 document_ += "null";
307 break;
308 case intValue:
309 document_ += valueToString(value.asLargestInt());
310 break;
311 case uintValue:
312 document_ += valueToString(value.asLargestUInt());
313 break;
314 case realValue:
315 document_ += valueToString(value.asDouble());
316 break;
317 case stringValue:
318 {
319 // Is NULL possible for value.string_?
320 char const* str;
321 char const* end;
322 bool ok = value.getString(&str, &end);
323 if (ok) document_ += valueToQuotedStringN(str, static_cast<unsigned>(end-str));
324 break;
325 }
326 case booleanValue:
327 document_ += valueToString(value.asBool());
328 break;
329 case arrayValue: {
330 document_ += '[';
331 int size = value.size();
332 for (int index = 0; index < size; ++index) {
333 if (index > 0)
334 document_ += ',';
335 writeValue(value[index]);
336 }
337 document_ += ']';
338 } break;
339 case objectValue: {
340 Value::Members members(value.getMemberNames());
341 document_ += '{';
342 for (Value::Members::iterator it = members.begin(); it != members.end();
343 ++it) {
344 const std::string& name = *it;
345 if (it != members.begin())
346 document_ += ',';
347 document_ += valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length()));
348 document_ += yamlCompatiblityEnabled_ ? ": " : ":";
349 writeValue(value[name]);
350 }
351 document_ += '}';
352 } break;
353 }
354}
355
356// Class StyledWriter
357// //////////////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 15

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

Tested by

no test coverage detected