bool JPEGDecompressor::readScanHeader(void) { /* Process all markers in the scan header: */ int nextMarker=processTables(); /* Process the next marker: */ if(nextMarker==SOS) processSos(); return nextMarker==SOS; }
int processManifestXML() { QFile xmlManifest(vManifestXML); QFile xmlData(vDatafileXML); QFile sqlInsertsFile(vSqlInsertsFile); //Open the manifest file and put the contents in a DOM document if (!xmlManifest.open(QIODevice::ReadOnly)) return 1; if (!manifestDoc.setContent(&xmlManifest)) { xmlManifest.close(); return 1; } xmlManifest.close(); //Open the xml data file and put the contents in a DOM document if (!xmlData.open(QIODevice::ReadOnly)) return 1; if (!dataDoc.setContent(&xmlData)) { xmlData.close(); return 1; } xmlData.close(); //Open text file for writing if (!sqlInsertsFile.open(QIODevice::WriteOnly | QIODevice::Text)) { return 1; } QTextStream out(&sqlInsertsFile); //Get the list of table nodes from the manifest tableNodesList = manifestDoc.elementsByTagName("table"); //Get nodes list for the data dataNodesList = dataDoc.elementsByTagName(vDatafileBaseNode); //Start the data processing processTables(tableNodesList.item(0), dataNodesList.item(0)); //Write the string to the file and close the file out << str; sqlInsertsFile.close(); return 0; }
JPEGDecompressor::JPEGDecompressor(IO::File& sSource) :source(sSource), numComponents(0), numBits(0), components(0), numScanComponents(0), restartInterval(0), ss(0),pt(0) { /* Clear the current components: */ for(int i=0;i<4;++i) scanComponents[i]=0; /* Clear the Huffman tables: */ for(int i=0;i<4;++i) huffmanTables[i]=0; /* Check for an SOI marker at the beginning of the stream: */ int c1=source.getChar(); int c2=source.getChar(); if(c1!=0xff||c2!=SOI) Misc::throwStdErr("JPEGDecompressor::JPEGDecompressor: input stream is not a JPEG stream"); /* Process the SOI marker just read: */ processSoi(); /* Process all markers in the file header: */ int nextMarker=processTables(); /* Process the next marker: */ switch(nextMarker) { case SOF0: case SOF1: case SOF3: processSof(nextMarker); break; default: /* Just ignore the wrong SOF marker type for now... */ ; } }
int processTables(QDomNode tableNodeToProcess, QDomNode dataNodeToProcess) { QString tableName; QDomNodeList recordsNodesList; QDomNode recordNode; QDomNode tableNode; QString fieldsStatement; QDomNode childTableNode; QString fieldName; bool processedData = false; //Get the table name and set how deep the node is in the tree tableName = tableNodeToProcess.toElement().attribute("mysqlcode", "None"); nodeDepth = nodeDepth + 1; //Get the records from the data using the table name //First check if the main table has been processed and pick its name correctly //This is caused by the fact that the main table in the manifest and the data might not have the same name if (tableName == vManifestMainTable) { recordsNodesList = dataDoc.elementsByTagName(vDatafileBaseNode); } else { if (tableName.startsWith(vManifestMainTable)) { recordsNodesList = dataNodeToProcess.toElement().elementsByTagName(tableName.mid(vManifestMainTable.length() + 1)); } else { recordsNodesList = dataNodeToProcess.toElement().elementsByTagName(tableName); } } if (recordsNodesList.count() > 0) { for (int recCount = 0; recCount <= recordsNodesList.count() - 1; recCount++) { processedData = false; recordNode = recordsNodesList.item(recCount); //Get the current table node from manifest for(int tcount = 0; tableNodesList.count(); tcount++) { if(tableNodesList.item(tcount).toElement().attribute("mysqlcode", "None") == tableName) { tableNode = tableNodesList.item(tcount); break; } } //Pass through the table child nodes to get the field names fieldsStatement = ""; childTableNode = tableNode.firstChild(); while (!childTableNode.isNull()) { if (childTableNode.toElement().tagName() == "field") { //Get the field name and use in creating the fields statement fieldName = childTableNode.toElement().attribute("mysqlcode", "None"); fieldsStatement = fieldsStatement + fieldName + ", "; } else { //Encountered a table get the record values under this parent record and do process again if (processedData == false) { processTableData(tableNode, recordNode, tableName, fieldsStatement, QString::number(recCount + 1)); processedData = true; } processTables(childTableNode, recordNode); } //Get the next child table node childTableNode = childTableNode.nextSibling(); } //If no table was encountered within the table being processed if (processedData == false) { processTableData(tableNode, recordNode, tableName, fieldsStatement, QString::number(recCount + 1)); } } } //Current table finished reduce nodeDepth nodeDepth = nodeDepth - 1; return 0; }