| 2814 | } |
| 2815 | |
| 2816 | Value::UInt Value::asUInt() const { |
| 2817 | switch (type_) { |
| 2818 | case intValue: |
| 2819 | JSON_ASSERT_MESSAGE(isUInt(), "LargestInt out of UInt range"); |
| 2820 | return UInt(value_.int_); |
| 2821 | case uintValue: |
| 2822 | JSON_ASSERT_MESSAGE(isUInt(), "LargestUInt out of UInt range"); |
| 2823 | return UInt(value_.uint_); |
| 2824 | case realValue: |
| 2825 | JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt), |
| 2826 | "double out of UInt range"); |
| 2827 | return UInt(value_.real_); |
| 2828 | case nullValue: |
| 2829 | return 0; |
| 2830 | case booleanValue: |
| 2831 | return value_.bool_ ? 1 : 0; |
| 2832 | default: |
| 2833 | break; |
| 2834 | } |
| 2835 | JSON_FAIL_MESSAGE("Value is not convertible to UInt."); |
| 2836 | } |
| 2837 | |
| 2838 | #if defined(JSON_HAS_INT64) |
| 2839 | |