Compose row string from values @input: - values - list of values in rows @output: - QString - result row string
| 93 | // @output: |
| 94 | // - QString - result row string |
| 95 | QString ContentIterator::composeRow(const QList<QString>& values) const { |
| 96 | QList<QString> rowValues = values; |
| 97 | const QString twoDelimiters = m_textDelimiter + m_textDelimiter; |
| 98 | for (auto i = 0; i < rowValues.size(); ++i) { |
| 99 | rowValues[i].replace(m_textDelimiter, twoDelimiters); |
| 100 | |
| 101 | QString delimiter = m_textDelimiter; |
| 102 | if (delimiter.isEmpty() && |
| 103 | (rowValues.at(i).contains(m_separator) || |
| 104 | rowValues.at(i).contains(CR) || rowValues.at(i).contains(LF))) |
| 105 | { |
| 106 | delimiter = DOUBLE_QUOTE; |
| 107 | } |
| 108 | |
| 109 | rowValues[i].prepend(delimiter); |
| 110 | rowValues[i].append(delimiter); |
| 111 | } |
| 112 | |
| 113 | QString result = rowValues.join(m_separator); |
| 114 | result.append(LF); |
| 115 | return result; |
| 116 | } |