MCPcopy Create free account
hub / github.com/bcndev/bytecoin / begin_array

Method begin_array

src/seria/KVBinaryOutputStream.cpp:117–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117bool 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
137void KVBinaryOutputStream::end_array() {
138 bool valid_array = m_stack.back().state == State::Array;

Callers

nothing calls this directly

Calls 4

StringViewClass · 0.85
write_array_sizeFunction · 0.85
LevelClass · 0.70
writeMethod · 0.45

Tested by

no test coverage detected