| 2124 | #endif |
| 2125 | |
| 2126 | Value::Int Value::asInt() const { |
| 2127 | switch (type_) { |
| 2128 | case intValue: |
| 2129 | JSON_ASSERT_MESSAGE(isInt(), "LargestInt out of Int range"); |
| 2130 | return Int(value_.int_); |
| 2131 | case uintValue: |
| 2132 | JSON_ASSERT_MESSAGE(isInt(), "LargestUInt out of Int range"); |
| 2133 | return Int(value_.uint_); |
| 2134 | case realValue: |
| 2135 | JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt, maxInt), |
| 2136 | "double out of Int range"); |
| 2137 | return Int(value_.real_); |
| 2138 | case nullValue: |
| 2139 | return 0; |
| 2140 | case booleanValue: |
| 2141 | return value_.bool_ ? 1 : 0; |
| 2142 | default: |
| 2143 | break; |
| 2144 | } |
| 2145 | JSON_FAIL_MESSAGE("Value is not convertible to Int."); |
| 2146 | } |
| 2147 | |
| 2148 | Value::UInt Value::asUInt() const { |
| 2149 | switch (type_) { |
no test coverage detected