! @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
| 7893 | @return whether a valid BSON-object/array was passed to the SAX parser |
| 7894 | */ |
| 7895 | bool parse_bson_element_internal(const char_int_type element_type, |
| 7896 | const std::size_t element_type_parse_position) |
| 7897 | { |
| 7898 | switch (element_type) |
| 7899 | { |
| 7900 | case 0x01: // double |
| 7901 | { |
| 7902 | double number{}; |
| 7903 | return get_number<double, true>(input_format_t::bson, number) && sax->number_float(static_cast<number_float_t>(number), ""); |
| 7904 | } |
| 7905 | |
| 7906 | case 0x02: // string |
| 7907 | { |
| 7908 | std::int32_t len{}; |
| 7909 | string_t value; |
| 7910 | return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_string(len, value) && sax->string(value); |
| 7911 | } |
| 7912 | |
| 7913 | case 0x03: // object |
| 7914 | { |
| 7915 | return parse_bson_internal(); |
| 7916 | } |
| 7917 | |
| 7918 | case 0x04: // array |
| 7919 | { |
| 7920 | return parse_bson_array(); |
| 7921 | } |
| 7922 | |
| 7923 | case 0x05: // binary |
| 7924 | { |
| 7925 | std::int32_t len{}; |
| 7926 | binary_t value; |
| 7927 | return get_number<std::int32_t, true>(input_format_t::bson, len) && get_bson_binary(len, value) && sax->binary(value); |
| 7928 | } |
| 7929 | |
| 7930 | case 0x08: // boolean |
| 7931 | { |
| 7932 | return sax->boolean(get() != 0); |
| 7933 | } |
| 7934 | |
| 7935 | case 0x0A: // null |
| 7936 | { |
| 7937 | return sax->null(); |
| 7938 | } |
| 7939 | |
| 7940 | case 0x10: // int32 |
| 7941 | { |
| 7942 | std::int32_t value{}; |
| 7943 | return get_number<std::int32_t, true>(input_format_t::bson, value) && sax->number_integer(value); |
| 7944 | } |
| 7945 | |
| 7946 | case 0x12: // int64 |
| 7947 | { |
| 7948 | std::int64_t value{}; |
| 7949 | return get_number<std::int64_t, true>(input_format_t::bson, value) && sax->number_integer(value); |
| 7950 | } |
| 7951 | |
| 7952 | default: // anything else not supported (yet) |
nothing calls this directly
no test coverage detected