diff options
| author | 2017-02-09 04:36:04 -0500 | |
|---|---|---|
| committer | 2017-02-09 04:36:04 -0500 | |
| commit | d9aa870e5d509cc7309ab82dd102a937ab58613a (patch) | |
| tree | d92d03d76b5c390b335f1cfd761f1a0b59ec8496 /SQLiteStudio3/coreSQLiteStudio/csvserializer.cpp | |
| parent | 68ee4cbcbe424b95969c70346283a9f217f63825 (diff) | |
Imported Upstream version 3.1.1+dfsg1upstream/3.1.1+dfsg1
Diffstat (limited to 'SQLiteStudio3/coreSQLiteStudio/csvserializer.cpp')
| -rw-r--r-- | SQLiteStudio3/coreSQLiteStudio/csvserializer.cpp | 60 |
1 files changed, 44 insertions, 16 deletions
diff --git a/SQLiteStudio3/coreSQLiteStudio/csvserializer.cpp b/SQLiteStudio3/coreSQLiteStudio/csvserializer.cpp index 15bf4e8..ce568e9 100644 --- a/SQLiteStudio3/coreSQLiteStudio/csvserializer.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/csvserializer.cpp @@ -10,20 +10,34 @@ bool isCsvColumnSeparator(QTextStream& data, const C& theChar, const CsvFormat& return format.columnSeparator.contains(theChar); // Strict checking (characters in defined order make a separator) + QStringList separators; + if (format.multipleColumnSeparators) + separators = format.columnSeparators; + else + separators << format.columnSeparator; + qint64 origPos = data.pos(); - data.seek(origPos - 1); - C nextChar; - for (const QChar& c : format.columnSeparator) + bool match = true; + for (const QString sep : separators) { - data >> nextChar; - if (c != nextChar) + match = true; + data.seek(origPos - 1); + C nextChar; + for (const QChar& c : sep) { - data.seek(origPos); - return false; + data >> nextChar; + if (c != nextChar) + { + data.seek(origPos); + match = false; + break; + } } + if (match) + break; } - return true; + return match; } template <class C> @@ -33,20 +47,34 @@ bool isCsvRowSeparator(QTextStream& data, const C& theChar, const CsvFormat& for return format.rowSeparator.contains(theChar); // Strict checking (characters in defined order make a separator) + QStringList separators; + if (format.multipleRowSeparators) + separators = format.rowSeparators; + else + separators << format.rowSeparator; + qint64 origPos = data.pos(); - data.seek(origPos - 1); - C nextChar; - for (const QChar& c : format.rowSeparator) + bool match = true; + for (const QString sep : separators) { - data >> nextChar; - if (data.atEnd() || c != nextChar) + match = true; + data.seek(origPos - 1); + C nextChar; + for (const QChar& c : sep) { - data.seek(origPos); - return false; + data >> nextChar; + if (data.atEnd() || c != nextChar) + { + data.seek(origPos); + match = false; + break; + } } + if (match) + break; } - return true; + return match; } template <class T, class C> |
