#include <iostream>
Go to the source code of this file.
◆ csvToModel()
Definition at line 41 of file CsvUtil.C.
45 std::ifstream f(csvFile.c_str());
void setItemPrototype(std::unique_ptr< WStandardItem > item)
void readFromCsv(std::istream &f, Wt::WAbstractItemModel *model, int numRows, bool firstLineIsHeaders)
Utility function that reads a model from a CSV file.
◆ readFromCsv()
void readFromCsv |
( |
std::istream & |
f, |
|
|
Wt::WAbstractItemModel * |
model, |
|
|
int |
numRows = -1 , |
|
|
bool |
firstLineIsHeaders = true |
|
) |
| |
Definition at line 56 of file CsvUtil.C.
66 typedef boost::tokenizer<boost::escaped_list_separator<char> >
68 CsvTokenizer tok(line);
71 for (CsvTokenizer::iterator i = tok.begin();
72 i != tok.end(); ++i, ++col) {
78 if (firstLineIsHeaders && csvRow == 0)
81 int dataRow = firstLineIsHeaders ? csvRow - 1 : csvRow;
83 if (numRows != -1 && dataRow >= numRows)
91 model->
setData(dataRow, col, data);
virtual bool insertColumns(int column, int count, const WModelIndex &parent=WModelIndex())
static WString fromUTF8(const std::string &value, bool checkValid=false)
virtual bool insertRows(int row, int count, const WModelIndex &parent=WModelIndex())
virtual bool setData(const WModelIndex &index, const cpp17::any &value, ItemDataRole role=ItemDataRole::Edit)
virtual int rowCount(const WModelIndex &parent=WModelIndex()) const=0
virtual int columnCount(const WModelIndex &parent=WModelIndex()) const=0
virtual bool setHeaderData(int section, Orientation orientation, const cpp17::any &value, ItemDataRole role=ItemDataRole::Edit)