diff options
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> |
