BSON_VECTOR_FLOAT32_CONST_VIEW_T(3)

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

πŸ’… BSON_VECTOR_FLOAT32_CONST_VIEW_T(3) β€” libbson

okay so bestie, welcome to the <bson/bson.h> cinematic universe 🎬 β€” this page is a reference to non-owned const BSON Binary data holding a valid Vector of float32 element type. that's the whole vibe. no cap. ✨


✨ SYNOPSIS ✨

drop this in and you're so back:

#include <bson/bson.h>

typedef struct bson_vector_float32_const_view_t {
   /*< private >*/
} bson_vector_float32_const_view_t;

that /*< private >*/ comment? yeah, it's giving "mind your business" πŸ’… the struct is opaque, bestie, the insides are not for you.


πŸŽ€ DESCRIPTION πŸŽ€

bson_vector_float32_const_view_t is a structure that acts as an opaque const reference to a block of memory that has been validated as a float32 vector. it's literally a little window into data you don't own πŸͺŸβœ¨

  • it is meant to be passed by value, and you can discard it at any time β€” no cleanup, no drama, she's low-maintenance 🧚
  • the contents of the structure should be considered private πŸ™ˆ don't go poking around in there, it's not your business
  • the bson_t MUST be valid for the lifetime of the view πŸ‘‘ like, the whole entire time
  • and it is an error to modify the bson_t while using the view πŸ’€ do not touch. do not edit. do not. i'm serious.
ngl this is the const-bestie version of the situation β€” it references memory it doesn't own, so if the underlying bson_t dips out of scope, your view is literally hanging out with nobody. keep the parent alive, periodt.

🌸 EXAMPLE 🌸

here's the moment, the main character energy, the code:

bson_iter_t iter;
bson_vector_float32_const_view_t view;

if (bson_iter_init_find (&iter, &doc, "vector") && bson_vector_float32_const_view_from_iter (&view, &iter)) {
  size_t length = bson_vector_float32_const_view_length (view);
  printf ("Elements in 'vector':\n");
  for (size_t i = 0; i < length; i++) {
    float element;
    BSON_ASSERT (bson_vector_float32_const_view_read (view, &element, 1, i));
    printf (" [%d] = %f\n", (int) i, element);
  }
}

look at her go πŸ₯Ή find the field, pull out a view, grab the length, loop, read each element, print it. iconic behavior only.


πŸ¦‹ SEE ALSO πŸ¦‹

  • bson_vector_float32_view_t β€” the non-const sibling, aka the one allowed to touch things πŸ‘€

πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc β€” yes, the MongoDB girlies themselves 🫢


2009-present, MongoDB, Inc. β€” all the rights, reserved and slaying πŸ’–


and that's the page, bestie! πŸŽ€ this little writeup comes to you from libbson version 2.5.6, dated Oct 09 β€” go forth and view those floats responsibly, mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from