MCPcopy Create free account
hub / github.com/MihailRis/voxelcore / from_binary

Method from_binary

src/coders/binary_json.cpp:142–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142std::shared_ptr<Map> json::from_binary(const ubyte* src, size_t size) {
143 if (size < 2) {
144 throw std::runtime_error("bytes length is less than 2");
145 }
146 if (src[0] == gzip::MAGIC[0] && src[1] == gzip::MAGIC[1]) {
147 // reading compressed document
148 auto data = gzip::decompress(src, size);
149 return from_binary(data.data(), data.size());
150 } else {
151 ByteReader reader(src, size);
152 Value value = value_from_binary(reader);
153
154 if (auto map = std::get_if<Map_sptr>(&value)) {
155 return *map;
156 } else {
157 throw std::runtime_error("root value is not an object");
158 }
159 }
160}

Callers

nothing calls this directly

Calls 3

value_from_binaryFunction · 0.85
dataMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected