| 783 | } |
| 784 | |
| 785 | bool Value::asBool() const { |
| 786 | switch (type_) { |
| 787 | case booleanValue: |
| 788 | return value_.bool_; |
| 789 | case nullValue: |
| 790 | return false; |
| 791 | case intValue: |
| 792 | return value_.int_ ? true : false; |
| 793 | case uintValue: |
| 794 | return value_.uint_ ? true : false; |
| 795 | case realValue: |
| 796 | // This is kind of strange. Not recommended. |
| 797 | return (value_.real_ != 0.0) ? true : false; |
| 798 | default: |
| 799 | break; |
| 800 | } |
| 801 | JSON_FAIL_MESSAGE("Value is not convertible to bool."); |
| 802 | } |
| 803 | |
| 804 | bool Value::isConvertibleTo(ValueType other) const { |
| 805 | switch (other) { |
no outgoing calls
no test coverage detected