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