| 3199 | #endif |
| 3200 | |
| 3201 | Value::Int Value::asInt() const { |
| 3202 | switch (type_) { |
| 3203 | case intValue: |
| 3204 | JSON_ASSERT_MESSAGE(isInt(), "LargestInt out of Int range"); |
| 3205 | return Int(value_.int_); |
| 3206 | case uintValue: |
| 3207 | JSON_ASSERT_MESSAGE(isInt(), "LargestUInt out of Int range"); |
| 3208 | return Int(value_.uint_); |
| 3209 | case realValue: |
| 3210 | JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt, maxInt), |
| 3211 | "double out of Int range"); |
| 3212 | return Int(value_.real_); |
| 3213 | case nullValue: |
| 3214 | return 0; |
| 3215 | case booleanValue: |
| 3216 | return value_.bool_ ? 1 : 0; |
| 3217 | default: |
| 3218 | break; |
| 3219 | } |
| 3220 | JSON_FAIL_MESSAGE("Value is not convertible to Int."); |
| 3221 | } |
| 3222 | |
| 3223 | Value::UInt Value::asUInt() const { |
| 3224 | switch (type_) { |
no test coverage detected