| 3178 | } |
| 3179 | |
| 3180 | Value::UInt Value::asUInt() const { |
| 3181 | switch (type_) { |
| 3182 | case intValue: |
| 3183 | JSON_ASSERT_MESSAGE(isUInt(), "LargestInt out of UInt range"); |
| 3184 | return UInt(value_.int_); |
| 3185 | case uintValue: |
| 3186 | JSON_ASSERT_MESSAGE(isUInt(), "LargestUInt out of UInt range"); |
| 3187 | return UInt(value_.uint_); |
| 3188 | case realValue: |
| 3189 | JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt), |
| 3190 | "double out of UInt range"); |
| 3191 | return UInt(value_.real_); |
| 3192 | case nullValue: |
| 3193 | return 0; |
| 3194 | case booleanValue: |
| 3195 | return value_.bool_ ? 1 : 0; |
| 3196 | default: |
| 3197 | break; |
| 3198 | } |
| 3199 | JSON_FAIL_MESSAGE("Value is not convertible to UInt."); |
| 3200 | } |
| 3201 | |
| 3202 | #if defined(JSON_HAS_INT64) |
| 3203 |
no test coverage detected