@@ -34,26 +34,44 @@ class key_context;
3434class 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// /
3951template <class base = closed_context>
4052class 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
0 commit comments