MCPcopy Create free account
hub / github.com/apple/foundationdb / serialize

Method serialize

flow/include/flow/ObjectSerializer.h:213–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

211 }
212 template <class... Items>
213 void serialize(FileIdentifier file_identifier, Items const&... items) {
214 int allocations = 0;
215 auto allocator = [this, &allocations](size_t size_) {
216 ++allocations;
217 this->size = writeProtocolVersion ? size_ + sizeof(uint64_t) : size_;
218 if (customAllocator) {
219 data = customAllocator(this->size);
220 } else {
221 data = new (arena) uint8_t[this->size];
222 }
223 if (writeProtocolVersion) {
224 auto v = protocolVersion().versionWithFlags();
225 memcpy(data, &v, sizeof(uint64_t));
226 return data + sizeof(uint64_t);
227 }
228 return data;
229 };
230 ASSERT(data == nullptr); // object serializer can only serialize one object
231 SaveContext<ObjectWriter, decltype(allocator)> context(this, allocator);
232 save_members(context, file_identifier, items...);
233 ASSERT(allocations == 1);
234 }
235
236 template <class Item>
237 void serialize(Item const& item) {

Callers 1

toValueMethod · 0.45

Calls 4

protocolVersionFunction · 0.85
memcpyFunction · 0.85
save_membersFunction · 0.85
serializeFunction · 0.85

Tested by

no test coverage detected