SYNOPSIS

#include <bson.h>

typedef struct
{
   uint8_t bytes[12];
} bson_oid_t;

void
bson_oid_init (bson_oid_t * oid,
               bson_context_t * context);

void
bson_oid_init_from_data (bson_oid_t    *oid,
                         const uint8_t *data);

void
bson_oid_init_from_string (bson_oid_t *oid,
                           const char *str);

void
bson_oid_init_sequence (bson_oid_t     *oid,
                        bson_context_t *context);

DESCRIPTION

The bson_oid_init() function shall initialize oid by generating a new oid. context MAY be NULL to use the default bson_context_t.

The bson_oid_init_from_data() function shall initialize oid by using the 12 bytes supplied by data. data MUST be 12 bytes in size.

The bson_oid_init_from_string() function shall initialize oid by parsing the 24-character hex encoded string str.

The bson_oid_init_sequence() function shall initialize oid by generating a new oid in sequence form. This is generally only useful to intra-MongoDB server communication.

ERRORS

If str could not be parsed, bson_oid_init_from_string() will not be initialized. You can check the validity of a string by first validating it with bson_oid_is_valid().

AUTHORS

This page was written by MongoDB, Inc.