diff options
| Commit | ad8feeb5d93a1b970699c8da30bdfbbb0e6aa97a (patch) | |
|---|---|---|
| Author | 2022-06-14 13:14:13 +0300 | |
| Committer | 2022-06-14 13:14:13 +0300 | |
| Files | 06d3930560daa96ad00b0eee0c90b3cedee08b6c /src | |
| FMI-OOP-P2_Tables-ad8feeb5d93a1b970699c8da30bdfbbb0e6aa97a.tar FMI-OOP-P2_Tables-ad8feeb5d93a1b970699c8da30bdfbbb0e6aa97a.tar.gz FMI-OOP-P2_Tables-ad8feeb5d93a1b970699c8da30bdfbbb0e6aa97a.zip | ||
| Parent | 2cd58d14ae14b19c16b04bf1a848bc3dbd073ea9 (diff) | |
Autocommit at 14.06.2022 @ 13:14
2 files changed, 9 insertions, 5 deletions
| -rw-r--r-- | src/Models/Table.cpp | 12 | ||||
| -rw-r--r-- | src/test.table | 2 |
diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp index db90f75..0256d88 100644 --- a/src/Models/Table.cpp +++ b/src/Models/Table.cpp @@ -146,10 +146,14 @@ void Table::putCell(unsigned row, unsigned col, const char* rawValue) { while (*rawValue == ' ') rawValue++; if (*rawValue == '"') { - String temp(rawValue); - newCell = (*rawValue == '=') - ? (Cell*)new CellFormula(rawValue, &cells) - : (Cell*)new CellString(rawValue); + String temp(++rawValue); + if (temp[temp.get_length() - 1] != '"') + throw std::logic_error("Error: No closing brace found!"); + temp[temp.get_length() - 1] = '\0'; + + newCell = (temp[0] == '=') + ? (Cell*)new CellFormula(temp.get_cstr(), &cells) + : (Cell*)new CellString(temp.get_cstr()); } else if ((*rawValue == '+' || *rawValue == '-') || (*rawValue >= '0' && *rawValue <= '9')) { double doubleParse = atof(rawValue); diff --git a/src/test.table b/src/test.table index 22b8523..8f0c9aa 100644 --- a/src/test.table +++ b/src/test.table @@ -1,2 +1,2 @@ -8.6,3,"String","= 3 * R0C1 + R0C0 ^ R0C1 * 27 / R0C1 - 2 * 2.5 * 2 * 2 + R0C2 ^ R0C2","", +8.6,3,"String","= 3 * R1C2 + R1C1 ^ R1C2 * 27 / R1C2 - 2 * 2.5 * 2 * 2 + R1C3 ^ R1C3","", "HELLL YEAH BROTHER","Bruh","=R1C0 + R1C1",,, |
