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