! \internal Default constructor initialization must be equivalent to: * memset( this, 0, sizeof(Value) ) * This optimization is used in ValueInternalMap fast allocator. */
| 381 | * This optimization is used in ValueInternalMap fast allocator. |
| 382 | */ |
| 383 | Value::Value(ValueType type) { |
| 384 | static char const emptyString[] = ""; |
| 385 | initBasic(type); |
| 386 | switch (type) { |
| 387 | case nullValue: |
| 388 | break; |
| 389 | case intValue: |
| 390 | case uintValue: |
| 391 | value_.int_ = 0; |
| 392 | break; |
| 393 | case realValue: |
| 394 | value_.real_ = 0.0; |
| 395 | break; |
| 396 | case stringValue: |
| 397 | // allocated_ == false, so this is safe. |
| 398 | value_.string_ = const_cast<char*>(static_cast<char const*>(emptyString)); |
| 399 | break; |
| 400 | case arrayValue: |
| 401 | case objectValue: |
| 402 | value_.map_ = new ObjectValues(); |
| 403 | break; |
| 404 | case booleanValue: |
| 405 | value_.bool_ = false; |
| 406 | break; |
| 407 | default: |
| 408 | JSON_ASSERT_UNREACHABLE; |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | Value::Value(Int value) { |
| 413 | initBasic(intValue); |