BSON_ITER_CODE(3)

πŸ’– BSON_ITER_CODE(3) πŸ’–

okay so this is a libbson manpage, bestie β€” it's giving "how do I get the code string out of a BSON iterator" and honestly it's so simple it's iconic ✨


🌸 SYNOPSIS 🌸

like, here's the whole vibe in code form:

#define BSON_ITER_HOLDS_CODE(iter) (bson_iter_type ((iter)) == BSON_TYPE_CODE)

const char *
bson_iter_code (const bson_iter_t *iter, uint32_t *length);

no cap, that macro is literally just a vibe check on the iterator type 🫢


πŸŽ€ PARAMETERS πŸŽ€

  • iter β€” a bson_iter_t. that's your iterator, your main character 🌟
  • length β€” a location to stash the length of the UTF-8 encoded string… or NULL if you literally don't care about the length. your call, queen πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

so bson_iter_code() hands you back the contents of a BSON_TYPE_CODE field. that's it, that's the whole function πŸŽ‰

the length of the string gets stashed in length β€” but only if length is non-NULL. if you passed NULL, she just doesn't bother. respect πŸ’œ

⚠️ the tea: it is invalid to call this function on a field that is not of type BSON_TYPE_CODE. like, do not do that. check with BSON_ITER_HOLDS_CODE(iter) first, or you're gonna have a bad time πŸ˜­πŸ’€

⭐ RETURNS ⭐

a UTF-8 encoded string 🧚 and listen β€” this string should not be modified or freed. it's not yours, bestie, don't touch it, don't free it, just look at it and appreciate it πŸ™ˆβœ¨


πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc β€” the icons themselves πŸ’–

2009-present, MongoDB, Inc. β€” periodt, protect the copyright 🫢


okay that's the whole page, ily bestie, go forth and read those BSON_TYPE_CODE fields responsibly πŸ“

libbson 2.5.6 Β· Oct 09, 2026 β€” mwah, catch you on the next manpage πŸ’‹πŸŽ€

πŸ“¦ where this page comes from