| 3291 | } |
| 3292 | |
| 3293 | bool Value::asBool() const { |
| 3294 | switch (type_) { |
| 3295 | case booleanValue: |
| 3296 | return value_.bool_; |
| 3297 | case nullValue: |
| 3298 | return false; |
| 3299 | case intValue: |
| 3300 | return value_.int_ ? true : false; |
| 3301 | case uintValue: |
| 3302 | return value_.uint_ ? true : false; |
| 3303 | case realValue: |
| 3304 | // This is kind of strange. Not recommended. |
| 3305 | return (value_.real_ != 0.0) ? true : false; |
| 3306 | default: |
| 3307 | break; |
| 3308 | } |
| 3309 | JSON_FAIL_MESSAGE("Value is not convertible to bool."); |
| 3310 | } |
| 3311 | |
| 3312 | bool Value::isConvertibleTo(ValueType other) const { |
| 3313 | switch (other) { |
no outgoing calls
no test coverage detected