| 439 | } |
| 440 | |
| 441 | void DartsDict::SerializeToFile(FILE* fp) const { |
| 442 | if (internal->doubleArray == nullptr) { |
| 443 | throw InvalidFormat( |
| 444 | "Cannot serialize a legacy 64-bit OCD dictionary; " |
| 445 | "rebuild via NewFromDict first"); |
| 446 | } |
| 447 | Darts::DoubleArray& dict = *internal->doubleArray; |
| 448 | |
| 449 | fwrite(OCDHEADER, sizeof(char), strlen(OCDHEADER), fp); |
| 450 | |
| 451 | // Write dartsSize as uint32_t so the file is platform-independent. |
| 452 | // id_type is fixed at uint32_t, so total_size() always fits in 32 bits. |
| 453 | uint32_t dartsSize = static_cast<uint32_t>(dict.total_size()); |
| 454 | fwrite(&dartsSize, sizeof(uint32_t), 1, fp); |
| 455 | fwrite(dict.array(), sizeof(char), dartsSize, fp); |
| 456 | |
| 457 | internal->binary.reset(new BinaryDict(lexicon)); |
| 458 | internal->binary->SerializeToFile(fp); |
| 459 | } |
nothing calls this directly
no test coverage detected