| 2111 | } |
| 2112 | |
| 2113 | Value::UInt64 Value::asUInt64() const { |
| 2114 | switch (type_) { |
| 2115 | case intValue: |
| 2116 | JSON_ASSERT_MESSAGE(isUInt64(), "LargestInt out of UInt64 range"); |
| 2117 | return UInt64(value_.int_); |
| 2118 | case uintValue: |
| 2119 | return UInt64(value_.uint_); |
| 2120 | case realValue: |
| 2121 | JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt64), |
| 2122 | "double out of UInt64 range"); |
| 2123 | return UInt64(value_.real_); |
| 2124 | case nullValue: |
| 2125 | return 0; |
| 2126 | case booleanValue: |
| 2127 | return value_.bool_ ? 1 : 0; |
| 2128 | default: |
| 2129 | break; |
| 2130 | } |
| 2131 | JSON_FAIL_MESSAGE("Value is not convertible to UInt64."); |
| 2132 | } |
| 2133 | #endif // if defined(JSON_HAS_INT64) |
| 2134 | |
| 2135 | LargestInt Value::asLargestInt() const { |