| 36 | } |
| 37 | |
| 38 | void write_element_name(IOutputStream &s, common::StringView name) { |
| 39 | if (name.size() > 255) |
| 40 | throw std::runtime_error("Element name is too long"); |
| 41 | // When this happens first time (probably inside begin_map/end_map) |
| 42 | // We will have to add new BIN_KV_SERIALIZE_TYPE_OBJECT2 format with |
| 43 | // key length written like write_array_size. Unfortunately we have |
| 44 | // no way to make this long keys compatible with old format |
| 45 | auto len = static_cast<uint8_t>(name.size()); |
| 46 | s.write(&len, sizeof(len)); |
| 47 | s.write(name.data(), len); |
| 48 | if (verbose_debug) |
| 49 | std::cout << "write_element_name name=" << (std::string)name << std::endl; |
| 50 | if (verbose_tokens) |
| 51 | std::cout << "\"" << (std::string)name << "\"" << std::endl; |
| 52 | } |
| 53 | |
| 54 | size_t write_array_size(IOutputStream &s, size_t val) { |
| 55 | if (val <= 63) |
no test coverage detected