MONGOC_URI_GET_OPTION_AS_INT32(3)
β¨ MONGOC_URI_GET_OPTION_AS_INT32 β¨
Okay bestie, so this one lives in the libmongoc manual, and it's genuinely one of those little helper functions that just gets it. Let's go π
πΈ SYNOPSIS πΈ
int32_t
mongoc_uri_get_option_as_int32 (const mongoc_uri_t *uri,
const char *option,
int32_t fallback);
π PARAMETERS π
- uri β a
mongoc_uri_t. The URI bestie in question, obvi. - option β the name of an option. And listen: it's case insensitive, so don't stress about the caps, she's chill like that. π
- fallback β a default value to return. Your little safety net. π«Ά
π¦ DESCRIPTION π¦
So what does she actually do? She returns the value of the URI option, but only if it's set and of the correct type (integer). If the option isn't set, is set to an invalid type, or is zero, she returns fallback. Periodt.
β οΈ Zero is considered "unset" β yes, literally, zero = no thoughts head empty. This is on purpose, so you can construct URIs like this and they'll still accept the default values:
bson_strdup_printf ("mongodb://localhost/?connectTimeoutMS=%d", myvalue)
So if myvalue is non-zero, that's your connection timeout, slay. If it's zero, the driver just uses the default timeout instead. Not me being obsessed with this pattern ngl, it's giving efficiency π
Also, heads up: when you're reading an option that's actually an int64, this function will return the value as int32_t. And if that value is outside the range of a 32-bit integer? π¨ A warning gets emitted and fallback is returned instead. So no silent chaos, she'll tell you.
π SEE ALSO π
mongoc_uri_get_option_as_int64()
π AUTHOR π
MongoDB, Inc β the blueprint, fr fr.
β COPYRIGHT β
2009-present, MongoDB, Inc.
Okay that's the whole vibe check, bestie π§ That was libmongoc version 2.5.6, dated Oct 09, 2026 β iconic, no notes, catch you in the next manpage πππ
π¦ where this page comes from
- epel 10: mongo-c-driver-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