! @brief Read a BSON element list (as specified in the BSON-spec) The same binary layout is used for objects and arrays, hence it must be indicated with the argument @a is_array which one is expected (true --> array, false --> object). @param[in] is_array Determines if the element list being read is to be
| 7971 | @return whether a valid BSON-object/array was passed to the SAX parser |
| 7972 | */ |
| 7973 | bool parse_bson_element_list(const bool is_array) |
| 7974 | { |
| 7975 | string_t key; |
| 7976 | |
| 7977 | while (auto element_type = get()) |
| 7978 | { |
| 7979 | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson, "element list"))) |
| 7980 | { |
| 7981 | return false; |
| 7982 | } |
| 7983 | |
| 7984 | const std::size_t element_type_parse_position = chars_read; |
| 7985 | if (JSON_HEDLEY_UNLIKELY(!get_bson_cstr(key))) |
| 7986 | { |
| 7987 | return false; |
| 7988 | } |
| 7989 | |
| 7990 | if (!is_array && !sax->key(key)) |
| 7991 | { |
| 7992 | return false; |
| 7993 | } |
| 7994 | |
| 7995 | if (JSON_HEDLEY_UNLIKELY(!parse_bson_element_internal(element_type, element_type_parse_position))) |
| 7996 | { |
| 7997 | return false; |
| 7998 | } |
| 7999 | |
| 8000 | // get_bson_cstr only appends |
| 8001 | key.clear(); |
| 8002 | } |
| 8003 | |
| 8004 | return true; |
| 8005 | } |
| 8006 | |
| 8007 | /*! |
| 8008 | @brief Reads an array from the BSON input and passes it to the SAX-parser. |