Website Summary Files Commits Branches @commit @diff @stats
path: root / src / Models / Table.cpp
diff options
context:
space:
mode:
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() != ',')
}
}
}