@@ -50,7 +50,7 @@ value::value(b_string v) : value(v.value) {}
50
50
value::value (stdx::string_view v) : _impl{stdx::make_unique<impl>()} {
51
51
_impl->_value .value_type = BSON_TYPE_UTF8;
52
52
_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 () );
54
54
}
55
55
56
56
value::value (b_null) : value(nullptr ) {}
@@ -90,6 +90,25 @@ value::value(const type id) : _impl{stdx::make_unique<impl>()} {
90
90
case type::k_undefined:
91
91
_impl->_value .value_type = BSON_TYPE_UNDEFINED;
92
92
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:
93
112
default :
94
113
throw bsoncxx::v_noabi::exception (error_code::k_invalid_bson_type_id);
95
114
}
@@ -100,7 +119,8 @@ value::value(stdx::string_view regex, stdx::string_view options)
100
119
: _impl{stdx::make_unique<impl>()} {
101
120
_impl->_value .value_type = BSON_TYPE_REGEX;
102
121
_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);
104
124
}
105
125
106
126
value::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>
110
130
case type::k_regex:
111
131
_impl->_value .value_type = BSON_TYPE_REGEX;
112
132
_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 ;
114
134
break ;
115
135
case type::k_code:
116
136
_impl->_value .value_type = BSON_TYPE_CODE;
117
137
_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 () );
119
139
break ;
120
140
case type::k_symbol:
121
141
_impl->_value .value_type = BSON_TYPE_SYMBOL;
122
142
_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 () );
124
144
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:
125
164
default :
126
165
throw bsoncxx::v_noabi::exception (error_code::k_invalid_bson_type_id);
127
166
}
@@ -139,9 +178,29 @@ value::value(type id, uint64_t a, uint64_t b) : _impl{stdx::make_unique<impl>()}
139
178
break ;
140
179
case type::k_timestamp:
141
180
_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) ;
144
183
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:
145
204
default :
146
205
throw bsoncxx::v_noabi::exception (error_code::k_invalid_bson_type_id);
147
206
}
@@ -151,7 +210,7 @@ value::value(b_dbpointer v) : value(v.collection, v.value) {}
151
210
value::value (stdx::string_view collection, oid value) : _impl{stdx::make_unique<impl>()} {
152
211
_impl->_value .value_type = BSON_TYPE_DBPOINTER;
153
212
_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 () );
155
214
std::memcpy (_impl->_value .value .v_dbpointer .oid .bytes , value.bytes (), value.k_oid_length );
156
215
}
157
216
@@ -160,9 +219,10 @@ value::value(stdx::string_view code, bsoncxx::v_noabi::document::view_or_value s
160
219
: _impl{stdx::make_unique<impl>()} {
161
220
_impl->_value .value_type = BSON_TYPE_CODEWSCOPE;
162
221
_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 ()));
166
226
std::memcpy (
167
227
_impl->_value .value .v_codewscope .scope_data , scope.view ().data (), scope.view ().length ());
168
228
}
@@ -174,25 +234,25 @@ value::value(const uint8_t* data, size_t size, const binary_sub_type sub_type)
174
234
: _impl{stdx::make_unique<impl>()} {
175
235
_impl->_value .value_type = BSON_TYPE_BINARY;
176
236
_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) );
179
239
if (size)
180
240
std::memcpy (_impl->_value .value .v_binary .data , data, size);
181
241
}
182
242
183
243
value::value (b_document v) : value(v.view()) {}
184
244
value::value (bsoncxx::v_noabi::document::view v) : _impl{stdx::make_unique<impl>()} {
185
245
_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 () ));
188
248
std::memcpy (_impl->_value .value .v_doc .data , v.data (), v.length ());
189
249
}
190
250
191
251
value::value (b_array v) : value(v.value) {}
192
252
value::value (bsoncxx::v_noabi::array::view v) : _impl{stdx::make_unique<impl>()} {
193
253
_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 () ));
196
256
std::memcpy (_impl->_value .value .v_doc .data , v.data (), v.length ());
197
257
}
198
258
@@ -215,7 +275,7 @@ value::value(const std::uint8_t* raw,
215
275
}
216
276
217
277
value::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) )) {}
219
279
220
280
value::value (const value& rhs) : value(&rhs._impl->_value) {}
221
281
0 commit comments