8649 {
8650 switch (element_type)
8651 {
8652 case 0x01:
8653 {
8654 double number{};
8655 return get_number<double, true>(input_format_t::bson, number) &&
sax->number_float(
static_cast<number_float_t
>(number),
"");
8656 }
8657
8658 case 0x02:
8659 {
8660 std::int32_t len{};
8662 return get_number<std::int32_t, true>(input_format_t::bson, len) &&
get_bson_string(len, value) &&
sax->string(value);
8663 }
8664
8665 case 0x03:
8666 {
8668 }
8669
8670 case 0x04:
8671 {
8673 }
8674
8675 case 0x05:
8676 {
8677 std::int32_t len{};
8679 return get_number<std::int32_t, true>(input_format_t::bson, len) &&
get_bson_binary(len, value) &&
sax->binary(value);
8680 }
8681
8682 case 0x08:
8683 {
8684 return sax->boolean(
get() != 0);
8685 }
8686
8687 case 0x0A:
8688 {
8690 }
8691
8692 case 0x10:
8693 {
8694 std::int32_t
value{};
8695 return get_number<std::int32_t, true>(input_format_t::bson, value) &&
sax->number_integer(value);
8696 }
8697
8698 case 0x12:
8699 {
8700 std::int64_t
value{};
8701 return get_number<std::int64_t, true>(input_format_t::bson, value) &&
sax->number_integer(value);
8702 }
8703
8704 default:
8705 {
8706 std::array<char, 3> cr{{}};
8707 (std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(element_type));
8708 return sax->parse_error(element_type_parse_position, std::string(cr.data()),
parse_error::create(114, element_type_parse_position,
"Unsupported BSON record type 0x" + std::string(cr.data()), BasicJsonType()));
8709 }
8710 }
8711 }
bool get_bson_string(const NumberType len, string_t &result)
Parses a zero-terminated string of length len from the BSON input.
bool parse_bson_array()
Reads an array from the BSON input and passes it to the SAX-parser.
bool get_bson_binary(const NumberType len, binary_t &result)
Parses a byte array input of length len from the BSON input.
json_sax_t * sax
the SAX parser
bool parse_bson_internal()
Reads in a BSON-object and passes it to the SAX-parser.
char_int_type get()
get next character from the input
static parse_error create(int id_, const position_t &pos, const std::string &what_arg, const BasicJsonType &context)
create a parse error exception
@ value
the parser finished reading a JSON value