int64_t batch_size = 0;
if (BSON_ITER_HOLDS_INT32 (&iter) || BSON_ITER_HOLDS_INT64 (&iter) || BSON_ITER_HOLDS_DOUBLE (&iter)) {
value = bson_iter_as_int64 (&iter);
}
This is perfectly valid code, but is annoying to write bunch of times.
We should add two new macros:
- BSON_ITER_HOLDS_NUMBER()
- Checks int32, int64 & double
- BSON_ITER_HOLDS_INT()
- Checks for int32 & int64
We should probably also go and fix code to use these.