| 974 | } |
| 975 | |
| 976 | void Value::dupPayload(const Value& other) { |
| 977 | setType(other.type()); |
| 978 | setIsAllocated(false); |
| 979 | switch (type()) { |
| 980 | case nullValue: |
| 981 | case intValue: |
| 982 | case uintValue: |
| 983 | case realValue: |
| 984 | case booleanValue: |
| 985 | value_ = other.value_; |
| 986 | break; |
| 987 | case stringValue: |
| 988 | if (other.value_.string_ && other.isAllocated()) { |
| 989 | unsigned len; |
| 990 | char const* str; |
| 991 | decodePrefixedString(other.isAllocated(), other.value_.string_, &len, |
| 992 | &str); |
| 993 | value_.string_ = duplicateAndPrefixStringValue(str, len); |
| 994 | setIsAllocated(true); |
| 995 | } else { |
| 996 | value_.string_ = other.value_.string_; |
| 997 | } |
| 998 | break; |
| 999 | case arrayValue: |
| 1000 | case objectValue: |
| 1001 | value_.map_ = new ObjectValues(*other.value_.map_); |
| 1002 | break; |
| 1003 | default: |
| 1004 | JSON_ASSERT_UNREACHABLE; |
| 1005 | } |
| 1006 | } |
| 1007 | |
| 1008 | void Value::releasePayload() { |
| 1009 | switch (type()) { |
nothing calls this directly
no test coverage detected