Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / Table.cpp
diff options
context:
space:
mode:
Commit7c0853dafc26855309487b713b26fc06d9601035 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-05-30 19:38:06 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-05-30 19:38:06 +0300
Files797c24ae0257896dd38ffe9effb4c11d0c2b8dc6 /src/Models/Table.cpp
FMI-OOP-P2_Tables-7c0853dafc26855309487b713b26fc06d9601035.tar
FMI-OOP-P2_Tables-7c0853dafc26855309487b713b26fc06d9601035.tar.gz
FMI-OOP-P2_Tables-7c0853dafc26855309487b713b26fc06d9601035.zip
Parenta1cdad178256606809d022c5e7dfa35ea43f4fa5 (diff)
Autocommit at 30.05.2022 @ 19:38
1 files changed, 8 insertions, 3 deletions
-rw-r--r--src/Models/Table.cpp11
diff --git a/src/Models/Table.cpp b/src/Models/Table.cpp
index 431f17d..afbccff 100644
--- a/src/Models/Table.cpp
+++ b/src/Models/Table.cpp
@@ -18,7 +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()
+#define fileLocationExceptionMsg(mainMessage, lines, columns) (((String(mainMessage) += (unsigned)(lines)) += " and col ") += (unsigned)(columns)).get_cstr()
bool containsNumber(const char*& str) {
while (*str == ' ') str++;
@@ -57,11 +57,16 @@ 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();
+ throw std::logic_error(fileLocationExceptionMsg("Error: Expected digit but got something else at row ", cells.get_count(), inFile.tellg() % cells.get_count() + 1));
while (isDigit(inFile.peek())) inFile.get();
- if (inFile.peek() != '.' && inFile.peek() != ' ' && inFile.peek() != ',')
+ if (inFile.peek() != '.') {
+ inFile.get();
+ while (isDigit(inFile.peek())) inFile.get();
+ }
+ if (inFile.peek() != ' ' && inFile.peek() != ',' && inFile.peek() != '\n')
}
}
}