! @brief Parses a C-style string from the BSON input. @param[in,out] result A reference to the string variable where the read string is to be stored. @return `true` if the \x00-byte indicating the end of the string was encountered before the EOF; false` indicates an unexpected EOF. */
| 9265 | encountered before the EOF; false` indicates an unexpected EOF. |
| 9266 | */ |
| 9267 | bool get_bson_cstr(string_t& result) |
| 9268 | { |
| 9269 | auto out = std::back_inserter(result); |
| 9270 | while (true) |
| 9271 | { |
| 9272 | get(); |
| 9273 | if (JSON_HEDLEY_UNLIKELY(!unexpect_eof(input_format_t::bson, "cstring"))) |
| 9274 | { |
| 9275 | return false; |
| 9276 | } |
| 9277 | if (current == 0x00) |
| 9278 | { |
| 9279 | return true; |
| 9280 | } |
| 9281 | *out++ = static_cast<typename string_t::value_type>(current); |
| 9282 | } |
| 9283 | } |
| 9284 | |
| 9285 | /*! |
| 9286 | @brief Parses a zero-terminated string of length @a len from the BSON |