1BSON_STRING_T(3) libbson BSON_STRING_T(3)
2
3
4
6 bson_string_t - bson_string_t
7
8 String Building Abstraction
9
11 #include <bson/bson.h>
12
13 typedef struct {
14 char *str;
15 uint32_t len;
16 uint32_t alloc;
17 } bson_string_t;
18
20 bson_string_t is an abstraction for building strings. As chunks are
21 added to the string, allocations are performed in powers of two.
22
23 This API is useful if you need to build UTF-8 encoded strings.
24
26 bson_string_t *str;
27
28 str = bson_string_new (NULL);
29 bson_string_append_printf (str, "%d %s %f\n", 0, "some string", 0.123);
30 printf ("%s\n", str->str);
31
32 bson_string_free (str, true);
33
34 TIP:
35 You can call bson_string_free() with false if you would like to take
36 ownership of str->str. Some APIs that do this might call return
37 bson_string_free (str, false); after building the string.
38
40 MongoDB, Inc
41
43 2017-present, MongoDB, Inc
44
45
46
47
481.16.2 Feb 25, 2020 BSON_STRING_T(3)