1BSON_COPY_TO_EXCLUDING_NOINIT(3) libbson BSON_COPY_TO_EXCLUDING_NOINIT(3)
2
3
4
6 bson_copy_to_excluding_noinit - bson_copy_to_excluding_noinit()
7
9 void
10 bson_copy_to_excluding_noinit (const bson_t *src,
11 bson_t *dst,
12 const char *first_exclude,
13 ...) BSON_GNUC_NULL_TERMINATED;
14
16 • src: A bson_t.
17
18 • dst: A bson_t.
19
20 • first_exclude: The first field name to exclude.
21
23 The bson_copy_to_excluding_noinit() function shall copy all fields from
24 src to dst except those specified by the variadic, NULL terminated list
25 of keys starting from first_exclude. Works the same way as
26 bson_copy_to_excluding(), except does not call bson_init() on dst.
27 This function should be preferred in new code over
28 bson_copy_to_excluding().
29
30 WARNING:
31 This is generally not needed except in very special situations.
32
34 #include <bson/bson.h>
35
36 int main ()
37 {
38 bson_t bson;
39 bson_t bson2;
40 char *str;
41
42 bson_init (&bson);
43 bson_append_int32 (&bson, "a", 1, 1);
44 bson_append_int32 (&bson, "b", 1, 2);
45 bson_append_int32 (&bson, "c", 1, 2);
46
47 bson_init (&bson2);
48 bson_copy_to_excluding_noinit (&bson, &bson2, "b", NULL);
49
50 str = bson_as_json (&bson2, NULL);
51 /* Prints
52 * { "a" : 1, "c" : 2 }
53 */
54 printf ("%s\n", str);
55 bson_free (str);
56
57 bson_destroy (&bson);
58 bson_destroy (&bson2);
59 }
60
62 MongoDB, Inc
63
65 2017-present, MongoDB, Inc
66
67
68
69
701.24.3 Aug 17, 2023 BSON_COPY_TO_EXCLUDING_NOINIT(3)