! \internal Default constructor initialization must be equivalent to: * memset( this, 0, sizeof(Value) ) * This optimization is used in ValueInternalMap fast allocator. */
| 2733 | * This optimization is used in ValueInternalMap fast allocator. |
| 2734 | */ |
| 2735 | Value::Value(ValueType type) { |
| 2736 | static char const emptyString[] = ""; |
| 2737 | initBasic(type); |
| 2738 | switch (type) { |
| 2739 | case nullValue: |
| 2740 | break; |
| 2741 | case intValue: |
| 2742 | case uintValue: |
| 2743 | value_.int_ = 0; |
| 2744 | break; |
| 2745 | case realValue: |
| 2746 | value_.real_ = 0.0; |
| 2747 | break; |
| 2748 | case stringValue: |
| 2749 | // allocated_ == false, so this is safe. |
| 2750 | value_.string_ = const_cast<char *>(static_cast<char const *>(emptyString)); |
| 2751 | break; |
| 2752 | case arrayValue: |
| 2753 | case objectValue: |
| 2754 | value_.map_ = new ObjectValues(); |
| 2755 | break; |
| 2756 | case booleanValue: |
| 2757 | value_.bool_ = false; |
| 2758 | break; |
| 2759 | default: |
| 2760 | JSON_ASSERT_UNREACHABLE; |
| 2761 | } |
| 2762 | } |
| 2763 | |
| 2764 | Value::Value(Int value) { |
| 2765 | initBasic(intValue); |
nothing calls this directly
no test coverage detected