Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / Table.cpp
diff options
context:
space:
mode:
Commitb07bd9dfb73e5a63520a0a30533841dc8ceff567 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-28 18:34:29 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-28 18:34:29 +0300
Filesbc3e4db314781b9d8940faa49c2c1a4a319734fa /src/Models/Table.cpp
FMI-OOP-P2_Tables-b07bd9dfb73e5a63520a0a30533841dc8ceff567.tar
FMI-OOP-P2_Tables-b07bd9dfb73e5a63520a0a30533841dc8ceff567.tar.gz
FMI-OOP-P2_Tables-b07bd9dfb73e5a63520a0a30533841dc8ceff567.zip
Parent68f6b62e49916a59442f4ae69fc0554bf1d84f3a (diff)
Autocommit at 28.05.2022 @ 18:34
1 files changed, 6 insertions, 2 deletions
-rw-r--r--src/Models/Table.cpp8
diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp
index 5d0c87f..af72875 100644
--- a/src/Models/Table.cpp
+++ b/src/Models/Table.cpp
@@ -19,14 +19,18 @@ bool containsNumber(const char*& str) {
}
void Table::putCell(unsigned row, unsigned col, const char* rawValue) {
-
Cell* newCell;
+
if (containsNumber(rawValue)) {
unsigned intParse = atoi(rawValue);
unsigned doubleParse = atof(rawValue);
newCell = (doubleParse - intParse > 0.00001 && doubleParse > 0.00001)
- ? new CellDouble(doubleParse) : new CellInt(intParse);
+ ? (Cell*)new CellDouble(doubleParse) : (Cell*)new CellInt(intParse);
+ }
+ else {
+ newCell = (*rawValue == '=') ? (Cell*)new CellFormula(rawValue) : (Cell*)new CellString(rawValue);
}
+ cells[row][col] = newCell;
}