| 4376 | } |
| 4377 | |
| 4378 | void FastWriter::writeValue(const Value& value) { |
| 4379 | switch (value.type()) { |
| 4380 | case nullValue: |
| 4381 | if (!dropNullPlaceholders_) |
| 4382 | document_ += "null"; |
| 4383 | break; |
| 4384 | case intValue: |
| 4385 | document_ += valueToString(value.asLargestInt()); |
| 4386 | break; |
| 4387 | case uintValue: |
| 4388 | document_ += valueToString(value.asLargestUInt()); |
| 4389 | break; |
| 4390 | case realValue: |
| 4391 | document_ += valueToString(value.asDouble()); |
| 4392 | break; |
| 4393 | case stringValue: |
| 4394 | { |
| 4395 | // Is NULL possible for value.string_? |
| 4396 | char const* str; |
| 4397 | char const* end; |
| 4398 | bool ok = value.getString(&str, &end); |
| 4399 | if (ok) document_ += valueToQuotedStringN(str, static_cast<unsigned>(end-str)); |
| 4400 | break; |
| 4401 | } |
| 4402 | case booleanValue: |
| 4403 | document_ += valueToString(value.asBool()); |
| 4404 | break; |
| 4405 | case arrayValue: { |
| 4406 | document_ += '['; |
| 4407 | int size = value.size(); |
| 4408 | for (int index = 0; index < size; ++index) { |
| 4409 | if (index > 0) |
| 4410 | document_ += ','; |
| 4411 | writeValue(value[index]); |
| 4412 | } |
| 4413 | document_ += ']'; |
| 4414 | } break; |
| 4415 | case objectValue: { |
| 4416 | Value::Members members(value.getMemberNames()); |
| 4417 | document_ += '{'; |
| 4418 | for (Value::Members::iterator it = members.begin(); it != members.end(); |
| 4419 | ++it) { |
| 4420 | const std::string& name = *it; |
| 4421 | if (it != members.begin()) |
| 4422 | document_ += ','; |
| 4423 | document_ += valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length())); |
| 4424 | document_ += yamlCompatiblityEnabled_ ? ": " : ":"; |
| 4425 | writeValue(value[name]); |
| 4426 | } |
| 4427 | document_ += '}'; |
| 4428 | } break; |
| 4429 | } |
| 4430 | } |
| 4431 | |
| 4432 | // Class StyledWriter |
| 4433 | // ////////////////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected