BSON_APPEND_VE...NT8_FROM_ARRAY(3)

πŸ“¦
version 2.5.6 Β· 3 versions
, in epel 10

πŸ’… BSON_APPEND_VECTOR_INT8_FROM_ARRAY(3) πŸ’…

Okay so bestie, this is the libbson page for BSON_APPEND_VECTOR_INT8_FROM_ARRAY, and it's literally about converting an array into a vector of int8s. It's giving "niche but iconic." Let's get into it. 🫢


✨ SYNOPSIS ✨

#define BSON_APPEND_VECTOR_INT8_FROM_ARRAY(b, key, iter, err) \
   bson_append_vector_int8_from_array (b, key, (int) strlen (key), iter, err)

bool
bson_append_vector_int8_from_array (bson_t *bson,
                                    const char *key,
                                    int key_length,
                                    const bson_iter_t *iter,
                                    bson_error_t *error);

πŸŽ€ PARAMETERS πŸŽ€

  • bson β€” A bson_t. It's the document you're appending to, bestie. Main character energy.
  • key β€” An ASCII C string containing the name of the field. Like, the field name. No cap.
  • key_length β€” The length of key in bytes, or -1 to determine the length with strlen(). Slay.
  • iter β€” A bson_iter_t referencing array elements that will be converted. It's the iterator, obviously.
  • error β€” Optional bson_error_t for detail about conversion failures. Optional but highkey useful. πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

Appends a new field to bson by converting an Array to a Vector of int8 elements. It's literally that simple.

For the conversion to succeed, every item in the Array must be an integer (BSON_TYPE_INT32 or BSON_TYPE_INT64) in the range INT8_MIN (-128) through INT8_MAX (127) inclusive. If any element has an incorrect type or an out-of-range value, the conversion fails with an error message providing details, and no changes are made to bson. Periodt. No partial updates, no messy vibes.

The provided iter must be positioned just prior to the first element of the BSON Array. If your input is a bare BSON Array, set up iter using bson_iter_init(). If the input is within a document field, use bson_iter_recurse().

Lowkey important: that iterator positioning is not a vibe check you can skip. Get it wrong and it's giving chaos. 😭

πŸ’– RETURNS πŸ’–

Returns true if the operation was applied successfully. On error, returns false and writes additional error information to error without modifying bson. The error will have a domain of BSON_ERROR_VECTOR and a code from bson_vector_error_code_t. That's the whole return situation, fr fr.


πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc


2009-present, MongoDB, Inc.


Okay bestie, that's the whole page. It's from libbson 2.5.6, dated Oct 09, 2024. Now go forth and slay those int8 vectors. πŸ’…βœ¨

πŸ“¦ where this page comes from