| 674 | } |
| 675 | |
| 676 | Value::UInt Value::asUInt() const { |
| 677 | switch (type()) { |
| 678 | case intValue: |
| 679 | JSON_ASSERT_MESSAGE(isUInt(), "LargestInt out of UInt range"); |
| 680 | return UInt(value_.int_); |
| 681 | case uintValue: |
| 682 | JSON_ASSERT_MESSAGE(isUInt(), "LargestUInt out of UInt range"); |
| 683 | return UInt(value_.uint_); |
| 684 | case realValue: |
| 685 | JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt), |
| 686 | "double out of UInt range"); |
| 687 | return UInt(value_.real_); |
| 688 | case nullValue: |
| 689 | return 0; |
| 690 | case booleanValue: |
| 691 | return value_.bool_ ? 1 : 0; |
| 692 | default: |
| 693 | break; |
| 694 | } |
| 695 | JSON_FAIL_MESSAGE("Value is not convertible to UInt."); |
| 696 | } |
| 697 | |
| 698 | #if defined(JSON_HAS_INT64) |
| 699 | |