| 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) { |
no test coverage detected