BSON_ITER_CODEWSCOPE(3)

Okay so this is the BSON_ITER_CODEWSCOPE(3) page from libbson, and it's literally here to help you handle code-with-scope iterator stuff without losing your mind πŸ’…βœ¨ Bestie, this one is niche but iconic.

✨ SYNOPSIS ✨

          #define BSON_ITER_HOLDS_CODEWSCOPE(iter) \
             (bson_iter_type ((iter)) == BSON_TYPE_CODEWSCOPE)

          const char *
          bson_iter_codewscope (const bson_iter_t *iter,
                                uint32_t *length,
                                uint32_t *scope_len,
                                const uint8_t **scope);

πŸ’– PARAMETERS πŸ’–

Here's the cast of characters, bestie 🫢:

  • iter β€” a bson_iter_t. This is the iterator you're working with.
  • length β€” an optional location for the length of the resulting UTF-8 encoded string. Optional, so no pressure.
  • scope_len β€” an optional location for the length of scope.
  • scope β€” an optional location to store the immutable raw scope BSON document. Immutable, so don't even think about editing it πŸ™ˆ

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so bson_iter_codewscope() acts similar to bson_iter_code(), except for BSON_TYPE_CODEWSCOPE elements. The way that it also will provide a pointer to the buffer for scope, which can be loaded into a bson_t using bson_init_static(). Slay.

🌈 RETURNS 🌈

An UTF-8 encoded string containing the JavaScript code. Do not modify it or free it β€” that's the rule, bestie 😭.

πŸ‘‘ AUTHOR πŸ‘‘

Author: MongoDB, Inc

Copyright: 2009-present, MongoDB, Inc.


Mwah πŸ’‹ β€” source libbson, version 2.5.6, dated Oct 09, 2026. That's the whole vibe check. 🫢

πŸ“¦ where this page comes from