From 4ce512129759a4cf7e7c7b1cbc7a1eed42b98b51 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 30 May 2022 19:17:58 +0300 Subject: Autocommit at 30.05.2022 @ 19:17 --- src/Models/Table.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/Models/Table.cpp') diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp index 6101136..c4fa332 100644 --- a/src/Models/Table.cpp +++ b/src/Models/Table.cpp @@ -39,7 +39,19 @@ Cell* Table::createCellByParsing(const char* rawValue) { void Table::readFromFile(std::ifstream& inFile) { unsigned commaCount = countOfCommas(inFile); + unsigned colInd = 0; while (!inFile.eof()) { + while (inFile.peek() == ' ') inFile.get(); + + if (inFile.peek() == ',') { + colInd++; + } + else if (inFile.peek() == '\n') { + cells.add(List(commaCount)); + colInd = 0; + inFile.get(); + } + else if (inFile.peek() ) } } @@ -47,7 +59,7 @@ Table::Table(const char* filePath) { std::ifstream inFile(filePath); if (inFile.is_open()) throw std::logic_error("Could now open file!"); - cells = List>(); + cells = List>(1); readFromFile(inFile); inFile.close(); } -- cgit v1.3.1-23-gd82d