! \internal Default constructor initialization must be equivalent to: * memset( this, 0, sizeof(Value) ) * This optimization is used in ValueInternalMap fast allocator. */
| 2822 | * This optimization is used in ValueInternalMap fast allocator. |
| 2823 | */ |
| 2824 | Value::Value(ValueType vtype) { |
| 2825 | static char const emptyString[] = ""; |
| 2826 | initBasic(vtype); |
| 2827 | switch (vtype) { |
| 2828 | case nullValue: |
| 2829 | break; |
| 2830 | case intValue: |
| 2831 | case uintValue: |
| 2832 | value_.int_ = 0; |
| 2833 | break; |
| 2834 | case realValue: |
| 2835 | value_.real_ = 0.0; |
| 2836 | break; |
| 2837 | case stringValue: |
| 2838 | // allocated_ == false, so this is safe. |
| 2839 | value_.string_ = const_cast<char*>(static_cast<char const*>(emptyString)); |
| 2840 | break; |
| 2841 | case arrayValue: |
| 2842 | case objectValue: |
| 2843 | value_.map_ = new ObjectValues(); |
| 2844 | break; |
| 2845 | case booleanValue: |
| 2846 | value_.bool_ = false; |
| 2847 | break; |
| 2848 | default: |
| 2849 | JSON_ASSERT_UNREACHABLE; |
| 2850 | } |
| 2851 | } |
| 2852 | |
| 2853 | Value::Value(Int value) { |
| 2854 | initBasic(intValue); |
nothing calls this directly
no test coverage detected