BSON_ITER_ARRAY(3)

okay so bestie, this is BSON_ITER_ARRAY(3) from libbson πŸ’– β€” the manual page for grabbing the raw buffer of a sub-array out of an iterator, and it’s honestly giving β€œsmall but mighty.” Let’s get into it. ✨

πŸ’– SYNOPSIS πŸ’–

First, the macro that is basically the vibe check:

#define BSON_ITER_HOLDS_ARRAY(iter) (bson_iter_type ((iter)) == BSON_TYPE_ARRAY)

Then the function signature, looking all official and everything:

          void
          bson_iter_array (const bson_iter_t *iter,
                           uint32_t *array_len,
                           const uint8_t **array);

πŸŽ€ PARAMETERS πŸŽ€

  • iter β€” a bson_iter_t. That’s the iterator you’re working with, no cap.
  • array_len β€” a location for the buffer length. It’s where the length goes, bestie.
  • array β€” a location for the immutable buffer. That’s the spot for the buffer, and yes, it’s immutable.

πŸ’« DESCRIPTION πŸ’«

bson_iter_array() shall retrieve the raw buffer of a sub-array from iter. Like, the actual raw buffer, from the iterator, for a sub-array. Got it? πŸ’…

⚠️ iter MUST be on an element that is of type BSON_TYPE_ARRAY. This is not a drill. It literally has to be that type, or you’re not in the right place.

This can be verified with bson_iter_type() or the BSON_ITER_HOLDS_ARRAY() macro. So use one of those to check before you go off, okay? 🫢

🌈 AUTHOR 🌈

MongoDB, Inc β€” yes, that MongoDB, Inc. Slay. πŸ‘‘

2009-present, MongoDB, Inc. β€” periodt. πŸ’œ


okay bye bestie πŸ’… β€” this iconic page comes from libbson version 2.5.6, dated Oct 09, 2026, and it’s called BSON_ITER_ARRAY(3) πŸ’–

πŸ“¦ where this page comes from