diff --git a/src/lib/ebus/filereader.h b/src/lib/ebus/filereader.h index d89ffaa8..6d968663 100644 --- a/src/lib/ebus/filereader.h +++ b/src/lib/ebus/filereader.h @@ -39,7 +39,7 @@ using namespace std; /** the separator character used to quote text having the @a FIELD_SEPARATOR in it. */ #define TEXT_SEPARATOR '"' -extern void printErrorPos(vector::iterator begin, const vector::iterator end, vector::iterator pos, string filename, size_t lineNo, result_t result); +extern void printErrorPos(ostream& out, vector::iterator begin, const vector::iterator end, vector::iterator pos, string filename, size_t lineNo, result_t result); /** @@ -138,10 +138,11 @@ public: if (m_supportsDefaults) { if (line[0] == '*') { row[0] = row[0].substr(1); - defaults.push_back(row); - continue; - } - result = addFromFile(it, end, arg, &defaults, filename, lineNo); + result = addDefaultFromFile(defaults, row, it, filename, lineNo); + if (result == RESULT_OK) + continue; + } else + result = addFromFile(it, end, arg, &defaults, filename, lineNo); } else result = addFromFile(it, end, arg, NULL, filename, lineNo); @@ -154,7 +155,7 @@ public: m_lastError = error.str(); return result; } - printErrorPos(row.begin(), end, it, filename, lineNo, result); + printErrorPos(cout, row.begin(), end, it, filename, lineNo, result); } else if (!verbose) m_lastError = ""; } @@ -169,6 +170,21 @@ public: */ virtual string getLastError() { return m_lastError; } + /** + * Add a default row that was read from a file. + * @param defaults the list to add the default row to. + * @param row the default row (initial star char removed). + * @param begin an iterator to the first column of the default row to read (for error reporting). + * @param filename the name of the file being read. + * @param lineNo the current line number in the file being read. + * @return @a RESULT_OK on success, or an error code. + */ + virtual result_t addDefaultFromFile(vector< vector >& defaults, vector& row, vector::iterator& begin, const string& filename, unsigned int lineNo) { + defaults.push_back(row); + begin = row.end(); + return RESULT_OK; + } + /** * Add a definition that was read from a file. * @param begin an iterator to the first column of the definition row to read.