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 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 eventTree_writeBinaryRepresentation(EventTree *eventTree, void (*writeFn)(const void * ptr, size_t size, size_t count)) { int64_t i; Event *event; event = eventTree_getRootEvent(eventTree); binaryRepresentation_writeElementType(CODE_EVENT_TREE, writeFn); binaryRepresentation_writeName(event_getName(event), writeFn); for(i=0; i<event_getChildNumber(event); i++) { eventTree_writeBinaryRepresentationP(event_getChild(event, i), writeFn); } binaryRepresentation_writeElementType(CODE_EVENT_TREE, writeFn); }
void testBinaryRepresentation_elementType(CuTest* testCase) { cactusSerialisationTestSetup(); void *vA2 = vA; binaryRepresentation_writeElementType(CODE_ADJACENCY, writeFn); binaryRepresentation_writeElementType(CODE_LINK, writeFn); CuAssertTrue(testCase, binaryRepresentation_peekNextElementType(vA2) == CODE_ADJACENCY); CuAssertTrue(testCase, binaryRepresentation_popNextElementType(&vA2) == CODE_ADJACENCY); CuAssertTrue(testCase, binaryRepresentation_peekNextElementType(vA2) == CODE_LINK); CuAssertTrue(testCase, binaryRepresentation_popNextElementType(&vA2) == CODE_LINK); 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); }
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); }
void sequence_writeBinaryRepresentation(Sequence *sequence, void (*writeFn)(const void * ptr, size_t size, size_t count)) { binaryRepresentation_writeElementType(CODE_SEQUENCE, writeFn); binaryRepresentation_writeName(sequence_getName(sequence), writeFn); }