| 2044 | #endif |
| 2045 | |
| 2046 | Value::Int Value::asInt() const { |
| 2047 | switch (type_) { |
| 2048 | case intValue: |
| 2049 | JSON_ASSERT_MESSAGE(isInt(), "LargestInt out of Int range"); |
| 2050 | return Int(value_.int_); |
| 2051 | case uintValue: |
| 2052 | JSON_ASSERT_MESSAGE(isInt(), "LargestUInt out of Int range"); |
| 2053 | return Int(value_.uint_); |
| 2054 | case realValue: |
| 2055 | JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt, maxInt), |
| 2056 | "double out of Int range"); |
| 2057 | return Int(value_.real_); |
| 2058 | case nullValue: |
| 2059 | return 0; |
| 2060 | case booleanValue: |
| 2061 | return value_.bool_ ? 1 : 0; |
| 2062 | default: |
| 2063 | break; |
| 2064 | } |
| 2065 | JSON_FAIL_MESSAGE("Value is not convertible to Int."); |
| 2066 | } |
| 2067 | |
| 2068 | Value::UInt Value::asUInt() const { |
| 2069 | switch (type_) { |
no test coverage detected