BSON_VECTOR_FLOAT32_CONST_VIEW_T(3)
π 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_tMUST be valid for the lifetime of the view π like, the whole entire time - and it is an error to modify the
bson_twhile 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 π«Ά
π COPYRIGHT π
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
- 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