| 3303 | } |
| 3304 | |
| 3305 | bool Value::asBool() const { |
| 3306 | switch (type_) { |
| 3307 | case booleanValue: |
| 3308 | return value_.bool_; |
| 3309 | case nullValue: |
| 3310 | return false; |
| 3311 | case intValue: |
| 3312 | return value_.int_ ? true : false; |
| 3313 | case uintValue: |
| 3314 | return value_.uint_ ? true : false; |
| 3315 | case realValue: |
| 3316 | // This is kind of strange. Not recommended. |
| 3317 | return (value_.real_ != 0.0) ? true : false; |
| 3318 | default: |
| 3319 | break; |
| 3320 | } |
| 3321 | JSON_FAIL_MESSAGE("Value is not convertible to bool."); |
| 3322 | } |
| 3323 | |
| 3324 | bool Value::isConvertibleTo(ValueType other) const { |
| 3325 | switch (other) { |
no outgoing calls
no test coverage detected