Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-1542

Add BSON_ITER_HOLDS_NUMBER() & BSON_ITER_HOLDS_INT()

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.7.0
    • Affects Version/s: None
    • Component/s: libbson
    • Labels:
      None

      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.

            Assignee:
            bjori Hannes Magnusson
            Reporter:
            bjori Hannes Magnusson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: