! \internal Default constructor initialization must be equivalent to: * memset( this, 0, sizeof(Value) ) * This optimization is used in ValueInternalMap fast allocator. */
| 2783 | * This optimization is used in ValueInternalMap fast allocator. |
| 2784 | */ |
| 2785 | Value::Value(ValueType type) { |
| 2786 | static char const emptyString[] = ""; |
| 2787 | initBasic(type); |
| 2788 | switch (type) { |
| 2789 | case nullValue: |
| 2790 | break; |
| 2791 | case intValue: |
| 2792 | case uintValue: |
| 2793 | value_.int_ = 0; |
| 2794 | break; |
| 2795 | case realValue: |
| 2796 | value_.real_ = 0.0; |
| 2797 | break; |
| 2798 | case stringValue: |
| 2799 | // allocated_ == false, so this is safe. |
| 2800 | value_.string_ = const_cast<char*>(static_cast<char const*>(emptyString)); |
| 2801 | break; |
| 2802 | case arrayValue: |
| 2803 | case objectValue: |
| 2804 | value_.map_ = new ObjectValues(); |
| 2805 | break; |
| 2806 | case booleanValue: |
| 2807 | value_.bool_ = false; |
| 2808 | break; |
| 2809 | default: |
| 2810 | JSON_ASSERT_UNREACHABLE; |
| 2811 | } |
| 2812 | } |
| 2813 | |
| 2814 | Value::Value(Int value) { |
| 2815 | initBasic(intValue); |
nothing calls this directly
no test coverage detected