! \internal Default constructor initialization must be equivalent to: * memset( this, 0, sizeof(Value) ) * This optimization is used in ValueInternalMap fast allocator. */
| 353 | * This optimization is used in ValueInternalMap fast allocator. |
| 354 | */ |
| 355 | Value::Value(ValueType vtype) { |
| 356 | static char const emptyString[] = ""; |
| 357 | initBasic(vtype); |
| 358 | switch (vtype) { |
| 359 | case nullValue: |
| 360 | break; |
| 361 | case intValue: |
| 362 | case uintValue: |
| 363 | value_.int_ = 0; |
| 364 | break; |
| 365 | case realValue: |
| 366 | value_.real_ = 0.0; |
| 367 | break; |
| 368 | case stringValue: |
| 369 | // allocated_ == false, so this is safe. |
| 370 | value_.string_ = const_cast<char*>(static_cast<char const*>(emptyString)); |
| 371 | break; |
| 372 | case arrayValue: |
| 373 | case objectValue: |
| 374 | value_.map_ = new ObjectValues(); |
| 375 | break; |
| 376 | case booleanValue: |
| 377 | value_.bool_ = false; |
| 378 | break; |
| 379 | default: |
| 380 | JSON_ASSERT_UNREACHABLE; |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | Value::Value(Int value) { |
| 385 | initBasic(intValue); |
nothing calls this directly
no test coverage detected