work save

This commit is contained in:
Roy Qu 2022-12-16 14:41:24 +08:00
parent 261c0b4cea
commit f4ca71803f
2 changed files with 13 additions and 3 deletions

View File

@ -2,7 +2,7 @@
#include <QFile> #include <QFile>
#include <QXmlStreamReader> #include <QXmlStreamReader>
# #include <QXmlStreamWriter>
QList<POJProblem> importFreeProblemSet(const QString &filename) QList<POJProblem> importFreeProblemSet(const QString &filename)
{ {
@ -14,7 +14,6 @@ QList<POJProblem> importFreeProblemSet(const QString &filename)
xml.setDevice(&file); xml.setDevice(&file);
POJProblem currentProblem; POJProblem currentProblem;
POJProblemCase currentCase; POJProblemCase currentCase;
QString currentText;
QString currentEleName; QString currentEleName;
while(!xml.atEnd()) { while(!xml.atEnd()) {
xml.readNext(); xml.readNext();
@ -94,3 +93,14 @@ QList<POJProblem> importFreeProblemSet(const QString &filename)
} }
return problems; return problems;
} }
void exportFreeProblemSet(const QList<POJProblem> &problems, const QString &filename)
{
QFile file(filename);
if (!file.open(QFile::WriteOnly|QFile::Truncate))
return;
QXmlStreamWriter writer(&file);
writer.setAutoFormatting(true);
writer.writeStartDocument();
writer.writeEndDocument();
}

View File

@ -4,6 +4,6 @@
#include "ojproblemset.h" #include "ojproblemset.h"
QList<POJProblem> importFreeProblemSet(const QString& filename); QList<POJProblem> importFreeProblemSet(const QString& filename);
//void exportFreeProblemSet(const QList<POJProblem>& problems); void exportFreeProblemSet(const QList<POJProblem>& problems, const QString& filename);
#endif // FREEPROJECTSETFORMAT_H #endif // FREEPROJECTSETFORMAT_H