58{
59 int csvRow = 0;
60
61 while (f) {
62 std::string line;
63 getline(f, line);
64
65 if (f) {
66 typedef boost::tokenizer<boost::escaped_list_separator<char> >
67 CsvTokenizer;
68 CsvTokenizer tok(line);
69
70 int col = 0;
71 for (CsvTokenizer::iterator i = tok.begin();
72 i != tok.end(); ++i, ++col) {
73
77
78 if (firstLineIsHeaders && csvRow == 0)
80 else {
81 int dataRow = firstLineIsHeaders ? csvRow - 1 : csvRow;
82
83 if (numRows != -1 && dataRow >= numRows)
84 return;
85
89
91 model->
setData(dataRow, col, data);
92 }
93 }
94 }
95
96 ++csvRow;
97 }
98}
virtual bool insertColumns(int column, int count, const WModelIndex &parent=WModelIndex())
virtual bool setHeaderData(int section, Orientation orientation, const boost::any &value, int role=EditRole)
virtual bool setData(const WModelIndex &index, const boost::any &value, int role=EditRole)
virtual int rowCount(const WModelIndex &parent=WModelIndex()) const=0
virtual bool insertRows(int row, int count, const WModelIndex &parent=WModelIndex())
virtual int columnCount(const WModelIndex &parent=WModelIndex()) const=0
static WString fromUTF8(const std::string &value, bool checkValid=false)