@@ -50,7 +50,7 @@ value::value(b_string v) : value(v.value) {}
5050value::value (stdx::string_view v) : _impl{stdx::make_unique<impl>()} {
5151 _impl->_value .value_type = BSON_TYPE_UTF8;
5252 _impl->_value .value .v_utf8 .str = make_copy_for_libbson (v);
53- _impl->_value .value .v_utf8 .len = ( uint32_t ) v.size ();
53+ _impl->_value .value .v_utf8 .len = static_cast < uint32_t >( v.size () );
5454}
5555
5656value::value (b_null) : value(nullptr ) {}
@@ -90,6 +90,25 @@ value::value(const type id) : _impl{stdx::make_unique<impl>()} {
9090 case type::k_undefined:
9191 _impl->_value .value_type = BSON_TYPE_UNDEFINED;
9292 break ;
93+
94+ case type::k_double:
95+ case type::k_string:
96+ case type::k_document:
97+ case type::k_array:
98+ case type::k_binary:
99+ case type::k_oid:
100+ case type::k_bool:
101+ case type::k_date:
102+ case type::k_null:
103+ case type::k_regex:
104+ case type::k_dbpointer:
105+ case type::k_code:
106+ case type::k_symbol:
107+ case type::k_codewscope:
108+ case type::k_int32:
109+ case type::k_timestamp:
110+ case type::k_int64:
111+ case type::k_decimal128:
93112 default :
94113 throw bsoncxx::v_noabi::exception (error_code::k_invalid_bson_type_id);
95114 }
@@ -100,7 +119,8 @@ value::value(stdx::string_view regex, stdx::string_view options)
100119 : _impl{stdx::make_unique<impl>()} {
101120 _impl->_value .value_type = BSON_TYPE_REGEX;
102121 _impl->_value .value .v_regex .regex = make_copy_for_libbson (regex);
103- _impl->_value .value .v_regex .options = options.empty () ? NULL : make_copy_for_libbson (options);
122+ _impl->_value .value .v_regex .options =
123+ options.empty () ? nullptr : make_copy_for_libbson (options);
104124}
105125
106126value::value (b_code v) : value(v.type_id, v) {}
@@ -110,18 +130,37 @@ value::value(const type id, stdx::string_view v) : _impl{stdx::make_unique<impl>
110130 case type::k_regex:
111131 _impl->_value .value_type = BSON_TYPE_REGEX;
112132 _impl->_value .value .v_regex .regex = make_copy_for_libbson (v);
113- _impl->_value .value .v_regex .options = NULL ;
133+ _impl->_value .value .v_regex .options = nullptr ;
114134 break ;
115135 case type::k_code:
116136 _impl->_value .value_type = BSON_TYPE_CODE;
117137 _impl->_value .value .v_code .code = make_copy_for_libbson (v);
118- _impl->_value .value .v_code .code_len = ( uint32_t ) v.length ();
138+ _impl->_value .value .v_code .code_len = static_cast < uint32_t >( v.length () );
119139 break ;
120140 case type::k_symbol:
121141 _impl->_value .value_type = BSON_TYPE_SYMBOL;
122142 _impl->_value .value .v_symbol .symbol = make_copy_for_libbson (v);
123- _impl->_value .value .v_symbol .len = ( uint32_t ) v.length ();
143+ _impl->_value .value .v_symbol .len = static_cast < uint32_t >( v.length () );
124144 break ;
145+
146+ case type::k_double:
147+ case type::k_string:
148+ case type::k_document:
149+ case type::k_array:
150+ case type::k_binary:
151+ case type::k_undefined:
152+ case type::k_oid:
153+ case type::k_bool:
154+ case type::k_date:
155+ case type::k_null:
156+ case type::k_dbpointer:
157+ case type::k_codewscope:
158+ case type::k_int32:
159+ case type::k_timestamp:
160+ case type::k_int64:
161+ case type::k_decimal128:
162+ case type::k_maxkey:
163+ case type::k_minkey:
125164 default :
126165 throw bsoncxx::v_noabi::exception (error_code::k_invalid_bson_type_id);
127166 }
@@ -139,9 +178,29 @@ value::value(type id, uint64_t a, uint64_t b) : _impl{stdx::make_unique<impl>()}
139178 break ;
140179 case type::k_timestamp:
141180 _impl->_value .value_type = BSON_TYPE_TIMESTAMP;
142- _impl->_value .value .v_timestamp .increment = ( uint32_t )a ;
143- _impl->_value .value .v_timestamp .timestamp = ( uint32_t )b ;
181+ _impl->_value .value .v_timestamp .increment = static_cast < uint32_t >(a) ;
182+ _impl->_value .value .v_timestamp .timestamp = static_cast < uint32_t >(b) ;
144183 break ;
184+
185+ case type::k_double:
186+ case type::k_string:
187+ case type::k_document:
188+ case type::k_array:
189+ case type::k_binary:
190+ case type::k_undefined:
191+ case type::k_oid:
192+ case type::k_bool:
193+ case type::k_date:
194+ case type::k_null:
195+ case type::k_regex:
196+ case type::k_dbpointer:
197+ case type::k_code:
198+ case type::k_symbol:
199+ case type::k_codewscope:
200+ case type::k_int32:
201+ case type::k_int64:
202+ case type::k_maxkey:
203+ case type::k_minkey:
145204 default :
146205 throw bsoncxx::v_noabi::exception (error_code::k_invalid_bson_type_id);
147206 }
@@ -151,7 +210,7 @@ value::value(b_dbpointer v) : value(v.collection, v.value) {}
151210value::value (stdx::string_view collection, oid value) : _impl{stdx::make_unique<impl>()} {
152211 _impl->_value .value_type = BSON_TYPE_DBPOINTER;
153212 _impl->_value .value .v_dbpointer .collection = make_copy_for_libbson (collection);
154- _impl->_value .value .v_dbpointer .collection_len = ( uint32_t ) collection.length ();
213+ _impl->_value .value .v_dbpointer .collection_len = static_cast < uint32_t >( collection.length () );
155214 std::memcpy (_impl->_value .value .v_dbpointer .oid .bytes , value.bytes (), value.k_oid_length );
156215}
157216
@@ -160,9 +219,10 @@ value::value(stdx::string_view code, bsoncxx::v_noabi::document::view_or_value s
160219 : _impl{stdx::make_unique<impl>()} {
161220 _impl->_value .value_type = BSON_TYPE_CODEWSCOPE;
162221 _impl->_value .value .v_codewscope .code = make_copy_for_libbson (code);
163- _impl->_value .value .v_codewscope .code_len = (uint32_t )code.length ();
164- _impl->_value .value .v_codewscope .scope_len = (uint32_t )scope.view ().length ();
165- _impl->_value .value .v_codewscope .scope_data = (uint8_t *)bson_malloc (scope.view ().length ());
222+ _impl->_value .value .v_codewscope .code_len = static_cast <uint32_t >(code.length ());
223+ _impl->_value .value .v_codewscope .scope_len = static_cast <uint32_t >(scope.view ().length ());
224+ _impl->_value .value .v_codewscope .scope_data =
225+ static_cast <uint8_t *>(bson_malloc (scope.view ().length ()));
166226 std::memcpy (
167227 _impl->_value .value .v_codewscope .scope_data , scope.view ().data (), scope.view ().length ());
168228}
@@ -174,25 +234,25 @@ value::value(const uint8_t* data, size_t size, const binary_sub_type sub_type)
174234 : _impl{stdx::make_unique<impl>()} {
175235 _impl->_value .value_type = BSON_TYPE_BINARY;
176236 _impl->_value .value .v_binary .subtype = static_cast <bson_subtype_t >(sub_type);
177- _impl->_value .value .v_binary .data_len = ( uint32_t ) size;
178- _impl->_value .value .v_binary .data = ( uint8_t *) bson_malloc (size);
237+ _impl->_value .value .v_binary .data_len = static_cast < uint32_t >( size) ;
238+ _impl->_value .value .v_binary .data = static_cast < uint8_t *>( bson_malloc (size) );
179239 if (size)
180240 std::memcpy (_impl->_value .value .v_binary .data , data, size);
181241}
182242
183243value::value (b_document v) : value(v.view()) {}
184244value::value (bsoncxx::v_noabi::document::view v) : _impl{stdx::make_unique<impl>()} {
185245 _impl->_value .value_type = BSON_TYPE_DOCUMENT;
186- _impl->_value .value .v_doc .data_len = ( uint32_t ) v.length ();
187- _impl->_value .value .v_doc .data = ( uint8_t *) bson_malloc (v.length ());
246+ _impl->_value .value .v_doc .data_len = static_cast < uint32_t >( v.length () );
247+ _impl->_value .value .v_doc .data = static_cast < uint8_t *>( bson_malloc (v.length () ));
188248 std::memcpy (_impl->_value .value .v_doc .data , v.data (), v.length ());
189249}
190250
191251value::value (b_array v) : value(v.value) {}
192252value::value (bsoncxx::v_noabi::array::view v) : _impl{stdx::make_unique<impl>()} {
193253 _impl->_value .value_type = BSON_TYPE_ARRAY;
194- _impl->_value .value .v_doc .data_len = ( uint32_t ) v.length ();
195- _impl->_value .value .v_doc .data = ( uint8_t *) bson_malloc (v.length ());
254+ _impl->_value .value .v_doc .data_len = static_cast < uint32_t >( v.length () );
255+ _impl->_value .value .v_doc .data = static_cast < uint8_t *>( bson_malloc (v.length () ));
196256 std::memcpy (_impl->_value .value .v_doc .data , v.data (), v.length ());
197257}
198258
@@ -215,7 +275,7 @@ value::value(const std::uint8_t* raw,
215275}
216276
217277value::value (void * internal_value)
218- : _impl(stdx::make_unique<impl>(( bson_value_t *) internal_value)) {}
278+ : _impl(stdx::make_unique<impl>(static_cast < const bson_value_t *>( internal_value) )) {}
219279
220280value::value (const value& rhs) : value(&rhs._impl->_value) {}
221281
0 commit comments