| 3121 | } |
| 3122 | |
| 3123 | Value::UInt Value::asUInt() const { |
| 3124 | switch (type_) { |
| 3125 | case intValue: |
| 3126 | JSON_ASSERT_MESSAGE(isUInt(), "LargestInt out of UInt range"); |
| 3127 | return UInt(value_.int_); |
| 3128 | case uintValue: |
| 3129 | JSON_ASSERT_MESSAGE(isUInt(), "LargestUInt out of UInt range"); |
| 3130 | return UInt(value_.uint_); |
| 3131 | case realValue: |
| 3132 | JSON_ASSERT_MESSAGE(InRange(value_.real_, 0, maxUInt), |
| 3133 | "double out of UInt range"); |
| 3134 | return UInt(value_.real_); |
| 3135 | case nullValue: |
| 3136 | return 0; |
| 3137 | case booleanValue: |
| 3138 | return value_.bool_ ? 1 : 0; |
| 3139 | default: |
| 3140 | if ( default_value_ ) |
| 3141 | return default_value_->asUInt(); |
| 3142 | else |
| 3143 | return 0u; |
| 3144 | } |
| 3145 | } |
| 3146 | |
| 3147 | #if defined(JSON_HAS_INT64) |
| 3148 |
no test coverage detected