| 2066 | } |
| 2067 | |
| 2068 | Value::UInt Value::asUInt() const { |
| 2069 | switch (type_) { |
| 2070 | case intValue: |
| 2071 | JSON_ASSERT_MESSAGE(isUInt(), "LargestInt out of UInt range"); |
| 2072 | return UInt(value_.int_); |
| 2073 | case uintValue: |
| 2074 | JSON_ASSERT_MESSAGE(isUInt(), "LargestUInt out of UInt range"); |
| 2075 | return UInt(value_.uint_); |
| 2076 | case realValue: |
| 2077 | JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt), |
| 2078 | "double out of UInt range"); |
| 2079 | return UInt(value_.real_); |
| 2080 | case nullValue: |
| 2081 | return 0; |
| 2082 | case booleanValue: |
| 2083 | return value_.bool_ ? 1 : 0; |
| 2084 | default: |
| 2085 | break; |
| 2086 | } |
| 2087 | JSON_FAIL_MESSAGE("Value is not convertible to UInt."); |
| 2088 | } |
| 2089 | |
| 2090 | #if defined(JSON_HAS_INT64) |
| 2091 | |