| 752 | } |
| 753 | |
| 754 | Value::UInt Value::asUInt() const { |
| 755 | switch (type_) { |
| 756 | case intValue: |
| 757 | JSON_ASSERT_MESSAGE(isUInt(), "LargestInt out of UInt range"); |
| 758 | return UInt(value_.int_); |
| 759 | case uintValue: |
| 760 | JSON_ASSERT_MESSAGE(isUInt(), "LargestUInt out of UInt range"); |
| 761 | return UInt(value_.uint_); |
| 762 | case realValue: |
| 763 | JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt), |
| 764 | "double out of UInt range"); |
| 765 | return UInt(value_.real_); |
| 766 | case nullValue: |
| 767 | return 0; |
| 768 | case booleanValue: |
| 769 | return value_.bool_ ? 1 : 0; |
| 770 | default: |
| 771 | break; |
| 772 | } |
| 773 | JSON_FAIL_MESSAGE("Value is not convertible to UInt."); |
| 774 | } |
| 775 | |
| 776 | #if defined(JSON_HAS_INT64) |
| 777 |
no test coverage detected