| 3157 | } |
| 3158 | |
| 3159 | Value::UInt64 Value::asUInt64() const { |
| 3160 | switch (type()) { |
| 3161 | case intValue: |
| 3162 | JSON_ASSERT_MESSAGE(isUInt64(), "LargestInt out of UInt64 range"); |
| 3163 | return UInt64(value_.int_); |
| 3164 | case uintValue: |
| 3165 | return UInt64(value_.uint_); |
| 3166 | case realValue: |
| 3167 | JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt64), |
| 3168 | "double out of UInt64 range"); |
| 3169 | return UInt64(value_.real_); |
| 3170 | case nullValue: |
| 3171 | return 0; |
| 3172 | case booleanValue: |
| 3173 | return value_.bool_ ? 1 : 0; |
| 3174 | default: |
| 3175 | break; |
| 3176 | } |
| 3177 | JSON_FAIL_MESSAGE("Value is not convertible to UInt64."); |
| 3178 | } |
| 3179 | #endif // if defined(JSON_HAS_INT64) |
| 3180 | |
| 3181 | LargestInt Value::asLargestInt() const { |