Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / Table.cpp
diff options
context:
space:
mode:
Commitbc9995425163016291fad811ab3644860114739b (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-06-13 21:17:47 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-06-13 21:17:47 +0300
Filesce4c5a73f38ca2f0ea57a9e5afe1bcbc64269cb5 /src/Models/Table.cpp
FMI-OOP-P2_Tables-bc9995425163016291fad811ab3644860114739b.tar
FMI-OOP-P2_Tables-bc9995425163016291fad811ab3644860114739b.tar.gz
FMI-OOP-P2_Tables-bc9995425163016291fad811ab3644860114739b.zip
Parent634b16497ea98ede471a3aa16f695fd943dc9b75 (diff)
Autocommit at 13.06.2022 @ 21:17
1 files changed, 11 insertions, 1 deletions
-rw-r--r--src/Models/Table.cpp12
diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp
index dc4adc7..e108c5d 100644
--- a/src/Models/Table.cpp
+++ b/src/Models/Table.cpp
@@ -35,10 +35,17 @@ 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) {
+ throw std::logic_error((
+ (((((String("Error: Invalid character \"") += inFile.peek())
+ += "\" at row ") += row) += "\" and column ") += ((int)inFile.tellg() / row))
+ ).get_cstr());
+}
+
void Table::readFromFile(std::ifstream& inFile) {
unsigned row = 0;
cells.add(List<Cell*>());
@@ -58,6 +65,9 @@ void Table::readFromFile(std::ifstream& inFile) {
inFile.get();
A(inFile, buffer);
buffer.add('\0');
+ W(inFile);
+
+ if (inFile.peek() != ',') throwException(inFile, row);
cells[row].add((buffer[0] == '=')
? (Cell*)new CellFormula(buffer.raw_data(), &cells)