MCPcopy Create free account
hub / github.com/chrxh/alien / readGenome

Function readGenome

source/EngineInterface/GenomeDescriptionService.cpp:138–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136 }
137
138 std::variant<MakeGenomeCopy, std::vector<uint8_t>> readGenome(std::vector<uint8_t> const& data, int& pos)
139 {
140 std::variant<MakeGenomeCopy, std::vector<uint8_t>> result;
141
142 bool makeGenomeCopy = readBool(data, pos);
143 if (makeGenomeCopy) {
144 result = MakeGenomeCopy();
145 } else {
146 auto size = readWord(data, pos);
147 size = std::min(size, toInt(data.size()) - pos);
148 std::vector<uint8_t> copiedGenome;
149 copiedGenome.reserve(size);
150 for (int i = 0; i < size; ++i) {
151 copiedGenome.emplace_back(readByte(data, pos));
152 }
153 result = copiedGenome;
154 }
155 return result;
156 }
157}
158
159std::vector<uint8_t> GenomeDescriptionService::convertDescriptionToBytes(GenomeDescription const& genome, GenomeEncodingSpecification const& spec)

Callers 1

Calls 6

readBoolFunction · 0.85
MakeGenomeCopyClass · 0.85
readWordFunction · 0.85
toIntFunction · 0.85
readByteFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected