Files
GenericQtClientCore/data/filehandler.h

29 lines
677 B
C++

#ifndef FILEHANDLER_H
#define FILEHANDLER_H
#include <QVariant>
typedef QHash<int, QVariant> ModelItemValues;
class QJsonDocument;
class QString;
class QByteArray;
class FileHandler {
public:
/// JSON
static bool saveToFile(const QJsonDocument& doc, const QString& fileName);
static QByteArray loadJSONDataFromFile(const QString fileName);
/// CSV
static QList<ModelItemValues> getItemValuesFromCSVFile(const QString& filePath);
static bool exportToCSVFile(const QList<QStringList>& rows, const QString& filePath);
private:
explicit FileHandler();
static QPair<QString, QByteArray> getFileContent(const QString& filePath);
};
#endif // FILEHANDLER_H