! @brief Read a BSON document element of the given @a element_type. @param[in] element_type The BSON element type, c.f. http://bsonspec.org/spec.html @param[in] element_type_parse_position The position in the input stream, where the `element_type` was read. @warning Not all BSON element types are supported yet. An unsupported @a element_type will give rise to a parse_error.114: U
| 9344 | @return whether a valid BSON-object/array was passed to the SAX parser |
| 9345 | */ |
| 9346 | bool parse_bson_element_internal(const char_int_type element_type, |
| 9347 | const std::size_t element_type_parse_position) |
| 9348 | { |
| 9349 | switch (element_type) |
| 9350 | { |
| 9351 | case 0x01: // double |
| 9352 | { |
| 9353 | double number{}; |
| 9354 | return get_number<double, true>(input_format_t::bson, number) && sax->number_float(static_cast<number_float_t>(number), ""); |
| 9355 | } |
| 9356 | |
| 9357 | case 0x02: // string |
| 9358 | { |
| 9359 | std::int32_t len{}; |
| 9360 | string_t value; |
| 9361 | return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value); |
| 9362 | } |
| 9363 | |
| 9364 | case 0x03: // object |
| 9365 | { |
| 9366 | return parse_bson_internal(); |
| 9367 | } |
| 9368 | |
| 9369 | case 0x04: // array |
| 9370 | { |
| 9371 | return parse_bson_array(); |
| 9372 | } |
| 9373 | |
| 9374 | case 0x05: // binary |
| 9375 | { |
| 9376 | std::int32_t len{}; |
| 9377 | binary_t value; |
| 9378 | return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value); |
| 9379 | } |
| 9380 | |
| 9381 | case 0x08: // boolean |
| 9382 | { |
| 9383 | return sax->boolean(get() != 0); |
| 9384 | } |
| 9385 | |
| 9386 | case 0x0A: // null |
| 9387 | { |
| 9388 | return sax->null(); |
| 9389 | } |
| 9390 | |
| 9391 | case 0x10: // int32 |
| 9392 | { |
| 9393 | std::int32_t value{}; |
| 9394 | return get_number<std::int32_t, true>(input_format_t::bson, value) && sax->number_integer(value); |
| 9395 | } |
| 9396 | |
| 9397 | case 0x12: // int64 |
| 9398 | { |
| 9399 | std::int64_t value{}; |
| 9400 | return get_number<std::int64_t, true>(input_format_t::bson, value) && sax->number_integer(value); |
| 9401 | } |
| 9402 | |
| 9403 | default: // anything else not supported (yet) |
nothing calls this directly
no test coverage detected