@@ -119,12 +119,12 @@ class core::impl {
119
119
}
120
120
}
121
121
122
- void push_back_document (const char * key, std::size_t len) {
122
+ void push_back_document (const char * key, std::int32_t len) {
123
123
_depth++;
124
124
_stack.emplace_back (back (), key, len, false );
125
125
}
126
126
127
- void push_back_array (const char * key, std::size_t len) {
127
+ void push_back_array (const char * key, std::int32_t len) {
128
128
_depth++;
129
129
_stack.emplace_back (back (), key, len, true );
130
130
}
@@ -138,7 +138,8 @@ class core::impl {
138
138
// to be appended to start a new key/value pair.
139
139
stdx::string_view next_key () {
140
140
if (is_array ()) {
141
- _itoa_key = _stack.empty () ? _n++ : _stack.back ().n ++;
141
+ _itoa_key = _stack.empty () ? static_cast <std::uint32_t >(_n++)
142
+ : static_cast <std::uint32_t >(_stack.back ().n ++);
142
143
_user_key_view = stdx::string_view{_itoa_key.c_str (), _itoa_key.length ()};
143
144
} else if (!_has_user_key) {
144
145
throw bsoncxx::exception{error_code::k_need_key};
@@ -200,7 +201,7 @@ class core::impl {
200
201
201
202
private:
202
203
struct frame {
203
- frame (bson_t * parent, const char * key, std::size_t len, bool is_array)
204
+ frame (bson_t * parent, const char * key, std::int32_t len, bool is_array)
204
205
: n(0 ), is_array(is_array), parent(parent) {
205
206
if (is_array) {
206
207
bson_append_array_begin (parent, key, len, &bson);
@@ -269,16 +270,20 @@ core& core::key_owned(std::string key) {
269
270
core& core::append (const types::b_double& value) {
270
271
stdx::string_view key = _impl->next_key ();
271
272
272
- bson_append_double (_impl->back (), key.data (), key.length (), value.value );
273
+ bson_append_double (
274
+ _impl->back (), key.data (), static_cast <std::int32_t >(key.length ()), value.value );
273
275
274
276
return *this ;
275
277
}
276
278
277
279
core& core::append (const types::b_utf8& value) {
278
280
stdx::string_view key = _impl->next_key ();
279
281
280
- bson_append_utf8 (
281
- _impl->back (), key.data (), key.length (), value.value .data (), value.value .length ());
282
+ bson_append_utf8 (_impl->back (),
283
+ key.data (),
284
+ static_cast <std::int32_t >(key.length ()),
285
+ value.value .data (),
286
+ static_cast <std::int32_t >(value.value .length ()));
282
287
283
288
return *this ;
284
289
}
@@ -288,7 +293,7 @@ core& core::append(const types::b_document& value) {
288
293
bson_t bson;
289
294
bson_init_static (&bson, value.value .data (), value.value .length ());
290
295
291
- bson_append_document (_impl->back (), key.data (), key.length (), &bson);
296
+ bson_append_document (_impl->back (), key.data (), static_cast <std:: int32_t >( key.length () ), &bson);
292
297
293
298
return *this ;
294
299
}
@@ -298,7 +303,7 @@ core& core::append(const types::b_array& value) {
298
303
bson_t bson;
299
304
bson_init_static (&bson, value.value .data (), value.value .length ());
300
305
301
- bson_append_array (_impl->back (), key.data (), key.length (), &bson);
306
+ bson_append_array (_impl->back (), key.data (), static_cast <std:: int32_t >( key.length () ), &bson);
302
307
303
308
return *this ;
304
309
}
@@ -308,7 +313,7 @@ core& core::append(const types::b_binary& value) {
308
313
309
314
bson_append_binary (_impl->back (),
310
315
key.data (),
311
- key.length (),
316
+ static_cast <std:: int32_t >( key.length () ),
312
317
static_cast <bson_subtype_t >(value.sub_type ),
313
318
value.bytes ,
314
319
value.size );
@@ -319,7 +324,7 @@ core& core::append(const types::b_binary& value) {
319
324
core& core::append (const types::b_undefined&) {
320
325
stdx::string_view key = _impl->next_key ();
321
326
322
- bson_append_undefined (_impl->back (), key.data (), key.length ());
327
+ bson_append_undefined (_impl->back (), key.data (), static_cast <std:: int32_t >( key.length () ));
323
328
324
329
return *this ;
325
330
}
@@ -329,31 +334,33 @@ core& core::append(const types::b_oid& value) {
329
334
bson_oid_t oid;
330
335
std::memcpy (&oid.bytes , value.value .bytes (), sizeof (oid.bytes ));
331
336
332
- bson_append_oid (_impl->back (), key.data (), key.length (), &oid);
337
+ bson_append_oid (_impl->back (), key.data (), static_cast <std:: int32_t >( key.length () ), &oid);
333
338
334
339
return *this ;
335
340
}
336
341
337
342
core& core::append (const types::b_bool& value) {
338
343
stdx::string_view key = _impl->next_key ();
339
344
340
- bson_append_bool (_impl->back (), key.data (), key.length (), value.value );
345
+ bson_append_bool (
346
+ _impl->back (), key.data (), static_cast <std::int32_t >(key.length ()), value.value );
341
347
342
348
return *this ;
343
349
}
344
350
345
351
core& core::append (const types::b_date& value) {
346
352
stdx::string_view key = _impl->next_key ();
347
353
348
- bson_append_date_time (_impl->back (), key.data (), key.length (), value.to_int64 ());
354
+ bson_append_date_time (
355
+ _impl->back (), key.data (), static_cast <std::int32_t >(key.length ()), value.to_int64 ());
349
356
350
357
return *this ;
351
358
}
352
359
353
360
core& core::append (const types::b_null&) {
354
361
stdx::string_view key = _impl->next_key ();
355
362
356
- bson_append_null (_impl->back (), key.data (), key.length ());
363
+ bson_append_null (_impl->back (), key.data (), static_cast <std:: int32_t >( key.length () ));
357
364
358
365
return *this ;
359
366
}
@@ -363,7 +370,7 @@ core& core::append(const types::b_regex& value) {
363
370
364
371
bson_append_regex (_impl->back (),
365
372
key.data (),
366
- key.length (),
373
+ static_cast <std:: int32_t >( key.length () ),
367
374
value.regex .to_string ().data (),
368
375
value.options .to_string ().data ());
369
376
@@ -376,25 +383,34 @@ core& core::append(const types::b_dbpointer& value) {
376
383
bson_oid_t oid;
377
384
std::memcpy (&oid.bytes , value.value .bytes (), sizeof (oid.bytes ));
378
385
379
- bson_append_dbpointer (
380
- _impl->back (), key.data (), key.length (), value.collection .to_string ().data (), &oid);
386
+ bson_append_dbpointer (_impl->back (),
387
+ key.data (),
388
+ static_cast <std::int32_t >(key.length ()),
389
+ value.collection .to_string ().data (),
390
+ &oid);
381
391
382
392
return *this ;
383
393
}
384
394
385
395
core& core::append (const types::b_code& value) {
386
396
stdx::string_view key = _impl->next_key ();
387
397
388
- bson_append_code (_impl->back (), key.data (), key.length (), value.code .to_string ().data ());
398
+ bson_append_code (_impl->back (),
399
+ key.data (),
400
+ static_cast <std::int32_t >(key.length ()),
401
+ value.code .to_string ().data ());
389
402
390
403
return *this ;
391
404
}
392
405
393
406
core& core::append (const types::b_symbol& value) {
394
407
stdx::string_view key = _impl->next_key ();
395
408
396
- bson_append_symbol (
397
- _impl->back (), key.data (), key.length (), value.symbol .data (), value.symbol .length ());
409
+ bson_append_symbol (_impl->back (),
410
+ key.data (),
411
+ static_cast <std::int32_t >(key.length ()),
412
+ value.symbol .data (),
413
+ static_cast <std::int32_t >(value.symbol .length ()));
398
414
399
415
return *this ;
400
416
}
@@ -405,33 +421,41 @@ core& core::append(const types::b_codewscope& value) {
405
421
bson_t bson;
406
422
bson_init_static (&bson, value.scope .data (), value.scope .length ());
407
423
408
- bson_append_code_with_scope (
409
- _impl->back (), key.data (), key.length (), value.code .to_string ().data (), &bson);
424
+ bson_append_code_with_scope (_impl->back (),
425
+ key.data (),
426
+ static_cast <std::int32_t >(key.length ()),
427
+ value.code .to_string ().data (),
428
+ &bson);
410
429
411
430
return *this ;
412
431
}
413
432
414
433
core& core::append (const types::b_int32& value) {
415
434
stdx::string_view key = _impl->next_key ();
416
435
417
- bson_append_int32 (_impl->back (), key.data (), key.length (), value.value );
436
+ bson_append_int32 (
437
+ _impl->back (), key.data (), static_cast <std::int32_t >(key.length ()), value.value );
418
438
419
439
return *this ;
420
440
}
421
441
422
442
core& core::append (const types::b_timestamp& value) {
423
443
stdx::string_view key = _impl->next_key ();
424
444
425
- bson_append_timestamp (
426
- _impl->back (), key.data (), key.length (), value.increment , value.timestamp );
445
+ bson_append_timestamp (_impl->back (),
446
+ key.data (),
447
+ static_cast <std::int32_t >(key.length ()),
448
+ value.increment ,
449
+ value.timestamp );
427
450
428
451
return *this ;
429
452
}
430
453
431
454
core& core::append (const types::b_int64& value) {
432
455
stdx::string_view key = _impl->next_key ();
433
456
434
- bson_append_int64 (_impl->back (), key.data (), key.length (), value.value );
457
+ bson_append_int64 (
458
+ _impl->back (), key.data (), static_cast <std::int32_t >(key.length ()), value.value );
435
459
436
460
return *this ;
437
461
}
@@ -442,23 +466,24 @@ core& core::append(const types::b_decimal128& value) {
442
466
d128.high = value.value .high ();
443
467
d128.low = value.value .low ();
444
468
445
- bson_append_decimal128 (_impl->back (), key.data (), key.length (), &d128);
469
+ bson_append_decimal128 (
470
+ _impl->back (), key.data (), static_cast <std::int32_t >(key.length ()), &d128);
446
471
447
472
return *this ;
448
473
}
449
474
450
475
core& core::append (const types::b_minkey&) {
451
476
stdx::string_view key = _impl->next_key ();
452
477
453
- bson_append_minkey (_impl->back (), key.data (), key.length ());
478
+ bson_append_minkey (_impl->back (), key.data (), static_cast <std:: int32_t >( key.length () ));
454
479
455
480
return *this ;
456
481
}
457
482
458
483
core& core::append (const types::b_maxkey&) {
459
484
stdx::string_view key = _impl->next_key ();
460
485
461
- bson_append_maxkey (_impl->back (), key.data (), key.length ());
486
+ bson_append_maxkey (_impl->back (), key.data (), static_cast <std:: int32_t >( key.length () ));
462
487
463
488
return *this ;
464
489
}
@@ -526,15 +551,15 @@ core& core::append(bool value) {
526
551
core& core::open_document () {
527
552
stdx::string_view key = _impl->next_key ();
528
553
529
- _impl->push_back_document (key.data (), key.length ());
554
+ _impl->push_back_document (key.data (), static_cast <std:: int32_t >( key.length () ));
530
555
531
556
return *this ;
532
557
}
533
558
534
559
core& core::open_array () {
535
560
stdx::string_view key = _impl->next_key ();
536
561
537
- _impl->push_back_array (key.data (), key.length ());
562
+ _impl->push_back_array (key.data (), static_cast <std:: int32_t >( key.length () ));
538
563
539
564
return *this ;
540
565
}
@@ -550,7 +575,8 @@ core& core::concatenate(const bsoncxx::document::view& view) {
550
575
while (bson_iter_next (&iter)) {
551
576
stdx::string_view key = _impl->next_key ();
552
577
553
- bson_append_iter (_impl->back (), key.data (), key.length (), &iter);
578
+ bson_append_iter (
579
+ _impl->back (), key.data (), static_cast <std::int32_t >(key.length ()), &iter);
554
580
}
555
581
556
582
} else {
0 commit comments