diff options
| author | 2017-02-09 04:37:26 -0500 | |
|---|---|---|
| committer | 2017-02-09 04:37:26 -0500 | |
| commit | c9d6debf9015b7853c3e061bbc64a555d85e2fcd (patch) | |
| tree | 53341bc57ae9fbad2beb5b6c08d97a68bee0ec8e /SQLiteStudio3/coreSQLiteStudio/csvserializer.cpp | |
| parent | d5caba2b1f36dc3b92fa705a06097d0597fa2ddd (diff) | |
| parent | d9aa870e5d509cc7309ab82dd102a937ab58613a (diff) | |
Merge tag 'upstream/3.1.1+dfsg1'
Upstream version 3.1.1+dfsg1
# gpg: Signature made Thu 09 Feb 2017 04:37:24 AM EST
# gpg: using RSA key 5001E1B09AA3744B
# gpg: issuer "unit193@ubuntu.com"
# gpg: Good signature from "Unit 193 <unit193@ubuntu.com>" [unknown]
# gpg: aka "Unit 193 <unit193@gmail.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg: There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 8DB3 E586 865D 2B4A 2B18 5A5C 5001 E1B0 9AA3 744B
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> |
