| 9321 | */ |
| 9322 | template<typename NumberType> |
| 9323 | bool get_bson_binary(const NumberType len, binary_t& result) |
| 9324 | { |
| 9325 | if (JSON_HEDLEY_UNLIKELY(len < 0)) |
| 9326 | { |
| 9327 | auto last_token = get_token_string(); |
| 9328 | return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, |
| 9329 | exception_message(input_format_t::bson, concat("byte array length cannot be negative, is ", std::to_string(len)), "binary"), nullptr)); |
| 9330 | } |
| 9331 | |
| 9332 | // All BSON binary values have a subtype |
| 9333 | std::uint8_t subtype{}; |
| 9334 | get_number<std::uint8_t>(input_format_t::bson, subtype); |
| 9335 | result.set_subtype(subtype); |
| 9336 | |
| 9337 | return get_binary(input_format_t::bson, len, result); |
| 9338 | } |
| 9339 | |
| 9340 | /*! |
| 9341 | @brief Read a BSON document element of the given @a element_type. |
nothing calls this directly
no test coverage detected