diff options
| Commit | 2c961228ea05472cb86eab289f5f7859f492190b (patch) | |
|---|---|---|
| Author | 2022-06-14 07:23:27 +0300 | |
| Committer | 2022-06-14 07:23:27 +0300 | |
| Files | 6c92676984dfe026fe7e37c969778a3f3e7ec594 /src | |
| FMI-OOP-P2_Tables-2c961228ea05472cb86eab289f5f7859f492190b.tar FMI-OOP-P2_Tables-2c961228ea05472cb86eab289f5f7859f492190b.tar.gz FMI-OOP-P2_Tables-2c961228ea05472cb86eab289f5f7859f492190b.zip | ||
| Parent | 450a93877be73a7ef526362d1284ecf58c25418e (diff) | |
Autocommit at 14.06.2022 @ 07:23
1 files changed, 9 insertions, 5 deletions
| -rw-r--r-- | src/Models/Table.cpp | 14 |
diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp index 68908fd..787652a 100644 --- a/src/Models/Table.cpp +++ b/src/Models/Table.cpp @@ -124,6 +124,14 @@ unsigned Table::get_cols() const { void Table::putCell(unsigned row, unsigned col, const char* rawValue) { Cell* newCell; + while (*rawValue == ' ') rawValue++; + + if (*rawValue == '"') { + rawValue++; + newCell = (*rawValue == '=') + ? (Cell*)new CellFormula(rawValue, &cells) + : (Cell*)new CellString(rawValue); + } if (containsNumber(rawValue)) { double doubleParse = atof(rawValue); unsigned intPart = abs(doubleParse); @@ -131,11 +139,7 @@ void Table::putCell(unsigned row, unsigned col, const char* rawValue) { newCell = (abs(doubleParse) - intPart > FLOATING_POINT_PRECISION) ? (Cell*)new CellDouble(doubleParse) : (Cell*)new CellInt(intPart); } - else if (*rawValue == '"') { - rawValue++; - newCell = (*rawValue == '=') - ? (Cell*)new CellFormula(rawValue, &cells) : (Cell*)new CellString(rawValue); - } + else throw std::logic_error("Error: Could not determine data type."); |
