BSON_APPEND_AR...OM_VECTOR_INT8(3)
π BSON_APPEND_AR...OM_VECTOR_INT8 π
okay bestie, so this one lives in libbson (that's the manual name, not me being cute), and it's basically the glow-up ritual that turns a fancy Binary Vector into a boring old BSON Array. yes, we're demoting it. it's giving "graduated and got a corporate job". let's get into it β¨
β¨ SYNOPSIS β¨
here's the whole vibe, copied exactly so there's zero miscommunication:
#define BSON_APPEND_ARRAY_FROM_VECTOR_INT8(b, key, view) \
bson_append_array_from_vector_int8 (b, key, (int) strlen (key), view)
bool
bson_append_array_from_vector_int8 (bson_t *bson,
const char *key,
int key_length,
bson_vector_int8_const_view_t view);
so you've got the cute little macro wrapper up top β she does the strlen for you, no thoughts head empty, iconic β and then the real function underneath doing the actual work. main character energy fr fr π
πΈ PARAMETERS πΈ
okay so every single one of these matters, don't skip:
bsonβ abson_t. that's the doc you're writing into, your canvas, your little craft project πkeyβ an ASCII C string with the name of the field. yes ASCII specifically. keep it simple bestie, we're not doing emoji field names here (ironic coming from me, i know π)key_lengthβ how longkeyis in bytes, or-1if you want it to figure the length out withstrlen(). the "-1 means figure it out yourself" is such a mood, honestly π«Άviewβ abson_vector_int8_const_view_tpointing to validated int8 BSON Binary Vector subtype data. note the word validated, okay? that's the bouncer at the club. if it's not validated, you're not getting in π«
π¦ DESCRIPTION π¦
so basically: it converts the Vector that view is pointing at into a plain BSON Array, and writes that array into bson under the name key. that's it. that's the whole plot. no cap π
like, the fancy vector data goes in, a regular basic-b BSON Array comes out, gets a name tag, and gets tucked into your bson document. lowkey a makeover montage. slay π
β RETURNS β
it returns true if the operation was applied successfully. happy ending, everyone claps π
but heads up β it fails if appending that array makes bson grow larger than INT32_MAX. like, that's the hard ceiling, and it is not budging. if you hit it, that's not a vibe check you're passing, sorry π
fair warning bestie: INT32_MAX is the limit, and beyond it the function just fails. don't go acting surprised when the big doc says no π
π SEE ALSO π
bson_array_builder_append_vector_int8_elements()
go read that one too, iykyk π§
π AUTHOR π
MongoDB, Inc
π COPYRIGHT π
2009-present, MongoDB, Inc.
and that's the whole page, no notes π
okay so like, tiny sign-off β this masterpiece brought to you by libbson, version2.5.6, datedOct 09, 202(yes the date got cut off mid-number, that's just how the page renders, don't come for me π). drink water, validate your views, periodt. π
π¦ where this page comes from
- epel 10: libbson-devel 2.5.6-1.el10_3 Β· Apache-2.0 AND ISC AND MIT AND Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms