* Adds the number stored in number to state and modifies state. * returns true if addition happened (type was supported) * @state: The augend * @number: The addend * @overflowedFromInt64: Used for AddInt64ToValue(); set if overflow from Int64 occurs, unset otherwise. */
| 140 | * @overflowedFromInt64: Used for AddInt64ToValue(); set if overflow from Int64 occurs, unset otherwise. |
| 141 | */ |
| 142 | bool |
| 143 | AddNumberToBsonValue(bson_value_t *state, const bson_value_t *number, |
| 144 | bool *overflowedFromInt64) |
| 145 | { |
| 146 | if (!BsonValueIsNumberOrBool(state)) |
| 147 | { |
| 148 | return false; |
| 149 | } |
| 150 | |
| 151 | switch (number->value_type) |
| 152 | { |
| 153 | case BSON_TYPE_INT64: |
| 154 | { |
| 155 | AddInt64ToValue(state, number->value.v_int64, overflowedFromInt64); |
| 156 | return true; |
| 157 | } |
| 158 | |
| 159 | case BSON_TYPE_INT32: |
| 160 | { |
| 161 | AddInt32ToValue(state, number->value.v_int32, overflowedFromInt64); |
| 162 | return true; |
| 163 | } |
| 164 | |
| 165 | case BSON_TYPE_DOUBLE: |
| 166 | { |
| 167 | AddDoubleToValue(state, number->value.v_double); |
| 168 | return true; |
| 169 | } |
| 170 | |
| 171 | case BSON_TYPE_DECIMAL128: |
| 172 | { |
| 173 | AddDecimal128ToValue(state, number); |
| 174 | return true; |
| 175 | } |
| 176 | |
| 177 | default: |
| 178 | { |
| 179 | return false; |
| 180 | } |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | |
| 185 | /* |
no test coverage detected