QDomDocument *XmlWriter::toXml() { QDomImplementation implementation; QDomDocumentType docType = implementation.createDocumentType( "scribe-document", "scribe", "qt.nokia.com/scribe"); document = new QDomDocument(docType); // ### This processing instruction is required to ensure that any kind // of encoding is given when the document is written. QDomProcessingInstruction process = document->createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"utf-8\""); document->appendChild(process); QDomElement documentElement = document->createElement("document"); document->appendChild(documentElement); //! [0] QTextBlock currentBlock = textDocument->begin(); while (currentBlock.isValid()) { //! [0] QDomElement blockElement = document->createElement("block"); document->appendChild(blockElement); readFragment(currentBlock, blockElement, document); //! [1] processBlock(currentBlock); //! [1] //! [2] currentBlock = currentBlock.next(); } //! [2] return document; }
struct FragFile* readFragmentsv2(char* s,int* nf,uint64_t *xtotal,uint64_t *ytotal){ //Fragment* readFragments(char* s,int* nf,int *xtotal,int *ytotal){ FILE* fe; struct FragFile* fs; int n; if((fe=fopen(s,"rb"))==NULL){ printf("***ERROR Opening input file"); exit(-1); } /* if((fsalida=fopen("fragmentosv2.txt","w"))==NULL){ printf("Fallo al leer Fragmentos"); exit(-1); } */ n=0; // fread(xtotal,sizeof( uint64_t),1,fe); // fread(ytotal,sizeof( uint64_t),1,fe); readSequenceLength(xtotal, fe); readSequenceLength(ytotal, fe); long int longFile; fseek(fe,0,SEEK_END); longFile=ftell(fe); n=(int)(longFile-2*sizeof(uint64_t))/sizeof(struct FragFile); // n=(int)(longFile-2*sizeof(int))/sizeof(Fragment); //printf("\n ReadFragments Complete\nnum: %d\n",n); rewind(fe); fs=(struct FragFile*)malloc(sizeof(struct FragFile)*(n+1)); if(fs==NULL){ printf("****ERROR: Out of memory\n"); exit(-1); } //*nf=n-1; *nf=n; n=0; // fread(xtotal,sizeof( uint64_t),1,fe); // fread(ytotal,sizeof( uint64_t),1,fe); readSequenceLength(xtotal, fe); readSequenceLength(ytotal, fe); // while(!feof(fe)){ for(n=0;n<*nf;n++){ readFragment(&fs[n], fe); //fprintf(stdout,"d=%" PRId64 "\tx=%" PRIu64 "\ty=%" PRIu64 "\tL=%" PRIu64 "\tsco=%" PRIu64 "\tseqX=%" PRIu64 "\tseqY=%" PRIu64 "\tSIM=%f" "\tstrand=%c\n",fs[n].diag, fs[n].xStart, fs[n].yStart, fs[n].length, fs[n].score, fs[n].seqX, fs[n].seqY,fs[n].similarity, fs[n].strand); // fprintf(stdout,"%" PRId64 "\t%" PRIu64 "\t%" PRIu64 "\t%" PRIu64 "\t%" PRIu64 "\t%c" "\t%" PRIu64 "\n",fs[n].xStart, fs[n].yStart, fs[n].xEnd, fs[n].yEnd, fs[n].length, fs[n].strand, fs[n].ident); // n++; } fclose(fe); // fclose(fsalida); return fs; }
static void print(const char *filename, Uint32 *buf, Uint32 size) { Uint32 index = 0; ndbout << "Filename: " << filename << " with size " << size << endl; Uint32 noOfPages = readWord(index, buf); if (noOfPages * 8192 != size) { ndbout << "noOfPages is wrong: noOfPages = " << noOfPages << endl; return; } Uint32 noOfWords = readWord(index, buf); ndbout << "noOfPages = " << noOfPages; ndbout << " noOfWords = " << noOfWords << endl; ndbout << "Table Data" << endl; ndbout << "----------" << endl; Uint32 totalfrags = readWord(index, buf); Uint32 noOfBackups = readWord(index, buf); Uint32 hashpointer = readWord(index, buf); Uint32 kvalue = readWord(index, buf); Uint32 mask = readWord(index, buf); Uint32 tab_method = readWord(index, buf); Uint32 tab_storage = readWord(index, buf); ndbout << "Num Frags: " << totalfrags; ndbout << " NoOfReplicas: " << (noOfBackups + 1); ndbout << " hashpointer: " << hashpointer << endl; ndbout << "kvalue: " << kvalue; ndbout << " mask: " << hex << mask; ndbout << " method: "; switch (tab_method) { case 0: ndbout << "LinearHash"; break; case 2: ndbout << "Hash"; break; case 3: ndbout << "User Defined"; break; case 4: ndbout << "HashMap"; break; default: ndbout << "set to:" << tab_method; break; } ndbout << endl; ndbout << "Storage is on "; switch (tab_storage) { case 0: ndbout << "Logged, not checkpointed, doesn't survive SR"; break; case 1: ndbout << "Logged and checkpointed, survives SR"; break; case 2: ndbout << "Table is lost after SR"; break; default: ndbout << "set to:" << tab_storage; break; } ndbout << endl; for (Uint32 i = 0; i < totalfrags; i++) { Uint32 j; Uint32 numStoredReplicas; readFragment(numStoredReplicas, index, buf); for (j = 0; j < numStoredReplicas; j++) { ndbout << "-------Stored Replica----------" << endl; readReplica(index, buf); } for ( ; j < (1 + noOfBackups); j++) { ndbout << "-------Old Stored Replica------" << endl; readReplica(index, buf); } } }