! @return The size of a BSON document entry header, including the id marker and the entry name size (and its null-terminator). */
| 13626 | and the entry name size (and its null-terminator). |
| 13627 | */ |
| 13628 | static std::size_t calc_bson_entry_header_size(const string_t& name) |
| 13629 | { |
| 13630 | const auto it = name.find(static_cast<typename string_t::value_type>(0)); |
| 13631 | if (JSON_HEDLEY_UNLIKELY(it != BasicJsonType::string_t::npos)) |
| 13632 | { |
| 13633 | JSON_THROW(out_of_range::create(409, |
| 13634 | "BSON key cannot contain code point U+0000 (at byte " + std::to_string(it) + ")")); |
| 13635 | } |
| 13636 | |
| 13637 | return /*id*/ 1ul + name.size() + /*zero-terminator*/1u; |
| 13638 | } |
| 13639 | |
| 13640 | /*! |
| 13641 | @brief Writes the given @a element_type and @a name to the output adapter |