| 3153 | #endif |
| 3154 | |
| 3155 | Value::Int Value::asInt() const { |
| 3156 | switch (type_) { |
| 3157 | case intValue: |
| 3158 | JSON_ASSERT_MESSAGE(isInt(), "LargestInt out of Int range"); |
| 3159 | return Int(value_.int_); |
| 3160 | case uintValue: |
| 3161 | JSON_ASSERT_MESSAGE(isInt(), "LargestUInt out of Int range"); |
| 3162 | return Int(value_.uint_); |
| 3163 | case realValue: |
| 3164 | JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt, maxInt), |
| 3165 | "double out of Int range"); |
| 3166 | return Int(value_.real_); |
| 3167 | case nullValue: |
| 3168 | return 0; |
| 3169 | case booleanValue: |
| 3170 | return value_.bool_ ? 1 : 0; |
| 3171 | default: |
| 3172 | break; |
| 3173 | } |
| 3174 | JSON_FAIL_MESSAGE("Value is not convertible to Int."); |
| 3175 | } |
| 3176 | |
| 3177 | Value::UInt Value::asUInt() const { |
| 3178 | switch (type_) { |
no test coverage detected