add optional clear flag to splitFields

This commit is contained in:
John
2022-04-30 15:36:48 +02:00
parent b20b81ae32
commit 101d0fcdfb
2 changed files with 6 additions and 3 deletions
+4 -2
View File
@@ -219,8 +219,10 @@ static size_t hashFunction(const string& str) {
}
bool FileReader::splitFields(istream* stream, vector<string>* row, unsigned int* lineNo,
size_t* hash, size_t* size) {
row->clear();
size_t* hash, size_t* size, bool clear) {
if (clear) {
row->clear();
}
string line;
bool quotedText = false, wasQuoted = false;
ostringstream field;
+2 -1
View File
@@ -162,10 +162,11 @@ class FileReader {
* @param lineNo the current line number (incremented with each line read).
* @param hash optional pointer to a @a size_t value for combining the hash of the line with, or nullptr.
* @param size optional pointer to a @a size_t value to add the trimmed line length to, or nullptr.
* @param clear whether to clear the fields before adding any.
* @return true if there are more lines to read, false when there are no more lines left.
*/
static bool splitFields(istream* stream, vector<string>* row, unsigned int* lineNo,
size_t* hash = nullptr, size_t* size = nullptr);
size_t* hash = nullptr, size_t* size = nullptr, bool clear = true);
/**
* Format the specified hash as 8 hex digits to the output stream.