| 771 | } |
| 772 | |
| 773 | Value::UInt64 Value::asUInt64() const { |
| 774 | switch (type()) { |
| 775 | case intValue: |
| 776 | JSON_ASSERT_MESSAGE(isUInt64(), "LargestInt out of UInt64 range"); |
| 777 | return UInt64(value_.int_); |
| 778 | case uintValue: |
| 779 | return UInt64(value_.uint_); |
| 780 | case realValue: |
| 781 | JSON_ASSERT_MESSAGE(InRange(value_.real_, 0u, maxUInt64), "double out of UInt64 range"); |
| 782 | return UInt64(value_.real_); |
| 783 | case nullValue: |
| 784 | return 0; |
| 785 | case booleanValue: |
| 786 | return value_.bool_ ? 1 : 0; |
| 787 | default: |
| 788 | break; |
| 789 | } |
| 790 | JSON_FAIL_MESSAGE("Value is not convertible to UInt64."); |
| 791 | } |
| 792 | #endif // if defined(JSON_HAS_INT64) |
| 793 | |
| 794 | LargestInt Value::asLargestInt() const { |