void flower_writeBinaryRepresentation(Flower *flower, void(*writeFn)(const void * ptr, size_t size, size_t count)) { Flower_SequenceIterator *sequenceIterator; Flower_EndIterator *endIterator; Flower_BlockIterator *blockIterator; Flower_GroupIterator *groupIterator; Flower_ChainIterator *chainIterator; Sequence *sequence; End *end; Block *block; Group *group; Chain *chain; binaryRepresentation_writeElementType(CODE_FLOWER, writeFn); binaryRepresentation_writeName(flower_getName(flower), writeFn); binaryRepresentation_writeBool(flower_builtBlocks(flower), writeFn); binaryRepresentation_writeBool(flower_builtTrees(flower), writeFn); binaryRepresentation_writeBool(flower_builtFaces(flower), writeFn); binaryRepresentation_writeName(flower->parentFlowerName, writeFn); if (flower_getEventTree(flower) != NULL) { eventTree_writeBinaryRepresentation(flower_getEventTree(flower), writeFn); } sequenceIterator = flower_getSequenceIterator(flower); while ((sequence = flower_getNextSequence(sequenceIterator)) != NULL) { sequence_writeBinaryRepresentation(sequence, writeFn); } flower_destructSequenceIterator(sequenceIterator); endIterator = flower_getEndIterator(flower); while ((end = flower_getNextEnd(endIterator)) != NULL) { end_writeBinaryRepresentation(end, writeFn); } flower_destructEndIterator(endIterator); blockIterator = flower_getBlockIterator(flower); while ((block = flower_getNextBlock(blockIterator)) != NULL) { block_writeBinaryRepresentation(block, writeFn); } flower_destructBlockIterator(blockIterator); groupIterator = flower_getGroupIterator(flower); while ((group = flower_getNextGroup(groupIterator)) != NULL) { group_writeBinaryRepresentation(group, writeFn); } flower_destructGroupIterator(groupIterator); chainIterator = flower_getChainIterator(flower); while ((chain = flower_getNextChain(chainIterator)) != NULL) { chain_writeBinaryRepresentation(chain, writeFn); } flower_destructChainIterator(chainIterator); binaryRepresentation_writeElementType(CODE_FLOWER, writeFn); //this avoids interpretting things wrong. }
void testBinaryRepresentation_bool(CuTest* testCase) { cactusSerialisationTestSetup(); void *vA2 = vA; bool i = 0; bool j = 1; binaryRepresentation_writeBool(i, writeFn); binaryRepresentation_writeBool(j, writeFn); CuAssertTrue(testCase, i == binaryRepresentation_getBool(&vA2)); CuAssertTrue(testCase, j == binaryRepresentation_getBool(&vA2)); cactusSerialisationTestTeardown(); }
void event_writeBinaryRepresentation(Event *event, void(*writeFn)( const void * ptr, size_t size, size_t count)) { binaryRepresentation_writeElementType(CODE_EVENT, writeFn); binaryRepresentation_writeName(event_getName(event_getParent(event)), writeFn); binaryRepresentation_writeName(event_getName(event), writeFn); binaryRepresentation_writeFloat(event_getBranchLength(event), writeFn); binaryRepresentation_writeString(event_getHeader(event), writeFn); binaryRepresentation_writeBool(event_isOutgroup(event), writeFn); }
static void cactusDisk_writeBinaryRepresentation(CactusDisk *cactusDisk, void (*writeFn)(const void * ptr, size_t size, size_t count)) { binaryRepresentation_writeElementType(CODE_CACTUS_DISK, writeFn); binaryRepresentation_writeBool(cactusDisk->storeSequencesInAFile, writeFn); if (cactusDisk->storeSequencesInAFile) { assert(cactusDisk->sequencesFileName != NULL); binaryRepresentation_writeString(cactusDisk->sequencesFileName, writeFn); } binaryRepresentation_writeElementType(CODE_CACTUS_DISK, writeFn); }
void metaSequence_writeBinaryRepresentation(MetaSequence *metaSequence, void (*writeFn)(const void * ptr, size_t size, size_t count)) { binaryRepresentation_writeElementType(CODE_META_SEQUENCE, writeFn); binaryRepresentation_writeName(metaSequence_getName(metaSequence), writeFn); binaryRepresentation_writeInteger(metaSequence_getStart(metaSequence), writeFn); binaryRepresentation_writeInteger(metaSequence_getLength(metaSequence), writeFn); binaryRepresentation_writeName(metaSequence_getEventName(metaSequence), writeFn); binaryRepresentation_writeName(metaSequence->stringName, writeFn); binaryRepresentation_writeString(metaSequence_getHeader(metaSequence), writeFn); binaryRepresentation_writeBool(metaSequence_isTrivialSequence(metaSequence), writeFn); }