| 3346 | } |
| 3347 | |
| 3348 | Value::UInt Value::asUInt() const |
| 3349 | { |
| 3350 | switch (type()) |
| 3351 | { |
| 3352 | case intValue: |
| 3353 | JSON_ASSERT_MESSAGE(isUInt(), "LargestInt out of UInt range"); |
| 3354 | return UInt(value_.int_); |
| 3355 | case uintValue: |
| 3356 | JSON_ASSERT_MESSAGE(isUInt(), "LargestUInt out of UInt range"); |
| 3357 | return UInt(value_.uint_); |
| 3358 | case realValue: |
| 3359 | JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt), "double out of UInt range"); |
| 3360 | return UInt(value_.real_); |
| 3361 | case nullValue: |
| 3362 | return 0; |
| 3363 | case booleanValue: |
| 3364 | return value_.bool_ ? 1 : 0; |
| 3365 | default: |
| 3366 | break; |
| 3367 | } |
| 3368 | JSON_FAIL_MESSAGE("Value is not convertible to UInt."); |
| 3369 | } |
| 3370 | |
| 3371 | #if defined(JSON_HAS_INT64) |
| 3372 |
no test coverage detected