BSON Value Types#

<bson/types.h> (header file)#

Defines a type enumeration for BSON value types, as well as several utility types for holding BSON values.

Types#

Type Enumeration#

enum [[zero_initializable]] bson_type#

This enumeration corresponds to the types of BSON elements. Their numeric value is equal to the octet value that is encoded in the BSON data itself.

enumerator bson_type_eod = 0x00#
enumerator bson_type_double = 0x01#
enumerator bson_type_utf8 = 0x02#
enumerator bson_type_document = 0x03#
enumerator bson_type_array = 0x04#
enumerator bson_type_binary = 0x05#
enumerator bson_type_undefined = 0x06#
enumerator bson_type_oid = 0x07#
enumerator bson_type_bool = 0x08#
enumerator bson_type_date_time = 0x09#
enumerator bson_type_null = 0x0A#
enumerator bson_type_regex = 0x0B#
enumerator bson_type_dbpointer = 0x0C#
enumerator bson_type_code = 0x0D#
enumerator bson_type_symbol = 0x0E#
enumerator bson_type_codewscope = 0x0F#
enumerator bson_type_int32 = 0x10#
enumerator bson_type_timestamp = 0x11#
enumerator bson_type_int64 = 0x12#
enumerator bson_type_decimal128 = 0x13#
enumerator bson_type_maxkey = 0x7F#
enumerator bson_type_minkey = 0xFF#

Element Value Types#

The following custom struct types are defined for decoding certain element values.

struct [[zero_initializable]] bson_eod#
struct [[zero_initializable]] bson_undefined#
struct [[zero_initializable]] bson_null#
struct [[zero_initializable]] bson_maxkey#
struct [[zero_initializable]] bson_minkey#

Empty struct types defined as placeholders for the BSON unit value types. The bson_eod struct is a special placeholder that represents the lack of value.

struct [[zero_initializable]] bson_binary_view#
const bson_byte *data;#
uint32_t data_len;#

Pointer to the binary data of the object, and the length of that data.

uint8_t subtype#

The binary data subtype tag

struct [[zero_initializable]] bson_oid#
uint8_t bytes[12]#

The twelve octets of the object ID

struct [[zero_initializable]] bson_dbpointer_view#
mlib_str_view collection#

The collection name

bson_oid object_id#

The object ID within the collection

struct [[zero_initializable]] bson_regex_view#
mlib_str_view regex#
mlib_str_view options#

The regular expression string and options string.

struct [[zero_initializable]] bson_timestamp#
uint32_t increment#
uint32_t timestamp#
struct [[zero_initializable]] bson_symbol_view#
mlib_str_view utf8#

The symbol spelling string

struct [[zero_initializable]] bson_code_view#
mlib_str_view utf8#

The code string

struct [[zero_initializable]] bson_decimal128#
uint8_t bytes[16]#
struct [[zero_initializable]] bson_datetime#
int64_t utf_ms_offset#

The offset from the Unix epoch as a count of milliseconds

using bson::null = ::bson_null#
using bson::undefined = ::bson_undefined#
using bson::minkey = ::bson_minkey#
using bson::maxkey = ::bson_maxkey#

Aliases of the C type within the bson namespace.