Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / Table.cpp
diff options
context:
space:
mode:
Commita2ad22319e3d85ec50269b59cb2a1106cf92dce7 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-06-14 07:33:30 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-06-14 07:33:30 +0300
Files3d97dd7f8cfebe77b350439302d745347681d25e /src/Models/Table.cpp
FMI-OOP-P2_Tables-a2ad22319e3d85ec50269b59cb2a1106cf92dce7.tar
FMI-OOP-P2_Tables-a2ad22319e3d85ec50269b59cb2a1106cf92dce7.tar.gz
FMI-OOP-P2_Tables-a2ad22319e3d85ec50269b59cb2a1106cf92dce7.zip
Parente55eec22a7356ceef3f422ef64b986f88d95501a (diff)
Autocommit at 14.06.2022 @ 07:33
1 files changed, 5 insertions, 2 deletions
-rw-r--r--src/Models/Table.cpp7
diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp
index fe84115..c80c7dd 100644
--- a/src/Models/Table.cpp
+++ b/src/Models/Table.cpp
@@ -42,7 +42,7 @@ void A(std::ifstream& in, List<char>& buffer) {
void throwException(std::ifstream& inFile, unsigned row) {
throw std::logic_error((
(((((String("Error: Invalid character \"") += inFile.peek())
- += "\" at row ") += row) += "\" and column ") += ((int)inFile.tellg() / row))
+ += "\" at row ") += row) += "\" and column ") += ((int)inFile.tellg() / (row + 1)))
).get_cstr());
}
@@ -50,7 +50,7 @@ void Table::readFromFile(std::ifstream& inFile) {
unsigned row = 0;
cells.add(List<Cell*>());
- while (inFile.peek() != EOF) {
+ while (!inFile.eof()) {
if (inFile.peek() == '\n') {
row++;
inFile.get();
@@ -68,6 +68,7 @@ void Table::readFromFile(std::ifstream& inFile) {
W(inFile);
if (inFile.peek() != ',') throwException(inFile, row);
+ inFile.get();
cells[row].add((buffer[0] == '=')
? (Cell*)new CellFormula(buffer.raw_data(), &cells)
@@ -82,12 +83,14 @@ void Table::readFromFile(std::ifstream& inFile) {
W(inFile);
if (inFile.peek() != ',') throwException(inFile, row);
+ inFile.get();
cells[row].add((Cell*)new CellDouble(buffer.raw_data()));
}
else {
W(inFile);
if (inFile.peek() != ',') throwException(inFile, row);
+ inFile.get();
cells[row].add((Cell*)new CellInt(buffer.raw_data()));
}