FileParseTools. Add new split method

This commit is contained in:
Bjørn Erik Jensen
2018-09-03 10:37:19 +02:00
parent 2c5c007048
commit 698fbb980d
2 changed files with 18 additions and 4 deletions

View File

@@ -22,9 +22,22 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList RifFileParseTools::splitLineAndTrim(const QString& line, const QString& separator)
QStringList RifFileParseTools::splitLineAndTrim(const QString& line, const QString& separator, bool skipEmptyParts)
{
QStringList cols = line.split(separator);
QStringList cols = line.trimmed().split(separator, skipEmptyParts ? QString::SkipEmptyParts : QString::KeepEmptyParts);
for (QString& col : cols)
{
col = col.trimmed();
}
return cols;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QStringList RifFileParseTools::splitLineAndTrim(const QString& line, const QRegExp& regexp, bool skipEmptyParts)
{
QStringList cols = line.trimmed().split(regexp, skipEmptyParts ? QString::SkipEmptyParts : QString::KeepEmptyParts);
for (QString& col : cols)
{
col = col.trimmed();