| 115 | } |
| 116 | |
| 117 | bool KVBinaryOutputStream::begin_array(size_t &size, bool fixed_size) { |
| 118 | write_element_prefix(BIN_KV_SERIALIZE_TYPE_ARRAY); |
| 119 | |
| 120 | m_stack.push_back(Level(common::StringView(""), size)); |
| 121 | if (verbose_debug) |
| 122 | std::cout << "begin_array size=" << size << std::endl; |
| 123 | if (size == 0) { |
| 124 | auto &s = stream(); |
| 125 | unsigned char c = |
| 126 | BIN_KV_SERIALIZE_FLAG_ARRAY | BIN_KV_SERIALIZE_TYPE_STRING; // we do not care which type is empty array |
| 127 | s.write(&c, 1); |
| 128 | write_array_size(s, size); |
| 129 | m_stack.back().state = State::Array; |
| 130 | // array_type is zero, so adding any element will lead to "Array elements types are non-uniform" logic error |
| 131 | if (verbose_tokens) |
| 132 | std::cout << "ARR t=" << int(BIN_KV_SERIALIZE_TYPE_STRING) << " c=" << size << std::endl; |
| 133 | } |
| 134 | return true; |
| 135 | } |
| 136 | |
| 137 | void KVBinaryOutputStream::end_array() { |
| 138 | bool valid_array = m_stack.back().state == State::Array; |
nothing calls this directly
no test coverage detected