Skip to content

Commit 6e3c2fd

Browse files
committed
CXX-796 Improve bsoncxx doc comments
Replaced doc todo's under bsoncxx with doc comments.
1 parent b9b2c18 commit 6e3c2fd

22 files changed

+559
-176
lines changed

src/bsoncxx/array/element.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ BSONCXX_INLINE_NAMESPACE_BEGIN
2727
namespace array {
2828

2929
///
30-
/// @todo document this class
30+
/// A variant view type that accesses values in serialized BSON arrays.
31+
///
32+
/// Element functions as a variant type, where the kind of the element can be
33+
/// interrogated by calling type() and a specific value can be extracted through
34+
/// get_X() accessors.
3135
///
3236
class BSONCXX_API element : private document::element {
3337
public:

src/bsoncxx/array/value.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ class BSONCXX_API value {
8383
BSONCXX_INLINE array::view view() const noexcept;
8484

8585
///
86-
/// @todo document this method
86+
/// Conversion operator that provides a view given a value.
87+
///
88+
/// @return A view over the value.
8789
///
8890
BSONCXX_INLINE operator array::view() const noexcept;
8991

src/bsoncxx/array/view.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ class BSONCXX_API view {
141141
};
142142

143143
///
144-
/// @todo document this class
144+
/// A mutable iterator over the contents of an array view.
145+
///
146+
/// This iterator type provides a mutable forward iterator interface to array
147+
/// view elements.
145148
///
146149
class BSONCXX_API view::iterator : public std::iterator<std::forward_iterator_tag, element> {
147150
public:
@@ -172,7 +175,10 @@ class BSONCXX_API view::iterator : public std::iterator<std::forward_iterator_ta
172175
};
173176

174177
///
175-
/// @todo document this class
178+
/// A const iterator over the contents of an array view.
179+
///
180+
/// This iterator type provides a const forward iterator interface to array
181+
/// view elements.
176182
///
177183
class BSONCXX_API view::const_iterator
178184
: public std::iterator<std::forward_iterator_tag, element, std::ptrdiff_t, const element*,

src/bsoncxx/builder/basic/array.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ class array : public sub_array {
4949
}
5050

5151
///
52-
/// @todo document this method
52+
/// Conversion operator that provides a view of the current builder
53+
/// contents.
54+
///
55+
/// @return A view of the current builder contents.
5356
///
5457
BSONCXX_INLINE operator bsoncxx::array::view() const {
5558
return view();

src/bsoncxx/builder/basic/document.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ class document : public sub_document {
4747
}
4848

4949
///
50-
/// @todo document this method
50+
/// Conversion operator that provides a view of the current builder
51+
/// contents.
52+
///
53+
/// @return A view of the current builder contents.
5154
///
5255
BSONCXX_INLINE operator bsoncxx::document::view() const {
5356
return view();

src/bsoncxx/builder/basic/sub_array.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class BSONCXX_API sub_array {
5555
}
5656

5757
///
58-
/// @todo document this method
58+
/// Inductive base-case for the variadic append(...)
5959
///
6060
BSONCXX_INLINE
6161
void append() {

src/bsoncxx/builder/basic/sub_document.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class BSONCXX_API sub_document {
5050
}
5151

5252
///
53-
/// @todo document this method
53+
/// Inductive base-case for the variadic append(...)
5454
///
5555
BSONCXX_INLINE
5656
void append() {

src/bsoncxx/builder/concatenate.hpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,20 @@ struct concatenate_doc {
3535
BSONCXX_INLINE ~concatenate_doc() = default;
3636

3737
///
38-
/// @todo document this method
38+
/// Conversion operator that provides a view of the wrapped concatenate
39+
/// document.
40+
///
41+
/// @return A view of the wrapped concatenate document.
3942
///
4043
BSONCXX_INLINE operator document::view() const {
4144
return doc;
4245
}
4346

4447
///
45-
/// @todo document this method
48+
/// Accessor that provides a view of the wrapped concatenate
49+
/// document.
50+
///
51+
/// @return A view of the wrapped concatenate document.
4652
///
4753
BSONCXX_INLINE document::view view() const {
4854
return doc;
@@ -61,14 +67,20 @@ struct concatenate_array {
6167
BSONCXX_INLINE ~concatenate_array() = default;
6268

6369
///
64-
/// @todo document this method
70+
/// Conversion operator that provides a view of the wrapped concatenate
71+
/// array.
72+
///
73+
/// @return A view of the wrapped concatenate array.
6574
///
6675
BSONCXX_INLINE operator array::view() const {
6776
return array;
6877
}
6978

7079
///
71-
/// @todo document this method
80+
/// Accessor that provides a view of the wrapped concatenate
81+
/// array.
82+
///
83+
/// @return A view of the wrapped concatenate array.
7284
///
7385
BSONCXX_INLINE array::view view() const {
7486
return array;

src/bsoncxx/builder/stream/array_context.hpp

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,44 @@ class key_context;
3434
class single_context;
3535

3636
///
37-
/// An internal class of builder::stream. Users should not use this directly.
37+
/// A stream context which expects any number of values.
38+
///
39+
/// The template argument can be used to hold additional information about
40+
/// containing documents or arrays. I.e. value_context<> implies that this array
41+
/// is a sub_array in a document, while array_context would indicated a sub_array
42+
/// in an array. These types can be nested, such that contextual parsing (for
43+
/// key/value pairs) and depth (to prevent an invalid array_close) are enforced
44+
/// by the type system.
45+
///
46+
/// I.e.
47+
/// builder << array_context << array_context << ...;
48+
///
49+
/// This builds a bson array with successively higher index keys
3850
///
3951
template <class base = closed_context>
4052
class array_context {
4153
public:
4254

4355
///
44-
/// @todo document this method
56+
/// Create an array_context given a core builder
57+
///
58+
/// @param core
59+
/// The core builder to orchestrate
4560
///
4661
BSONCXX_INLINE array_context(core* core) : _core(core) {
4762
}
4863

4964
///
50-
/// @todo document this method
65+
/// << operator for accepting a real value and appending it to the core
66+
/// builder.
67+
///
68+
/// @param t
69+
/// The value to append
5170
///
5271
template <class T>
5372
BSONCXX_INLINE typename std::enable_if<
5473
!(util::is_functor<T, void(array_context<>)>::value ||
5574
util::is_functor<T, void(single_context)>::value ||
56-
std::is_same<T, const close_document_type>::value ||
5775
std::is_same<typename std::remove_reference<T>::type, const finalize_type>::value),
5876
array_context>::type&
5977
operator<<(T&& t) {
@@ -62,7 +80,12 @@ class array_context {
6280
}
6381

6482
///
65-
/// @todo document this method
83+
/// << operator for accepting a callable of the form void(array_context) or
84+
/// void(single_context) and invoking it to perform 1 or more value appends
85+
/// to the core builder.
86+
///
87+
/// @param func
88+
/// The callback to invoke
6689
///
6790
template <typename Func>
6891
BSONCXX_INLINE typename std::enable_if<(util::is_functor<Func, void(array_context<>)>::value ||
@@ -74,7 +97,15 @@ class array_context {
7497
}
7598

7699
///
77-
/// @todo document this method
100+
/// << operator for finalizing the stream.
101+
///
102+
/// This operation finishes all processing necessary to fully encode the
103+
/// bson bytes and returns an owning value.
104+
///
105+
/// @param _
106+
/// A finalize_type token
107+
///
108+
/// @return A value type which holds the complete bson document.
78109
///
79110
template <typename T>
80111
BSONCXX_INLINE typename std::enable_if<
@@ -88,46 +119,64 @@ class array_context {
88119
}
89120

90121
///
91-
/// @todo document this method
122+
/// << operator for opening a new subdocument in the core builder.
123+
///
124+
/// @param _
125+
/// An open_document_type token
92126
///
93127
BSONCXX_INLINE key_context<array_context> operator<<(const open_document_type) {
94128
_core->open_document();
95129
return wrap_document();
96130
}
97131

98132
///
99-
/// @todo document this method
133+
/// << operator for concatenating another array.
134+
///
135+
/// This operation concatenates all of the values from the passed document
136+
/// into the current stream. Keys are adjusted to match the existing array.
137+
///
138+
/// @param array
139+
/// An array to concatenate
100140
///
101141
BSONCXX_INLINE array_context operator<<(concatenate_array array) {
102142
_core->concatenate(array.view());
103143
return *this;
104144
}
105145

106146
///
107-
/// @todo document this method
147+
/// << operator for opening a new subarray in the core builder.
148+
///
149+
/// @param _
150+
/// An open_document_type token
108151
///
109152
BSONCXX_INLINE array_context<array_context> operator<<(const open_array_type) {
110153
_core->open_array();
111154
return wrap_array();
112155
}
113156

114157
///
115-
/// @todo document this method
158+
/// << operator for closing a subarray in the core builder.
159+
///
160+
/// @param _
161+
/// A close_array_type token
116162
///
117163
BSONCXX_INLINE base operator<<(const close_array_type) {
118164
_core->close_array();
119165
return unwrap();
120166
}
121167

122168
///
123-
/// @todo document this method
169+
/// Conversion operator which provides a rooted array context given any
170+
/// stream currently in a nested array_context.
124171
///
125172
BSONCXX_INLINE operator array_context<>() {
126173
return array_context<>(_core);
127174
}
128175

129176
///
130-
/// @todo document this method
177+
/// Conversion operator for single_context.
178+
///
179+
/// @relatesalso single_context
131180
///
132181
BSONCXX_INLINE operator single_context();
133182

src/bsoncxx/builder/stream/closed_context.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ class core;
2525
namespace stream {
2626

2727
///
28-
/// An internal struct of builder::stream. Users should not use this directly.
28+
/// The closed_context, when used as a template parameter for array_context,
29+
/// value_context or key_context, indicates that the document cannot be closed
30+
/// further. This could indicate that the document is the root, or that the type
31+
/// stack has been intentionally erased, as is the case when using callbacks in
32+
/// the stream api.
2933
///
3034
struct closed_context {
3135
closed_context(core*) {

0 commit comments

Comments
 (0)