BSON_APPEND_SYMBOL(3)
π BSON_APPEND_SYMBOL(3) π
okay so bestie, welcome to the libbson manual, page BSON_APPEND_SYMBOL(3) β yes the title is a whole mouthful, but honestly it's giving "tiny convenience macro with a big job" energy and we're gonna get through it together π
β¨ SYNOPSIS β¨
here's the whole thing, exactly as it lives in the header, no cap:
#define BSON_APPEND_SYMBOL(b, key, val) \
bson_append_symbol (b, key, (int) strlen (key), val, (int) strlen (val))
bool
bson_append_symbol (bson_t *bson,
const char *key,
int key_length,
const char *value,
int length);
so the macro is literally just a lil' wrapper that does the strlen() math for you so you don't have to, and the real grown-up function underneath is bson_append_symbol(). slay π
π¦ PARAMETERS π¦
okay so the cast of characters, let's meet them:
bsonβ Abson_t. that's the document you're stuffing stuff into, she's the main character here πkeyβ An ASCII C string containing the name of the field. like the label on the lil' box π·οΈkey_lengthβ The length ofkeyin bytes, or-1to determine the length withstrlen(). so-1is the "girl math it for me" option πvalueβ The symbol. this is the actual thing going in π¦lengthβ A length ofsymbolin bytes, or-1to determine the length withstrlen(). same deal,-1means letstrlen()handle it β¨
πΈ DESCRIPTION πΈ
so what does she do? Appends a new field to bson of type BSON_TYPE_SYMBOL. simple enough right?
β οΈ but bestie, listen to me: This BSON type is deprecated and should not be used in new code. like, she's iconic but she's also retired. we respect her legacy from a distance π
now here's the messy part. Due to legacy behavior, passing NULL for value appends a null value, not a symbol value. yeah. I know. π it's giving plot twist. so if what you actually want is a null value, please just do the normal thing β To append a null value directly, prefer using bson_append_null(). cleaner, safer, no weird legacy surprises π«Ά
β RETURNS β
Returns true if the operation was applied successfully π
but note β The function will fail if appending the value grows bson larger than INT32_MAX. so like, don't try to be extra with it, there's a size limit and she means it π
π§ AUTHOR π§
MongoDB, Inc β the legends themselves π
π COPYRIGHT π
2009-present, MongoDB, Inc. all the rights, reserved, periodt β¨
okay that's the whole page!! you made it, I'm so proud π₯Ή this was libbson version 2.5.6, dated Oct 09, 2026, signing off β go forth and don't use deprecated symbol types, mwah ππ
π¦ 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