diff options
| Commit | cb7ed2e2af57c98bbe22080ed5529777b8019b74 (patch) | |
|---|---|---|
| Author | 2022-06-14 13:39:17 +0300 | |
| Committer | 2022-06-14 13:39:17 +0300 | |
| Files | 16ef3543b89873a7d98e61035f6daf9078e7841b /src | |
| FMI-OOP-P2_Tables-cb7ed2e2af57c98bbe22080ed5529777b8019b74.tar FMI-OOP-P2_Tables-cb7ed2e2af57c98bbe22080ed5529777b8019b74.tar.gz FMI-OOP-P2_Tables-cb7ed2e2af57c98bbe22080ed5529777b8019b74.zip | ||
| Parent | 279f36b77c527061853fcc2267994aeb1c1d4afa (diff) | |
Autocommit at 14.06.2022 @ 13:39
2 files changed, 10 insertions, 9 deletions
| -rw-r--r-- | src/Models/Table.cpp | 17 | ||||
| -rw-r--r-- | src/test.table | 2 |
diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp index 163926b..a3c03fe 100644 --- a/src/Models/Table.cpp +++ b/src/Models/Table.cpp @@ -72,9 +72,8 @@ void Table::readFromFile(std::ifstream& inFile) { W(inFile); if (inFile.peek() == ',') inFile.get(); - else if (inFile.peek() != '\n' || inFile.peek() != EOF) + else if (inFile.peek() != '\n' && inFile.peek() != EOF) throwException(inFile, row); - inFile.get(); cells[row].add((buffer[0] == '=') ? (Cell*)new CellFormula(buffer.raw_data(), &cells) @@ -93,16 +92,18 @@ void Table::readFromFile(std::ifstream& inFile) { buffer.add('\0'); W(inFile); - if (inFile.peek() != ',') throwException(inFile, row); - inFile.get(); + if (inFile.peek() == ',') inFile.get(); + else if (inFile.peek() != '\n' && inFile.peek() != EOF) + throwException(inFile, row); cells[row].add((Cell*)new CellDouble(buffer.raw_data())); } else { buffer.add('\0'); W(inFile); - if (inFile.peek() != ',') throwException(inFile, row); - inFile.get(); + if (inFile.peek() == ',') inFile.get(); + else if (inFile.peek() != '\n' && inFile.peek() != EOF) + throwException(inFile, row); cells[row].add((Cell*)new CellInt(buffer.raw_data())); } @@ -182,8 +183,8 @@ void Table::putCell(unsigned row, unsigned col, const char* rawValue) { List<String> Table::getAllCells() const { List<String> toRet; for (unsigned i = 0; i < cells.get_count(); i++) { - for (unsigned j = 0; j < cells[i].get_count(); j++) { - if (cells[i][j] != nullptr) + for (unsigned j = 0; j < get_cols(); j++) { + if (cells[i].get_count() - 1 >= j && cells[i][j] != nullptr) toRet.add(cells[i][j]->getValueForPrint()); else toRet.add(""); diff --git a/src/test.table b/src/test.table index 9570992..ca7c7b8 100644 --- a/src/test.table +++ b/src/test.table @@ -1,2 +1,2 @@ 8.6,3,"String","= 3 * R1C2 + R1C1 ^ R1C2 * 27 / R1C2 - 2 * 2.5 * 2 * 2 + R1C3 ^ R1C3","", -"HELLL YEAH BROTHER","Bruh","=R1C0 + R1C1",,,,,,,,,,"Wow", +"HELLL YEAH BROTHER","Bruh","=R1C0 + R1C1",,,,,,,,,,"Wow" |
