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

Function write_element_name

src/seria/KVBinaryOutputStream.cpp:38–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36}
37
38void 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
54size_t write_array_size(IOutputStream &s, size_t val) {
55 if (val <= 63)

Callers 1

write_element_prefixMethod · 0.85

Calls 3

sizeMethod · 0.45
writeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected