| 301 | } |
| 302 | |
| 303 | void 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 | // ////////////////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected