| 2941 | } |
| 2942 | |
| 2943 | bool Value::asBool() const { |
| 2944 | switch (type_) { |
| 2945 | case booleanValue: |
| 2946 | return value_.bool_; |
| 2947 | case nullValue: |
| 2948 | return false; |
| 2949 | case intValue: |
| 2950 | return value_.int_ ? true : false; |
| 2951 | case uintValue: |
| 2952 | return value_.uint_ ? true : false; |
| 2953 | case realValue: |
| 2954 | // This is kind of strange. Not recommended. |
| 2955 | return (value_.real_ != 0.0) ? true : false; |
| 2956 | default: |
| 2957 | break; |
| 2958 | } |
| 2959 | JSON_FAIL_MESSAGE("Value is not convertible to bool."); |
| 2960 | } |
| 2961 | |
| 2962 | bool Value::isConvertibleTo(ValueType other) const { |
| 2963 | switch (other) { |
no outgoing calls
no test coverage detected