| 865 | } |
| 866 | |
| 867 | bool Value::asBool() const { |
| 868 | switch (type_) { |
| 869 | case booleanValue: |
| 870 | return value_.bool_; |
| 871 | case nullValue: |
| 872 | return false; |
| 873 | case intValue: |
| 874 | return value_.int_ ? true : false; |
| 875 | case uintValue: |
| 876 | return value_.uint_ ? true : false; |
| 877 | case realValue: |
| 878 | // This is kind of strange. Not recommended. |
| 879 | return (value_.real_ != 0.0) ? true : false; |
| 880 | default: |
| 881 | break; |
| 882 | } |
| 883 | JSON_FAIL_MESSAGE("Value is not convertible to bool."); |
| 884 | } |
| 885 | |
| 886 | bool Value::isConvertibleTo(ValueType other) const { |
| 887 | switch (other) { |
no outgoing calls
no test coverage detected