| 693 | } |
| 694 | |
| 695 | Value::UInt Value::asUInt() const { |
| 696 | switch (type()) { |
| 697 | case intValue: |
| 698 | JSON_ASSERT_MESSAGE(isUInt(), "LargestInt out of UInt range"); |
| 699 | return UInt(value_.int_); |
| 700 | case uintValue: |
| 701 | JSON_ASSERT_MESSAGE(isUInt(), "LargestUInt out of UInt range"); |
| 702 | return UInt(value_.uint_); |
| 703 | case realValue: |
| 704 | JSON_ASSERT_MESSAGE(InRange(value_.real_, 0u, maxUInt), "double out of UInt range"); |
| 705 | return UInt(value_.real_); |
| 706 | case nullValue: |
| 707 | return 0; |
| 708 | case booleanValue: |
| 709 | return value_.bool_ ? 1 : 0; |
| 710 | default: |
| 711 | break; |
| 712 | } |
| 713 | JSON_FAIL_MESSAGE("Value is not convertible to UInt."); |
| 714 | } |
| 715 | |
| 716 | #if defined(JSON_HAS_INT64) |
| 717 |
no test coverage detected