| 3112 | } |
| 3113 | |
| 3114 | Value::UInt Value::asUInt() const { |
| 3115 | switch (type()) { |
| 3116 | case intValue: |
| 3117 | JSON_ASSERT_MESSAGE(isUInt(), "LargestInt out of UInt range"); |
| 3118 | return UInt(value_.int_); |
| 3119 | case uintValue: |
| 3120 | JSON_ASSERT_MESSAGE(isUInt(), "LargestUInt out of UInt range"); |
| 3121 | return UInt(value_.uint_); |
| 3122 | case realValue: |
| 3123 | JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt), |
| 3124 | "double out of UInt range"); |
| 3125 | return UInt(value_.real_); |
| 3126 | case nullValue: |
| 3127 | return 0; |
| 3128 | case booleanValue: |
| 3129 | return value_.bool_ ? 1 : 0; |
| 3130 | default: |
| 3131 | break; |
| 3132 | } |
| 3133 | JSON_FAIL_MESSAGE("Value is not convertible to UInt."); |
| 3134 | } |
| 3135 | |
| 3136 | #if defined(JSON_HAS_INT64) |
| 3137 |
no test coverage detected