| 3223 | } |
| 3224 | |
| 3225 | Value::UInt64 Value::asUInt64() const { |
| 3226 | switch (type_) { |
| 3227 | case intValue: |
| 3228 | JSON_ASSERT_MESSAGE(isUInt64(), "LargestInt out of UInt64 range"); |
| 3229 | return UInt64(value_.int_); |
| 3230 | case uintValue: |
| 3231 | return UInt64(value_.uint_); |
| 3232 | case realValue: |
| 3233 | JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt64), |
| 3234 | "double out of UInt64 range"); |
| 3235 | return UInt64(value_.real_); |
| 3236 | case nullValue: |
| 3237 | return 0; |
| 3238 | case booleanValue: |
| 3239 | return value_.bool_ ? 1 : 0; |
| 3240 | default: |
| 3241 | break; |
| 3242 | } |
| 3243 | JSON_FAIL_MESSAGE("Value is not convertible to UInt64."); |
| 3244 | } |
| 3245 | #endif // if defined(JSON_HAS_INT64) |
| 3246 | |
| 3247 | LargestInt Value::asLargestInt() const { |