1BSON_OID_T(3)                       Libbson                      BSON_OID_T(3)
2
3
4

NAME

6       bson_oid_t - bson_oid_t
7
8       BSON ObjectID Abstraction
9

SYNOPSIS

11          #include <bson/bson.h>
12
13          typedef struct {
14             uint8_t bytes[12];
15          } bson_oid_t;
16

DESCRIPTION

18       The bson_oid_t structure contains the 12-byte ObjectId notation defined
19       by the BSON ObjectID specification.
20
21       ObjectId is a 12-byte BSON type, constructed using:
22
23       · a 4-byte value representing the seconds since the Unix epoch (in  Big
24         Endian)
25
26       · a 3-byte machine identifier
27
28       · a 2-byte process id (Big Endian), and
29
30       · a 3-byte counter (Big Endian), starting with a random value.
31

STRING CONVERSION

33       You can convert an Object ID to a string using bson_oid_to_string() and
34       back with bson_oid_init_from_string().
35

HASHING

37       A  bson_oid_t  can  be  used   in   hashtables   using   the   function
38       bson_oid_hash() and bson_oid_equal().
39

COMPARING

41       A  bson_oid_t  can  be compared to another using bson_oid_compare() for
42       qsort() style comparing and bson_oid_equal() for direct equality.
43

VALIDATING

45       You can validate that a string containing  a  hex-encoded  ObjectID  is
46       valid using the function bson_oid_is_valid().
47

EXAMPLE

49          #include <bson.h>
50          #include <stdio.h>
51
52          int
53          main (int argc, char *argv[])
54          {
55             bson_oid_t oid;
56             char str[25];
57
58             bson_oid_init (&oid, NULL);
59             bson_oid_to_string (&oid, str);
60             printf ("%s\n", str);
61
62             if (bson_oid_is_valid (str, sizeof str)) {
63                bson_oid_init_from_string (&oid, str);
64             }
65
66             printf ("The UNIX time was: %u\n", (unsigned) bson_oid_get_time_t (&oid));
67
68             return 0;
69          }
70

AUTHOR

72       MongoDB, Inc
73
75       2017-present, MongoDB, Inc
76
77
78
79
801.13.1                           Jan 24, 2019                    BSON_OID_T(3)
Impressum