mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-10 23:46:00 -06:00
FileParseTools. Add new split method
This commit is contained in:
parent
2c5c007048
commit
698fbb980d
@ -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();
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include <QRegExp>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -28,7 +28,8 @@
|
||||
class RifFileParseTools
|
||||
{
|
||||
public:
|
||||
static QStringList splitLineAndTrim(const QString& line, const QString& separator);
|
||||
static QStringList splitLineAndTrim(const QString& line, const QString& separator, bool skipEmptyParts = false);
|
||||
static QStringList splitLineAndTrim(const QString& line, const QRegExp& regexp, bool skipEmptyParts = false);
|
||||
};
|
||||
|
||||
//==================================================================================================
|
||||
|
Loading…
Reference in New Issue
Block a user