Skip to content

Commit b63d17a

Browse files
authored
CXX-3082 Add Comprehensive Examples (bsoncxx) (#1208)
* Silence common warnings in API examples * Add bsoncxx and mongocxx topic pages for guides and explanations * Add bsoncxx topic page for using BSON documents * Add BSON document usage examples * Add bsoncxx error handling examples * Add decimal128 examples * Add oid examples * Add validation examples * CXX-3101 Workaround missing features of mnmlstc/core polyfills * Refactor API examples to use component registration pattern * Ensure assertions in examples are always evaluated
1 parent daf2d38 commit b63d17a

File tree

109 files changed

+5804
-10
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+5804
-10
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Access an Array Element
2+
3+
## By Iteration
4+
5+
### Basic Example
6+
7+
@snippet api/bsoncxx/examples/bson_documents/access_array/basic.cpp Example
8+
9+
### Using Iterators
10+
11+
@snippet api/bsoncxx/examples/bson_documents/access_array/iterators.cpp Example
12+
13+
### Using Algorithms
14+
15+
@snippet api/bsoncxx/examples/bson_documents/access_array/algorithms.cpp Example
16+
17+
## By Key
18+
19+
### Using find()
20+
21+
@snippet api/bsoncxx/examples/bson_documents/access_array/find.cpp Example
22+
23+
### Using the Subscript Operator
24+
25+
@snippet api/bsoncxx/examples/bson_documents/access_array/subscript.cpp Example
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Access a Document Element
2+
3+
## By Iteration
4+
5+
### Basic Example
6+
7+
@snippet api/bsoncxx/examples/bson_documents/access_doc/basic.cpp Example
8+
9+
### Using Iterators
10+
11+
@snippet api/bsoncxx/examples/bson_documents/access_doc/iterators.cpp Example
12+
13+
### Using Algorithms
14+
15+
@snippet api/bsoncxx/examples/bson_documents/access_doc/algorithms.cpp Example
16+
17+
## By Key
18+
19+
### Using find()
20+
21+
@snippet api/bsoncxx/examples/bson_documents/access_doc/find.cpp Example
22+
23+
### Using the Subscript Operator
24+
25+
@snippet api/bsoncxx/examples/bson_documents/access_doc/subscript.cpp Example
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Create an Array
2+
3+
## From a JSON String
4+
5+
### Basic Example
6+
7+
@snippet api/bsoncxx/examples/bson_documents/create_array/json_basic.cpp Example
8+
9+
### With Extended JSON
10+
11+
@snippet api/bsoncxx/examples/bson_documents/create_array/json_extended.cpp Example
12+
13+
### With a Sub-Document
14+
15+
@snippet api/bsoncxx/examples/bson_documents/create_array/json_sub_document.cpp Example
16+
17+
### With a Sub-Array
18+
19+
@snippet api/bsoncxx/examples/bson_documents/create_array/json_sub_array.cpp Example
20+
21+
### With a User-Defined Literal
22+
23+
@snippet api/bsoncxx/examples/bson_documents/create_array/json_udl.cpp Example
24+
25+
## Using the Basic Builder
26+
27+
### Basic Example
28+
29+
@snippet api/bsoncxx/examples/bson_documents/create_array/builder_basic.cpp Example
30+
31+
### With make_document
32+
33+
@snippet api/bsoncxx/examples/bson_documents/create_array/builder_make_document.cpp Example
34+
35+
### With Multiple Appends
36+
37+
@snippet api/bsoncxx/examples/bson_documents/create_array/builder_append.cpp Example
38+
39+
### To Create Multiple Documents
40+
41+
@snippet api/bsoncxx/examples/bson_documents/create_array/builder_reset.cpp Example
42+
43+
### With a Value Type
44+
45+
@snippet api/bsoncxx/examples/bson_documents/create_array/builder_value_type.cpp Example
46+
47+
### With a BSON Type
48+
49+
@snippet api/bsoncxx/examples/bson_documents/create_array/builder_bson_type.cpp Example
50+
51+
### With a BSON Value
52+
53+
@snippet api/bsoncxx/examples/bson_documents/create_array/builder_bson_value.cpp Example
54+
55+
### With a Sub-Document
56+
57+
@snippet api/bsoncxx/examples/bson_documents/create_array/builder_sub_document.cpp Example
58+
59+
### With Multiple Sub-Document Appends
60+
61+
@snippet api/bsoncxx/examples/bson_documents/create_array/builder_sub_document_append.cpp Example
62+
63+
### With a Sub-Array
64+
65+
@snippet api/bsoncxx/examples/bson_documents/create_array/builder_sub_array.cpp Example
66+
67+
### With Multiple Sub-Array Appends
68+
69+
@snippet api/bsoncxx/examples/bson_documents/create_array/builder_sub_array_append.cpp Example
70+
71+
## From Raw Bytes
72+
73+
### As a View
74+
75+
@snippet api/bsoncxx/examples/bson_documents/create_array/builder_raw_view.cpp Example
76+
77+
### As a Value
78+
79+
@snippet api/bsoncxx/examples/bson_documents/create_array/builder_raw_value.cpp Example
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Create a Document
2+
3+
## From a JSON String
4+
5+
### Basic Example
6+
7+
@snippet api/bsoncxx/examples/bson_documents/create_doc/json_basic.cpp Example
8+
9+
### With Extended JSON
10+
11+
@snippet api/bsoncxx/examples/bson_documents/create_doc/json_extended.cpp Example
12+
13+
### With a Sub-Document
14+
15+
@snippet api/bsoncxx/examples/bson_documents/create_doc/json_sub_document.cpp Example
16+
17+
### With a Sub-Array
18+
19+
@snippet api/bsoncxx/examples/bson_documents/create_doc/json_sub_array.cpp Example
20+
21+
### With a User-Defined Literal
22+
23+
@snippet api/bsoncxx/examples/bson_documents/create_doc/json_udl.cpp Example
24+
25+
## Using the Basic Builder
26+
27+
### Basic Example
28+
29+
@snippet api/bsoncxx/examples/bson_documents/create_doc/builder_basic.cpp Example
30+
31+
### With make_document
32+
33+
@snippet api/bsoncxx/examples/bson_documents/create_doc/builder_make_document.cpp Example
34+
35+
### With Multiple Appends
36+
37+
@snippet api/bsoncxx/examples/bson_documents/create_doc/builder_append.cpp Example
38+
39+
### To Create Multiple Documents
40+
41+
@snippet api/bsoncxx/examples/bson_documents/create_doc/builder_reset.cpp Example
42+
43+
### With a Value Type
44+
45+
@snippet api/bsoncxx/examples/bson_documents/create_doc/builder_value_type.cpp Example
46+
47+
### With a BSON Type
48+
49+
@snippet api/bsoncxx/examples/bson_documents/create_doc/builder_bson_type.cpp Example
50+
51+
### With a BSON Value
52+
53+
@snippet api/bsoncxx/examples/bson_documents/create_doc/builder_bson_value.cpp Example
54+
55+
### With a Sub-Document
56+
57+
@snippet api/bsoncxx/examples/bson_documents/create_doc/builder_sub_document.cpp Example
58+
59+
### With Multiple Sub-Document Appends
60+
61+
@snippet api/bsoncxx/examples/bson_documents/create_doc/builder_sub_document_append.cpp Example
62+
63+
### With a Sub-Array
64+
65+
@snippet api/bsoncxx/examples/bson_documents/create_doc/builder_sub_array.cpp Example
66+
67+
### With Multiple Sub-Array Appends
68+
69+
@snippet api/bsoncxx/examples/bson_documents/create_doc/builder_sub_array_append.cpp Example
70+
71+
## From Raw Bytes
72+
73+
### As a View
74+
75+
@snippet api/bsoncxx/examples/bson_documents/create_doc/builder_raw_view.cpp Example
76+
77+
### As a Value
78+
79+
@snippet api/bsoncxx/examples/bson_documents/create_doc/builder_raw_value.cpp Example
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Query an Element
2+
3+
## In a Document
4+
5+
### For a Single Type
6+
7+
@snippet api/bsoncxx/examples/bson_documents/elements/doc_single.cpp Example
8+
9+
### For Multiple Types
10+
11+
@snippet api/bsoncxx/examples/bson_documents/elements/doc_multi.cpp Example
12+
13+
## In an Array
14+
15+
### For Single Type
16+
17+
@snippet api/bsoncxx/examples/bson_documents/elements/arr_single.cpp Example
18+
19+
### For Multiple Types
20+
21+
@snippet api/bsoncxx/examples/bson_documents/elements/arr_multi.cpp Example
22+
23+
## Comparison
24+
25+
### By Type
26+
27+
@snippet api/bsoncxx/examples/bson_documents/elements/cmp_type.cpp Example
28+
29+
### By BSON Value
30+
31+
@snippet api/bsoncxx/examples/bson_documents/elements/cmp_bson_value.cpp Example
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Convert to a JSON String
2+
3+
## From a Document
4+
5+
@snippet api/bsoncxx/examples/bson_documents/json/document.cpp Example
6+
7+
## From an Array
8+
9+
@snippet api/bsoncxx/examples/bson_documents/json/array.cpp Example
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Obtain a BSON Value
2+
3+
## From a BSON Type
4+
5+
### As a View
6+
7+
@snippet api/bsoncxx/examples/bson_documents/values/bson_type_view.cpp Example
8+
9+
### As a Value
10+
11+
@snippet api/bsoncxx/examples/bson_documents/values/bson_type_value.cpp Example
12+
13+
## From a Document Element
14+
15+
### As a View
16+
17+
@snippet api/bsoncxx/examples/bson_documents/values/doc_view.cpp Example
18+
19+
### As a Value
20+
21+
@snippet api/bsoncxx/examples/bson_documents/values/doc_value.cpp Example
22+
23+
## From an Array Element
24+
25+
### As a View
26+
27+
@snippet api/bsoncxx/examples/bson_documents/values/arr_view.cpp Example
28+
29+
### As a Value
30+
31+
@snippet api/bsoncxx/examples/bson_documents/values/arr_value.cpp Example
32+
33+
## From a Value Type
34+
35+
@snippet api/bsoncxx/examples/bson_documents/values/value_type.cpp Example
36+
37+
## With make_value
38+
39+
@snippet api/bsoncxx/examples/bson_documents/values/make_value.cpp Example

0 commit comments

Comments
 (0)