diff options
| Commit | a6da045ab5ce6d7c33ae223fa6f217e470af0c02 (patch) | |
|---|---|---|
| Author | 2022-06-13 21:02:44 +0300 | |
| Committer | 2022-06-13 21:02:44 +0300 | |
| Files | 41fd4c03dcf6f82503e04a98b6dce007548d39a4 /src | |
| FMI-OOP-P2_Tables-a6da045ab5ce6d7c33ae223fa6f217e470af0c02.tar FMI-OOP-P2_Tables-a6da045ab5ce6d7c33ae223fa6f217e470af0c02.tar.gz FMI-OOP-P2_Tables-a6da045ab5ce6d7c33ae223fa6f217e470af0c02.zip | ||
| Parent | 319a198203a37c10e774c9b7abcdfdfb86ac4bed (diff) | |
Autocommit at 13.06.2022 @ 21:02
1 files changed, 14 insertions, 4 deletions
| -rw-r--r-- | src/Models/Table.cpp | 18 |
diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp index 1ba3daa..2db80e2 100644 --- a/src/Models/Table.cpp +++ b/src/Models/Table.cpp @@ -40,7 +40,17 @@ void A(std::ifstream& in, List<char>& buffer) { } void Table::readFromFile(std::ifstream& inFile) { + unsigned row = 0; + cells.add(List<Cell*>()); + while (inFile.peek() != EOF) { + if (inFile.peek() == '\0') { + row++; + inFile.get(); + cells.add(List<Cell*>()); + continue; + } + List<char> buffer; W(inFile); @@ -49,9 +59,9 @@ void Table::readFromFile(std::ifstream& inFile) { A(inFile, buffer); buffer.add('\0'); - cells[0][0] = (buffer[0] == '=') + cells[row].add((buffer[0] == '=') ? (Cell*)new CellFormula(buffer.raw_data(), &cells) - : (Cell*)new CellString(buffer.raw_data()); + : (Cell*)new CellString(buffer.raw_data())); } else { P(inFile, buffer); @@ -59,10 +69,10 @@ void Table::readFromFile(std::ifstream& inFile) { if (inFile.peek() == '.') { inFile.get(); D(inFile, buffer); - cells[0][0] = (Cell*)new CellDouble(buffer.raw_data()); + cells[row].add((Cell*)new CellDouble(buffer.raw_data())); } else - cells[0][0] = (Cell*)new CellInt(buffer.raw_data()); + cells[row].add((Cell*)new CellInt(buffer.raw_data())); } } } |
