! \internal Default constructor initialization must be equivalent to: * memset( this, 0, sizeof(Value) ) * This optimization is used in ValueInternalMap fast allocator. */
| 2994 | * This optimization is used in ValueInternalMap fast allocator. |
| 2995 | */ |
| 2996 | Value::Value(ValueType type) |
| 2997 | { |
| 2998 | static char const emptyString[] = ""; |
| 2999 | initBasic(type); |
| 3000 | switch (type) |
| 3001 | { |
| 3002 | case nullValue: |
| 3003 | break; |
| 3004 | case intValue: |
| 3005 | case uintValue: |
| 3006 | value_.int_ = 0; |
| 3007 | break; |
| 3008 | case realValue: |
| 3009 | value_.real_ = 0.0; |
| 3010 | break; |
| 3011 | case stringValue: |
| 3012 | // allocated_ == false, so this is safe. |
| 3013 | value_.string_ = const_cast<char *>(static_cast<char const *>(emptyString)); |
| 3014 | break; |
| 3015 | case arrayValue: |
| 3016 | case objectValue: |
| 3017 | value_.map_ = new ObjectValues(); |
| 3018 | break; |
| 3019 | case booleanValue: |
| 3020 | value_.bool_ = false; |
| 3021 | break; |
| 3022 | default: |
| 3023 | JSON_ASSERT_UNREACHABLE; |
| 3024 | } |
| 3025 | } |
| 3026 | |
| 3027 | Value::Value(Int value) |
| 3028 | { |
no test coverage detected