Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / Table.cpp
diff options
context:
space:
mode:
Commitdd8ff49d2bd29f08c5a6afa39d89dba3d715ee4a (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-30 20:33:26 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-30 20:33:26 +0300
Filesb012e52c5b2bd32ee55e3f59d341bfe4c493a873 /src/Models/Table.cpp
FMI-OOP-P2_Tables-dd8ff49d2bd29f08c5a6afa39d89dba3d715ee4a.tar
FMI-OOP-P2_Tables-dd8ff49d2bd29f08c5a6afa39d89dba3d715ee4a.tar.gz
FMI-OOP-P2_Tables-dd8ff49d2bd29f08c5a6afa39d89dba3d715ee4a.zip
Parent2929a4a6e811ddc2c2073158f50d2e20170c6c6a (diff)
Autocommit at 30.05.2022 @ 20:33
1 files changed, 6 insertions, 0 deletions
-rw-r--r--src/Models/Table.cpp6
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<Cell*>(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();