| 370 | } |
| 371 | |
| 372 | void 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 | // ////////////////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected