From: <dhu...@us...> - 2007-01-05 12:49:48
|
Revision: 98 http://svn.sourceforge.net/qcell/?rev=98&view=rev Author: dhubleizh Date: 2007-01-05 04:49:45 -0800 (Fri, 05 Jan 2007) Log Message: ----------- - preliminary parsing out things - generic interfaces updated for parse out - started KI saving implementation Modified Paths: -------------- trunk/qcell/baseheaders/GenericParserPlugin.h trunk/qcell/baseheaders/interfaces.h trunk/qcell/basesources/GenericParserPlugin.cpp trunk/qcell/parsers/KI/KIParserPlugin.cpp trunk/qcell/parsers/KI/KIParserPlugin.h Modified: trunk/qcell/baseheaders/GenericParserPlugin.h =================================================================== --- trunk/qcell/baseheaders/GenericParserPlugin.h 2007-01-05 10:45:54 UTC (rev 97) +++ trunk/qcell/baseheaders/GenericParserPlugin.h 2007-01-05 12:49:45 UTC (rev 98) @@ -68,7 +68,7 @@ QString parse(const QByteArray content, const QString type, const QString subtype=""); - + QByteArray parseOut(QString content, const QString type, const QString subtype="") = 0; }; #endif Modified: trunk/qcell/baseheaders/interfaces.h =================================================================== --- trunk/qcell/baseheaders/interfaces.h 2007-01-05 10:45:54 UTC (rev 97) +++ trunk/qcell/baseheaders/interfaces.h 2007-01-05 12:49:45 UTC (rev 98) @@ -50,6 +50,9 @@ * @return A xml string containing the parsed data in common format */ virtual QString parse(const QByteArray content, const QString type, const QString subtype) = 0; + + virtual QByteArray parseOut(QString content, const QString type, const QString subtype) = 0; + }; Q_DECLARE_INTERFACE(ParserInterface, Modified: trunk/qcell/basesources/GenericParserPlugin.cpp =================================================================== --- trunk/qcell/basesources/GenericParserPlugin.cpp 2007-01-05 10:45:54 UTC (rev 97) +++ trunk/qcell/basesources/GenericParserPlugin.cpp 2007-01-05 12:49:45 UTC (rev 98) @@ -77,3 +77,50 @@ } +void GenericParserPlugin::parseOut(const QByteArray content, const QString type, const QString subtype) +{ + if(!supported_parser_types.contains(type)) + { + // Constructing supported parser types + QString types; + for(int i =0 ; i < supported_parser_types.count()-1; i++) + { + types.append(supported_parser_types[i]); + types.append(','); + + }; + types.append(supported_parser_types.last()); + + qDebug(tr("This plugin doesn't support saving type %1. It supports %2.") + .arg(type) + .arg(types) + .toAscii() + ); + + return; + } + else if(!supported_file_types.contains(subtype)){ + + // Constructing supported file types + QString subtypes; + for(int i =0 ; i < supported_file_types.count()-1; i++) + { + subtypes.append(supported_file_types[i]); + subtypes.append(','); + + }; + subtypes.append(supported_file_types.last()); + + qDebug(tr("This plugin doesn't support saving type %1. It supports %2.") + .arg(type) + .arg(subtypes) + .toAscii() + ); + + return; + + } + + return realParserOut(content, type, subtype); +} + Modified: trunk/qcell/parsers/KI/KIParserPlugin.cpp =================================================================== --- trunk/qcell/parsers/KI/KIParserPlugin.cpp 2007-01-05 10:45:54 UTC (rev 97) +++ trunk/qcell/parsers/KI/KIParserPlugin.cpp 2007-01-05 12:49:45 UTC (rev 98) @@ -136,5 +136,78 @@ return cd.createXmlHeader(); } +QByteArray KIParserPlugin::parseOut(QString content, const QString type, const QString subtype) +{ + // The resulting array to write to file by the backend + QByteArray result; + // Generic type to parse XML request + CalculationData cd; + // Number of dimensions we are dealing with + int dimensions; + + // Check if we can use the generic type from the XML string + if(!cd.setFromXmlString(&content)) + { + qDebug(tr("Unable to parse out internal data!").toAscii()); + } + + dimensions = cd.getDimension(); + + /// @todo header + + switch (dimensions) + { + case 1: + { + for (int x = 0; x < cd.getDataSize(); x++) + { + result.append(cd.getValueAt_i(x)); + } + + break; + } + case 2: + { + for(int y = 0; y < cd.getSizeY(); y++) + { + for (int x = 0; x < cd.getSizeX(); x++) + { + result.append(cd.getValueAt_i(x,y)); + } + + result.append('\n'); + } + + break; + } + case 3: + { + for(int z = 0; z < cd.getSizeZ(); z++) + { + for (int y = 0; y < cd.getSizeY(); y++) + { + for (int x = 0; x < cd.getSizeX(); x++) + { + result.append(cd.getValueAt_d(x, y, z)); + } + + result.append('\n'); + } + + result.append('\n'); + } + + break; + } + default: + { + qDebug(tr("Unable to parse out Calculation Data: Wrong number of dimensions!").toAscii()); + return QByteArray(); + } + } + + return result; +} + Q_EXPORT_PLUGIN2(KIFileParser, KIParserPlugin) Modified: trunk/qcell/parsers/KI/KIParserPlugin.h =================================================================== --- trunk/qcell/parsers/KI/KIParserPlugin.h 2007-01-05 10:45:54 UTC (rev 97) +++ trunk/qcell/parsers/KI/KIParserPlugin.h 2007-01-05 12:49:45 UTC (rev 98) @@ -19,7 +19,7 @@ { protected: QString realParser(QByteArray content, QString type, QString subtype); - + QByteArray parseOut(QString content, const QString type, const QString subtype=""); public: KIParserPlugin(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |