| 3266 | } |
| 3267 | |
| 3268 | Value::UInt64 Value::asUInt64() const { |
| 3269 | switch (type_) { |
| 3270 | case intValue: |
| 3271 | JSON_ASSERT_MESSAGE(isUInt64(), "LargestInt out of UInt64 range"); |
| 3272 | return UInt64(value_.int_); |
| 3273 | case uintValue: |
| 3274 | return UInt64(value_.uint_); |
| 3275 | case realValue: |
| 3276 | JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt64), |
| 3277 | "double out of UInt64 range"); |
| 3278 | return UInt64(value_.real_); |
| 3279 | case nullValue: |
| 3280 | return 0; |
| 3281 | case booleanValue: |
| 3282 | return value_.bool_ ? 1 : 0; |
| 3283 | default: |
| 3284 | break; |
| 3285 | } |
| 3286 | JSON_FAIL_MESSAGE("Value is not convertible to UInt64."); |
| 3287 | } |
| 3288 | #endif // if defined(JSON_HAS_INT64) |
| 3289 | |
| 3290 | LargestInt Value::asLargestInt() const { |