allow subclass override behaviour of reading defaults, added ostream arg to printErrorPos
This commit is contained in:
@@ -39,7 +39,7 @@ using namespace std;
|
|||||||
/** the separator character used to quote text having the @a FIELD_SEPARATOR in it. */
|
/** the separator character used to quote text having the @a FIELD_SEPARATOR in it. */
|
||||||
#define TEXT_SEPARATOR '"'
|
#define TEXT_SEPARATOR '"'
|
||||||
|
|
||||||
extern void printErrorPos(vector<string>::iterator begin, const vector<string>::iterator end, vector<string>::iterator pos, string filename, size_t lineNo, result_t result);
|
extern void printErrorPos(ostream& out, vector<string>::iterator begin, const vector<string>::iterator end, vector<string>::iterator pos, string filename, size_t lineNo, result_t result);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,10 +138,11 @@ public:
|
|||||||
if (m_supportsDefaults) {
|
if (m_supportsDefaults) {
|
||||||
if (line[0] == '*') {
|
if (line[0] == '*') {
|
||||||
row[0] = row[0].substr(1);
|
row[0] = row[0].substr(1);
|
||||||
defaults.push_back(row);
|
result = addDefaultFromFile(defaults, row, it, filename, lineNo);
|
||||||
continue;
|
if (result == RESULT_OK)
|
||||||
}
|
continue;
|
||||||
result = addFromFile(it, end, arg, &defaults, filename, lineNo);
|
} else
|
||||||
|
result = addFromFile(it, end, arg, &defaults, filename, lineNo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
result = addFromFile(it, end, arg, NULL, filename, lineNo);
|
result = addFromFile(it, end, arg, NULL, filename, lineNo);
|
||||||
@@ -154,7 +155,7 @@ public:
|
|||||||
m_lastError = error.str();
|
m_lastError = error.str();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
printErrorPos(row.begin(), end, it, filename, lineNo, result);
|
printErrorPos(cout, row.begin(), end, it, filename, lineNo, result);
|
||||||
} else if (!verbose)
|
} else if (!verbose)
|
||||||
m_lastError = "";
|
m_lastError = "";
|
||||||
}
|
}
|
||||||
@@ -169,6 +170,21 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual string getLastError() { return m_lastError; }
|
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<string> >& defaults, vector<string>& row, vector<string>::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.
|
* Add a definition that was read from a file.
|
||||||
* @param begin an iterator to the first column of the definition row to read.
|
* @param begin an iterator to the first column of the definition row to read.
|
||||||
|
|||||||
Reference in New Issue
Block a user