Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / Table.cpp
diff options
context:
space:
mode:
Commit859196059b3c63d3461d29aed8b3ba326af65151 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-06-14 07:43:33 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-06-14 07:43:33 +0300
Filesd72220512389cfb202bd841eb150e615fbd6fb19 /src/Models/Table.cpp
FMI-OOP-P2_Tables-859196059b3c63d3461d29aed8b3ba326af65151.tar
FMI-OOP-P2_Tables-859196059b3c63d3461d29aed8b3ba326af65151.tar.gz
FMI-OOP-P2_Tables-859196059b3c63d3461d29aed8b3ba326af65151.zip
Parent31122305895d59583523f94b6aafdadc0cef242a (diff)
Autocommit at 14.06.2022 @ 07:43
1 files changed, 9 insertions, 3 deletions
-rw-r--r--src/Models/Table.cpp12
diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp
index 0d46853..cd9e7d1 100644
--- a/src/Models/Table.cpp
+++ b/src/Models/Table.cpp
@@ -35,15 +35,15 @@ void D(std::ifstream& in, List<char>& buffer) {
}
void A(std::ifstream& in, List<char>& buffer) {
- while ((in.peek() >= ' ' && in.peek() <= '~') && in.peek() == '"')
+ while ((in.peek() >= ' ' && in.peek() <= '~') && in.peek() != '"')
buffer.add(in.get());
}
void throwException(std::ifstream& inFile, unsigned row) {
row++;
throw std::logic_error((
- (((((String("Error: Invalid character \"") += (char)inFile.peek())
- += "\" at row ") += row) += "\" and column ") += ((int)inFile.tellg() / row))
+ (((((String("Error: Invalid character '") += (char)inFile.peek())
+ += "' at row ") += row) += "\" and column ") += ((int)inFile.tellg() / row + 1))
).get_cstr());
}
@@ -66,6 +66,8 @@ void Table::readFromFile(std::ifstream& inFile) {
inFile.get();
A(inFile, buffer);
buffer.add('\0');
+ if (inFile.peek() != '"') throwException(inFile, row);
+ inFile.get();
W(inFile);
if (inFile.peek() != ',') throwException(inFile, row);
@@ -75,6 +77,10 @@ void Table::readFromFile(std::ifstream& inFile) {
? (Cell*)new CellFormula(buffer.raw_data(), &cells)
: (Cell*)new CellString(buffer.raw_data()));
}
+ else if (inFile.peek() == ',') {
+ inFile.get();
+ cells[row].add((Cell*)new CellString(""));
+ }
else {
P(inFile, buffer);
D(inFile, buffer);