Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / Table.cpp
diff options
context:
space:
mode:
Commita1cdad178256606809d022c5e7dfa35ea43f4fa5 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-30 19:33:04 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-30 19:33:04 +0300
Filesee2c182e93d14dbe1915de281a7b296e26e9458b /src/Models/Table.cpp
FMI-OOP-P2_Tables-a1cdad178256606809d022c5e7dfa35ea43f4fa5.tar
FMI-OOP-P2_Tables-a1cdad178256606809d022c5e7dfa35ea43f4fa5.tar.gz
FMI-OOP-P2_Tables-a1cdad178256606809d022c5e7dfa35ea43f4fa5.zip
Parentce0db88d4bc4b0e1f8ee4268dec61a0b1c881596 (diff)
Autocommit at 30.05.2022 @ 19:33
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 be4c8bc..431f17d 100644
--- a/src/Models/Table.cpp
+++ b/src/Models/Table.cpp
@@ -18,6 +18,7 @@ unsigned countOfCommas(std::ifstream& file) {
#define abs(a) ((a < 0) ? -a : a)
#define isDigit(a) (a >= '0' && a <= '9')
+#define fileLocationExceptionMsg(mainMessage, columns, lines) (((String(mainMessage) += (unsigned)(lines)) += " and col ") += (unsigned)(columns)).get_cstr()
bool containsNumber(const char*& str) {
while (*str == ' ') str++;
@@ -41,6 +42,7 @@ Cell* Table::createCellByParsing(const char* rawValue) {
void Table::readFromFile(std::ifstream& inFile) {
unsigned commaCount = countOfCommas(inFile);
unsigned colInd = 0;
+ cells.add(List<Cell*>());
while (!inFile.eof()) {
while (inFile.peek() == ' ') inFile.get();
@@ -56,8 +58,10 @@ void Table::readFromFile(std::ifstream& inFile) {
else if (inFile.peek() == '-' || inFile.peek() == '+' || isDigit(inFile.peek())) {
unsigned numberStart = inFile.tellg();
if (inFile.peek() == '-' || inFile.peek() == '+') inFile.get();
- if (!isDigit(inFile.peek()))
- throw std::logic_error((((String("Error: Expected digit but got something else at row ") += cells.get_count()) += " and col ") += (unsigned)(inFile.tellg() % cells.get_count())).get_cstr());
+ if (isDigit(inFile.peek()))
+ throw std::logic_error();
+ while (isDigit(inFile.peek())) inFile.get();
+ if (inFile.peek() != '.' && inFile.peek() != ' ' && inFile.peek() != ',')
}
}
}