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