bson_iter_utf8 (3) - Linux Manuals
bson_iter_utf8: The bson_iter_utf8() function shall retrieve the contents of a BSON_TYPE_UTF8 element currently observed by iter.
Command to display bson_iter_utf8
manual in Linux: $ man 3 bson_iter_utf8
NAME
bson_iter_utf8() - The bson_iter_utf8() function shall retrieve the contents of a BSON_TYPE_UTF8 element currently observed by iter.
SYNOPSIS
#define BSON_ITER_HOLDS_UTF8(iter) \
(bson_iter_type ((iter)) == BSON_TYPE_UTF8)
const char *
bson_iter_utf8 (const bson_iter_t *iter,
uint32_t *length);
PARAMETERS
- iter
-
A
bson_iter_t
\&.
- length
-
An optional location for the length of the resulting UTF-8 encoded string.
DESCRIPTION
The
bson_iter_utf8(3)
function shall retrieve the contents of a BSON_TYPE_UTF8 element currently observed by
iter
\&.
It is invalid to call this function while observing an element other than BSON_TYPE_UTF8.
RETURNS
A UTF-8 encoded string that has not been modified or freed.
It is suggested that the caller validate the content is valid UTF-8 before using this in other places. That can be done by calling
bson_utf8_validate(3)
or validating the underlying
bson_t
before iterating it.
Note that not all drivers use multi-byte representation for
\0
in UTF-8 encodings (commonly referred to as modified-UTF8). You probably want to take a look at the length field when marshaling to other runtimes.
COLOPHON
This page is part of libbson.
Please report any bugs at
https://jira.mongodb.org/browse/CDRIVER.
Pages related to bson_iter_utf8
- bson_iter_array (3) - The bson_iter_array() function shall retrieve the raw buffer of a sub-array from iter. iter MUST be on an element that is of type BSON_TYPE_ARRAY. This can be verified with bson_iter_type() or the BSON_ITER_HOLDS_ARRAY() macro.
- bson_iter_as_bool (3) - Fetches the current field as if it were a boolean.
- bson_iter_as_int64 (3) - The bson_iter_as_int64() function shall return the contents of the current element as if it were a BSON_TYPE_INT64 element. The currently supported casts include:
- bson_iter_binary (3) - This function shall return the binary data of a BSON_TYPE_BINARY element. It is a programming error to call this function on a field that is not of type BSON_TYPE_BINARY. You can check this with the BSON_ITER_HOLDS_BINARY() macro or bson_iter_type().
- bson_iter_bool (3) - The bson_iter_bool()function shall return the boolean value of a BSON_TYPE_BOOL element. It is a programming error to call this function on an element other than BSON_TYPE_BOOL. You can check this with bson_iter_type() or BSON_ITER_HOLDS_BOOL().
- bson_iter_code (3) - This function returns the contents of a BSON_TYPE_CODE field. The length of the string is stored in length if non-NULL.
- bson_iter_codewscope (3) - The bson_iter_codewscope() function acts similar to bson_iter_code() except for BSON_TYPE_CODEWSCOPE elements. It also will provide a pointer to the buffer for scope, which can be loaded into a bson_t using bson_init_static().
- bson_iter_date_time (3) - The bson_iter_date_time() function shall return the number of miliseconds since the UNIX epoch, as contained in the BSON_TYPE_DATE_TIME element.
- bson_iter_dbpointer (3) - Fetches the contents of a BSON_TYPE_DBPOINTER element.
- bson_iter_document (3) - The bson_iter_document() function shall retrieve the raw buffer of a sub-document from iter. iter MUST be on an element that is of type BSON_TYPE_DOCUMENT. This can be verified with bson_iter_type() or the BSON_ITER_HOLDS_DOCUMENT() macro.
- bson_iter_double (3) - Fetches the contents of a BSON_TYPE_DOUBLE field.
- bson_iter_dup_utf8 (3) - This function is similar to bson_iter_utf8() except that it calls bson_strndup() on the result.
- bson_iter_find (3) - The bson_iter_find()function shall advance iterto the element named keyor exhaust all elements of iter. If iteris exhausted, false is returned and itershould be considered invalid.
- bson_iter_find_case (3) - Advances iter until it is observing an element matching the name of key or exhausting all elements.