| 2859 | } |
| 2860 | |
| 2861 | Value::UInt64 Value::asUInt64() const { |
| 2862 | switch (type_) { |
| 2863 | case intValue: |
| 2864 | JSON_ASSERT_MESSAGE(isUInt64(), "LargestInt out of UInt64 range"); |
| 2865 | return UInt64(value_.int_); |
| 2866 | case uintValue: |
| 2867 | return UInt64(value_.uint_); |
| 2868 | case realValue: |
| 2869 | JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt64), |
| 2870 | "double out of UInt64 range"); |
| 2871 | return UInt64(value_.real_); |
| 2872 | case nullValue: |
| 2873 | return 0; |
| 2874 | case booleanValue: |
| 2875 | return value_.bool_ ? 1 : 0; |
| 2876 | default: |
| 2877 | break; |
| 2878 | } |
| 2879 | JSON_FAIL_MESSAGE("Value is not convertible to UInt64."); |
| 2880 | } |
| 2881 | #endif // if defined(JSON_HAS_INT64) |
| 2882 | |
| 2883 | LargestInt Value::asLargestInt() const { |