| 737 | } |
| 738 | |
| 739 | Value::UInt Value::asUInt() const { |
| 740 | switch (type_) { |
| 741 | case intValue: |
| 742 | JSON_ASSERT_MESSAGE(isUInt(), "LargestInt out of UInt range"); |
| 743 | return UInt(value_.int_); |
| 744 | case uintValue: |
| 745 | JSON_ASSERT_MESSAGE(isUInt(), "LargestUInt out of UInt range"); |
| 746 | return UInt(value_.uint_); |
| 747 | case realValue: |
| 748 | JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt), |
| 749 | "double out of UInt range"); |
| 750 | return UInt(value_.real_); |
| 751 | case nullValue: |
| 752 | return 0; |
| 753 | case booleanValue: |
| 754 | return value_.bool_ ? 1 : 0; |
| 755 | default: |
| 756 | break; |
| 757 | } |
| 758 | JSON_FAIL_MESSAGE("Value is not convertible to UInt."); |
| 759 | } |
| 760 | |
| 761 | #if defined(JSON_HAS_INT64) |
| 762 |
no test coverage detected