diff options
| Commit | c396eec30d0db694d665275b625d04627c401317 (patch) | |
|---|---|---|
| Author | 2022-06-14 09:13:58 +0300 | |
| Committer | 2022-06-14 09:13:58 +0300 | |
| Files | a0c10f9757cdb3865fabb326ad0eb29a0401cdd7 /src | |
| FMI-OOP-P2_Tables-c396eec30d0db694d665275b625d04627c401317.tar FMI-OOP-P2_Tables-c396eec30d0db694d665275b625d04627c401317.tar.gz FMI-OOP-P2_Tables-c396eec30d0db694d665275b625d04627c401317.zip | ||
| Parent | 7febd01493afa6b5406a8c09ab16eba1d30270a9 (diff) | |
Autocommit at 14.06.2022 @ 09:13
2 files changed, 10 insertions, 7 deletions
| -rw-r--r-- | src/Models/Table.cpp | 15 | ||||
| -rw-r--r-- | src/test.table | 2 |
diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp index f55e986..552cd61 100644 --- a/src/Models/Table.cpp +++ b/src/Models/Table.cpp @@ -122,8 +122,8 @@ Table::Table(const char* filePath) { } Table::~Table() { - for (unsigned i = 0; i < cells.get_length(); i++) { - for (unsigned j = 0; j < cells.get_length(); j++) { + for (unsigned i = 0; i < cells.get_count(); i++) { + for (unsigned j = 0; j < cells[i].get_count(); j++) { delete cells[i][j]; } } @@ -163,10 +163,15 @@ void Table::putCell(unsigned row, unsigned col, const char* rawValue) { else throw std::logic_error("Error: Could not determine data type."); - - if (cells[row][col] != nullptr) + if (cells[row].get_count() - 1 < col) { + while (cells[row].get_count() < col) + cells[row].add((Cell*)new CellString()); + cells[row].add(newCell); + } + else { delete cells[row][col]; - cells[row][col] = newCell; + cells[row][col] = newCell; + } } List<String> Table::getAllCells() const { diff --git a/src/test.table b/src/test.table index 9290552..e69de29 100644 --- a/src/test.table +++ b/src/test.table @@ -1,2 +0,0 @@ -8.6,3,"String","= 3 * R0C1 + R0C0 ^ R0C1 * 27 / R0C1 - 2 * 2.5 * 2 * 2 + R0C2 ^ R0C2",, -,,,,, |
