33 lines
970 B
C++
33 lines
970 B
C++
#ifndef CSVPARSER_H
|
|
#define CSVPARSER_H
|
|
|
|
#include <QString>
|
|
|
|
typedef QHash<int, QVariant> ModelItemValues;
|
|
|
|
namespace rapidcsv {
|
|
class Document;
|
|
}
|
|
|
|
class CsvParser {
|
|
public:
|
|
static QList<ModelItemValues> getItemsFromCSVFile(const QString& fileName);
|
|
static bool exportToCSVFile(const QList<QStringList>& rows, const QString& filePath);
|
|
|
|
private:
|
|
explicit CsvParser();
|
|
|
|
static bool isCsvCompatible(const rapidcsv::Document& doc);
|
|
static QList<ModelItemValues> createListItemsFromCsvEntries(const rapidcsv::Document& doc);
|
|
static QHash<QString, std::vector<std::string>> extractColumnValues(
|
|
const QList<QString> headerNames,
|
|
const rapidcsv::Document& doc);
|
|
static ModelItemValues getItemValuesForRow(
|
|
const QList<QString>& headerNames,
|
|
const QHash<QString, std::vector<std::string>>& columnValueMap,
|
|
const int row);
|
|
static QVariant parseItemValue(const int role, const std::string& valueString);
|
|
};
|
|
|
|
#endif // CSVPARSER_H
|