Man page - bson_t(3)
Packages contas this manual
- bson_oid_equal_unsafe(3)
- bson_string_append_c(3)
- bson_oid_init_from_string_unsafe(3)
- bson_get_micro_version(3)
- bson_steal(3)
- bson_append_array(3)
- bson_writer_get_length(3)
- bson_oid_get_time_t(3)
- bson_iter_double(3)
- bson_append_timeval(3)
- bson_iter_regex(3)
- bson_decimal128_to_string(3)
- bson_iter_dbpointer(3)
- bson_init_static(3)
- bson_reserve_buffer(3)
- bson_type_t(3)
- bson_iter_find_w_len(3)
- bson_json_opts_set_outermost_array(3)
- bson_writer_end(3)
- bson_get_minor_version(3)
- bson_destroy_with_steal(3)
- bson_json_data_reader_new(3)
- bson_strdup_printf(3)
- bson_json_reader_new(3)
- bson_iter_overwrite_bool(3)
- bson_string_truncate(3)
- bson_reader_read_func_t(3)
- bson_init(3)
- bson_reader_tell(3)
- bson_unichar_t(3)
- bson_destroy(3)
- bson_ascii_strtoll(3)
- bson_realloc_ctx(3)
- bson_copy_to(3)
- bson_append_undefined(3)
- bson_iter_key_len(3)
- bson_reader_set_destroy_func(3)
- bson_iter_document(3)
- bson_iter_init_from_data(3)
- bson_json_reader_new_from_file(3)
- bson_append_code_with_scope(3)
- bson_malloc0(3)
- bson_append_array_end(3)
- bson_context_destroy(3)
- bson_iter_timestamp(3)
- bson_append_value(3)
- bson_iter_as_double(3)
- bson_append_utf8(3)
- bson_uint32_to_string(3)
- bson_check_version(3)
- bson_compare(3)
- bson_iter_symbol(3)
- bson_reinit(3)
- bson_as_legacy_extended_json(3)
- bson_iter_utf8(3)
- bson_iter_init(3)
- bson_append_now_utc(3)
- bson_writer_t(3)
- bson_iter_as_int64(3)
- bson_iter_type(3)
- bson_strcasecmp(3)
- bson_iter_date_time(3)
- bson_append_iter(3)
- bson_reader_set_read_func(3)
- bson_array_as_relaxed_extended_json(3)
- bson_oid_compare(3)
- bson_iter_dup_utf8(3)
- bson_append_array_begin(3)
- bson_strdup(3)
- bson_string_free(3)
- bson_iter_timeval(3)
- bson_iter_find(3)
- bson_writer_begin(3)
- bson_append_int32(3)
- bson_append_code(3)
- bson_equal(3)
- bson_append_oid(3)
- bson_get_major_version(3)
- bson_value_copy(3)
- bson_append_time_t(3)
- bson_iter_overwrite_int64(3)
- bson_iter_overwrite_date_time(3)
- bson_append_symbol(3)
- bson_iter_init_from_data_at_offset(3)
- bson_iter_int64(3)
- bson_oid_init_from_string(3)
- bson_append_dbpointer(3)
- bson_has_field(3)
- bson_json_reader_new_from_fd(3)
- bson_count_keys(3)
- bson_t(3)
- bson_strncpy(3)
- bson_validate_with_error_and_offset(3)
- bson_iter_offset(3)
- bson_iter_bool(3)
- bson_init_from_json(3)
- bson_new_from_data(3)
- bson_reader_new_from_data(3)
- bson_append_document_end(3)
- bson_malloc(3)
- bson_append_bool(3)
- bson_iter_oid(3)
- bson_iter_value(3)
- bson_json_reader_t(3)
- bson_as_canonical_extended_json(3)
- bson_append_document(3)
- bson_writer_rollback(3)
- bson_oid_copy_unsafe(3)
- bson_iter_overwrite_oid(3)
- bson_new(3)
- bson_oid_hash(3)
- bson_copy_to_excluding(3)
- bson_validate_flags_t(3)
- bson_append_double(3)
- bson_append_document_begin(3)
- bson_oid_copy(3)
- bson_iter_init_find_case(3)
- bson_oid_equal(3)
- bson_value_t(3)
- bson_iter_key(3)
- bson_aligned_alloc(3)
- bson_reader_destroy(3)
- bson_sized_new(3)
- bson_iter_init_find_w_len(3)
- bson_json_opts_t(3)
- bson_iter_array(3)
- bson_array_as_legacy_extended_json(3)
- bson_reader_read(3)
- bson_append_date_time(3)
- bson_iter_codewscope(3)
- bson_writer_destroy(3)
- bson_strdupv_printf(3)
- bson_iter_code(3)
- bson_iter_overwrite_int32(3)
- bson_utf8_get_char(3)
- bson_string_t(3)
- bson_memory(3)
- bson_zero_free(3)
- bson_validate(3)
- bson_append_regex(3)
- bson_set_error(3)
- bson_as_json(3)
- bson_copy(3)
- bson_decimal128_t(3)
- bson_reference(3)
- bson_array_as_json(3)
- bson_context_t(3)
- bson_get_version(3)
- bson_iter_binary(3)
- bson_iter_int32(3)
- bson_iter_find_descendant(3)
- bson_vsnprintf(3)
- bson_reader_new_from_fd(3)
- bson_json_mode_t(3)
- bson_visitor_t(3)
- bson_append_minkey(3)
- bson_array_as_canonical_extended_json(3)
- bson_get_monotonic_time(3)
- bson_append_binary(3)
- bson_string_append(3)
- bson_strfreev(3)
- bson_reader_new_from_handle(3)
- bson_string_append_unichar(3)
- bson_iter_as_bool(3)
- bson_subtype_t(3)
- bson_utf8_next_char(3)
- bson_utf8_escape_for_json(3)
- bson_append_timestamp(3)
- bson_oid_to_string(3)
- bson_iter_decimal128(3)
- bson_character_and_string_routines(3)
- bson_get_data(3)
- bson_writer_new(3)
- bson_json_opts_destroy(3)
- bson_reader_reset(3)
- bson_oid_init_from_data(3)
- bson_free(3)
- bson_utf8_from_unichar(3)
- bson_value_destroy(3)
- bson_oid_is_valid(3)
- bson_reader_new_from_file(3)
- bson_oid_compare_unsafe(3)
- bson_strndup(3)
- bson_array_builder_t(3)
- bson_append_null(3)
- bson_json_opts_new(3)
- bson_string_append_printf(3)
- bson_utf8_validate(3)
- bson_context_new(3)
- bson_iter_overwrite_double(3)
- bson_append_maxkey(3)
- bson_error_t(3)
- bson_iter_find_case(3)
- bson_mem_restore_vtable(3)
- bson_iter_overwrite_timestamp(3)
- bson_new_from_json(3)
- bson_oid_hash_unsafe(3)
- bson_append_regex_w_len(3)
- bson_iter_recurse(3)
- bson_append_int64(3)
- bson_reader_t(3)
- bson_oid_get_time_t_unsafe(3)
- bson_aligned_alloc0(3)
- bson_new_from_buffer(3)
- bson_copy_to_excluding_noinit_va(3)
- bson_version(3)
- bson_string_new(3)
- bson_validate_with_error(3)
- bson_json_data_reader_ingest(3)
- bson_strnlen(3)
- bson_iter_next(3)
- bson_realloc(3)
- bson_oid_init_sequence(3)
- bson_decimal128_from_string_w_len(3)
- bson_as_json_with_opts(3)
- bson_concat(3)
- bson_oid_t(3)
- bson_strerror_r(3)
- bson_reader_destroy_func_t(3)
- bson_snprintf(3)
- bson_as_relaxed_extended_json(3)
- bson_mem_set_vtable(3)
- bson_oid_init(3)
- bson_iter_init_find(3)
- bson_context_get_default(3)
- bson_isspace(3)
- bson_decimal128_from_string(3)
- bson_iter_visit_all(3)
- bson_iter_t(3)
- bson_copy_to_excluding_noinit(3)
- bson_append_decimal128(3)
- bson_realloc_func(3)
- bson_json_reader_destroy(3)
- bson_iter_overwrite_decimal128(3)
- bson_iter_time_t(3)
- bson_json_reader_read(3)
apt-get install libbson-doc
Manual
| BSON_T(3) | libbson | BSON_T(3) |
BSON Document Abstraction
SYNOPSIS
#include <bson/bson.h> /**
* bson_empty:
* @b: a bson_t.
*
* Checks to see if @b is an empty BSON document. An empty BSON document is
* a 5 byte document which contains the length (4 bytes) and a single NUL
* byte indicating end of fields.
*/ #define bson_empty(b) /* ... */ /**
* bson_empty0:
*
* Like bson_empty() but treats NULL the same as an empty bson_t document.
*/ #define bson_empty0(b) /* ... */ /**
* bson_clear:
*
* Easily free a bson document and set it to NULL. Use like:
*
* bson_t *doc = bson_new();
* bson_clear (&doc);
* BSON_ASSERT (doc == NULL);
*/ #define bson_clear(bptr) /* ... */ /**
* BSON_MAX_SIZE:
*
* The maximum size in bytes of a BSON document.
*/ #define BSON_MAX_SIZE /* ... */ #define BSON_APPEND_ARRAY(b, key, val) \
bson_append_array (b, key, (int) strlen (key), val) #define BSON_APPEND_ARRAY_BEGIN(b, key, child) \
bson_append_array_begin (b, key, (int) strlen (key), child) #define BSON_APPEND_BINARY(b, key, subtype, val, len) \
bson_append_binary (b, key, (int) strlen (key), subtype, val, len) #define BSON_APPEND_BOOL(b, key, val) \
bson_append_bool (b, key, (int) strlen (key), val) #define BSON_APPEND_CODE(b, key, val) \
bson_append_code (b, key, (int) strlen (key), val) #define BSON_APPEND_CODE_WITH_SCOPE(b, key, val, scope) \
bson_append_code_with_scope (b, key, (int) strlen (key), val, scope) #define BSON_APPEND_DBPOINTER(b, key, coll, oid) \
bson_append_dbpointer (b, key, (int) strlen (key), coll, oid) #define BSON_APPEND_DOCUMENT_BEGIN(b, key, child) \
bson_append_document_begin (b, key, (int) strlen (key), child) #define BSON_APPEND_DOUBLE(b, key, val) \
bson_append_double (b, key, (int) strlen (key), val) #define BSON_APPEND_DOCUMENT(b, key, val) \
bson_append_document (b, key, (int) strlen (key), val) #define BSON_APPEND_INT32(b, key, val) \
bson_append_int32 (b, key, (int) strlen (key), val) #define BSON_APPEND_INT64(b, key, val) \
bson_append_int64 (b, key, (int) strlen (key), val) #define BSON_APPEND_MINKEY(b, key) \
bson_append_minkey (b, key, (int) strlen (key)) #define BSON_APPEND_DECIMAL128(b, key, val) \
bson_append_decimal128 (b, key, (int) strlen (key), val) #define BSON_APPEND_MAXKEY(b, key) \
bson_append_maxkey (b, key, (int) strlen (key)) #define BSON_APPEND_NULL(b, key) bson_append_null (b, key, (int) strlen (key)) #define BSON_APPEND_OID(b, key, val) \
bson_append_oid (b, key, (int) strlen (key), val) #define BSON_APPEND_REGEX(b, key, val, opt) \
bson_append_regex (b, key, (int) strlen (key), val, opt) #define BSON_APPEND_UTF8(b, key, val) \
bson_append_utf8 (b, key, (int) strlen (key), val, (int) strlen (val)) #define BSON_APPEND_SYMBOL(b, key, val) \
bson_append_symbol (b, key, (int) strlen (key), val, (int) strlen (val)) #define BSON_APPEND_TIME_T(b, key, val) \
bson_append_time_t (b, key, (int) strlen (key), val) #define BSON_APPEND_TIMEVAL(b, key, val) \
bson_append_timeval (b, key, (int) strlen (key), val) #define BSON_APPEND_DATE_TIME(b, key, val) \
bson_append_date_time (b, key, (int) strlen (key), val) #define BSON_APPEND_TIMESTAMP(b, key, val, inc) \
bson_append_timestamp (b, key, (int) strlen (key), val, inc) #define BSON_APPEND_UNDEFINED(b, key) \
bson_append_undefined (b, key, (int) strlen (key)) #define BSON_APPEND_VALUE(b, key, val) \
bson_append_value (b, key, (int) strlen (key), (val)) BSON_ALIGNED_BEGIN (128) typedef struct {
uint32_t flags; /* Internal flags for the bson_t. */
uint32_t len; /* Length of BSON data. */
uint8_t padding[120]; /* Padding for stack allocation. */ } bson_t BSON_ALIGNED_END (128);
DESCRIPTION
The bson_t structure represents a BSON document. This structure manages the underlying BSON encoded buffer. For mutable documents, it can append new data to the document.
PERFORMANCE NOTES
The bson_t structure attempts to use an inline allocation within the structure to speed up performance of small documents. When this internal buffer has been exhausted, a heap allocated buffer will be dynamically allocated. Therefore, it is essential to call bson_destroy() on allocated documents.
DUPLICATE KEYS
The BSON specification allows BSON documents to have duplicate keys. Documents are stored as an ordered list of key-value pairs. A bson_t may contain duplicate keys. Applications should refrain from generating such documents, because MongoDB server behavior is undefined when a BSON document contains duplicate keys.
EXAMPLE
static void
create_on_heap (void)
{
bson_t *b = bson_new ();
BSON_APPEND_INT32 (b, "foo", 123);
BSON_APPEND_UTF8 (b, "bar", "foo");
BSON_APPEND_DOUBLE (b, "baz", 1.23f);
bson_destroy (b);
}
AUTHOR
MongoDB, Inc
COPYRIGHT
2009-present, MongoDB, Inc.
| December 18, 2025 | 1.30.4 |