| 3081 | } |
| 3082 | |
| 3083 | Value::UInt Value::asUInt() const { |
| 3084 | switch (type()) { |
| 3085 | case intValue: |
| 3086 | JSON_ASSERT_MESSAGE(isUInt(), "LargestInt out of UInt range"); |
| 3087 | return UInt(value_.int_); |
| 3088 | case uintValue: |
| 3089 | JSON_ASSERT_MESSAGE(isUInt(), "LargestUInt out of UInt range"); |
| 3090 | return UInt(value_.uint_); |
| 3091 | case realValue: |
| 3092 | JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt), |
| 3093 | "double out of UInt range"); |
| 3094 | return UInt(value_.real_); |
| 3095 | case nullValue: |
| 3096 | return 0; |
| 3097 | case booleanValue: |
| 3098 | return value_.bool_ ? 1 : 0; |
| 3099 | default: |
| 3100 | break; |
| 3101 | } |
| 3102 | JSON_FAIL_MESSAGE("Value is not convertible to UInt."); |
| 3103 | } |
| 3104 | |
| 3105 | #if defined(JSON_HAS_INT64) |
| 3106 |
no test coverage detected