| 2146 | } |
| 2147 | |
| 2148 | Value::UInt Value::asUInt() const { |
| 2149 | switch (type_) { |
| 2150 | case intValue: |
| 2151 | JSON_ASSERT_MESSAGE(isUInt(), "LargestInt out of UInt range"); |
| 2152 | return UInt(value_.int_); |
| 2153 | case uintValue: |
| 2154 | JSON_ASSERT_MESSAGE(isUInt(), "LargestUInt out of UInt range"); |
| 2155 | return UInt(value_.uint_); |
| 2156 | case realValue: |
| 2157 | JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt), |
| 2158 | "double out of UInt range"); |
| 2159 | return UInt(value_.real_); |
| 2160 | case nullValue: |
| 2161 | return 0; |
| 2162 | case booleanValue: |
| 2163 | return value_.bool_ ? 1 : 0; |
| 2164 | default: |
| 2165 | break; |
| 2166 | } |
| 2167 | JSON_FAIL_MESSAGE("Value is not convertible to UInt."); |
| 2168 | } |
| 2169 | |
| 2170 | #if defined(JSON_HAS_INT64) |
| 2171 | |