From dd8ff49d2bd29f08c5a6afa39d89dba3d715ee4a Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 30 May 2022 20:33:26 +0300 Subject: Autocommit at 30.05.2022 @ 20:33 --- src/Models/Table.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/Models/Table.cpp') diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp index a4103be..dd82b30 100644 --- a/src/Models/Table.cpp +++ b/src/Models/Table.cpp @@ -35,15 +35,18 @@ void Table::readFromFile(std::ifstream& inFile) { while (!inFile.eof()) { while (inFile.peek() == ' ') inFile.get(); + // Entering a new cell on the current row if (inFile.peek() == ',') { colInd++; inFile.get(); } + // Entering a new row else if (inFile.peek() == '\n') { cells.add(List(commaCount)); colInd = 0; inFile.get(); } + // Parsing number else if (inFile.peek() == '-' || inFile.peek() == '+' || isDigit(inFile.peek())) { int whole = 0; unsigned exponent = 1; @@ -56,9 +59,11 @@ void Table::readFromFile(std::ifstream& inFile) { if (isDigit(inFile.peek())) throw std::logic_error(fileLocationExceptionMsg("Error: Expected digit but got something else at row ", cells.get_count(), inFile.tellg() % cells.get_count() + 1)); + // Parsing digits of whole number/whole part of floating point number while (isDigit(inFile.peek())) { (whole *= 10) += inFile.get() - '0'; } + // Parsing digits of potential floating point number if (inFile.peek() != '.') { inFile.get(); while (isDigit(inFile.peek())) { @@ -75,6 +80,7 @@ void Table::readFromFile(std::ifstream& inFile) { else cells[cells.get_count() - 1].add(new CellDouble((double)whole / exponent)); } + // Parsing string or formula else if (inFile.peek() == '"') { String res; inFile.get(); -- cgit v1.3.1-23-gd82d