| 3141 | #endif |
| 3142 | |
| 3143 | Value::Int Value::asInt() const { |
| 3144 | switch (type_) { |
| 3145 | case intValue: |
| 3146 | JSON_ASSERT_MESSAGE(isInt(), "LargestInt out of Int range"); |
| 3147 | return Int(value_.int_); |
| 3148 | case uintValue: |
| 3149 | JSON_ASSERT_MESSAGE(isInt(), "LargestUInt out of Int range"); |
| 3150 | return Int(value_.uint_); |
| 3151 | case realValue: |
| 3152 | JSON_ASSERT_MESSAGE(InRange(value_.real_, minInt, maxInt), |
| 3153 | "double out of Int range"); |
| 3154 | return Int(value_.real_); |
| 3155 | case nullValue: |
| 3156 | return 0; |
| 3157 | case booleanValue: |
| 3158 | return value_.bool_ ? 1 : 0; |
| 3159 | default: |
| 3160 | break; |
| 3161 | } |
| 3162 | JSON_FAIL_MESSAGE("Value is not convertible to Int."); |
| 3163 | } |
| 3164 | |
| 3165 | Value::UInt Value::asUInt() const { |
| 3166 | switch (type_) { |
no test coverage detected