mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-16 18:32:10 -05:00
#4683 clang-format on all files in ApplicationCode
This commit is contained in:
1 parent
3a317504bb
commit
fe9e567825
2092 files changed
+117952
-111846
No files matched your search
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA
|
||||
//
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -22,30 +22,30 @@
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaStdStringTools.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QDir>
|
||||
|
||||
#include <functional>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Constants
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#define PARAMETERS_FILE_NAME "parameters.txt"
|
||||
#define RUNSPEC_FILE_NAME "runspecification.xml"
|
||||
#define PARAMETERS_FILE_NAME "parameters.txt"
|
||||
#define RUNSPEC_FILE_NAME "runspecification.xml"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifCaseRealizationReader::RifCaseRealizationReader(const QString& fileName)
|
||||
RifCaseRealizationReader::RifCaseRealizationReader( const QString& fileName )
|
||||
{
|
||||
m_parameters = std::shared_ptr<RigCaseRealizationParameters>(new RigCaseRealizationParameters());
|
||||
m_fileName = fileName;
|
||||
m_file = nullptr;
|
||||
m_parameters = std::shared_ptr<RigCaseRealizationParameters>( new RigCaseRealizationParameters() );
|
||||
m_fileName = fileName;
|
||||
m_file = nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifCaseRealizationReader::~RifCaseRealizationReader()
|
||||
{
|
||||
@@ -53,7 +53,7 @@ RifCaseRealizationReader::~RifCaseRealizationReader()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::shared_ptr<RigCaseRealizationParameters> RifCaseRealizationReader::parameters() const
|
||||
{
|
||||
@@ -61,46 +61,46 @@ const std::shared_ptr<RigCaseRealizationParameters> RifCaseRealizationReader::pa
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::shared_ptr<RifCaseRealizationReader> RifCaseRealizationReader::createReaderFromFileName(const QString& fileName)
|
||||
std::shared_ptr<RifCaseRealizationReader> RifCaseRealizationReader::createReaderFromFileName( const QString& fileName )
|
||||
{
|
||||
std::shared_ptr<RifCaseRealizationReader> reader;
|
||||
|
||||
if (fileName.endsWith(PARAMETERS_FILE_NAME))
|
||||
if ( fileName.endsWith( PARAMETERS_FILE_NAME ) )
|
||||
{
|
||||
reader.reset(new RifCaseRealizationParametersReader(fileName));
|
||||
reader.reset( new RifCaseRealizationParametersReader( fileName ) );
|
||||
}
|
||||
else if (fileName.endsWith(RUNSPEC_FILE_NAME))
|
||||
else if ( fileName.endsWith( RUNSPEC_FILE_NAME ) )
|
||||
{
|
||||
reader.reset(new RifCaseRealizationRunspecificationReader(fileName));
|
||||
reader.reset( new RifCaseRealizationRunspecificationReader( fileName ) );
|
||||
}
|
||||
return reader;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QFile* RifCaseRealizationReader::openFile()
|
||||
{
|
||||
if (!m_file)
|
||||
if ( !m_file )
|
||||
{
|
||||
m_file = new QFile(m_fileName);
|
||||
if (!m_file->open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
m_file = new QFile( m_fileName );
|
||||
if ( !m_file->open( QIODevice::ReadOnly | QIODevice::Text ) )
|
||||
{
|
||||
closeFile();
|
||||
throw FileParseException(QString("Failed to open %1").arg(m_fileName));
|
||||
throw FileParseException( QString( "Failed to open %1" ).arg( m_fileName ) );
|
||||
}
|
||||
}
|
||||
return m_file;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifCaseRealizationReader::closeFile()
|
||||
{
|
||||
if (m_file)
|
||||
if ( m_file )
|
||||
{
|
||||
m_file->close();
|
||||
delete m_file;
|
||||
@@ -109,75 +109,78 @@ void RifCaseRealizationReader::closeFile()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifCaseRealizationParametersReader::RifCaseRealizationParametersReader(const QString& fileName) :
|
||||
RifCaseRealizationReader(fileName)
|
||||
RifCaseRealizationParametersReader::RifCaseRealizationParametersReader( const QString& fileName )
|
||||
: RifCaseRealizationReader( fileName )
|
||||
{
|
||||
m_textStream = nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifCaseRealizationParametersReader::~RifCaseRealizationParametersReader()
|
||||
{
|
||||
if (m_textStream)
|
||||
if ( m_textStream )
|
||||
{
|
||||
delete m_textStream;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifCaseRealizationParametersReader::parse()
|
||||
{
|
||||
int lineNo = 0;
|
||||
QTextStream* dataStream = openDataStream();
|
||||
int lineNo = 0;
|
||||
QTextStream* dataStream = openDataStream();
|
||||
|
||||
try
|
||||
{
|
||||
while (!dataStream->atEnd())
|
||||
while ( !dataStream->atEnd() )
|
||||
{
|
||||
QString line = dataStream->readLine();
|
||||
|
||||
lineNo++;
|
||||
QStringList cols = RifFileParseTools::splitLineAndTrim(line, QRegExp("[ \t]"), true);
|
||||
QStringList cols = RifFileParseTools::splitLineAndTrim( line, QRegExp( "[ \t]" ), true );
|
||||
|
||||
if (cols.size() != 2)
|
||||
if ( cols.size() != 2 )
|
||||
{
|
||||
throw FileParseException(QString("RifEnsembleParametersReader: Invalid file format in line %1").arg(lineNo));
|
||||
throw FileParseException(
|
||||
QString( "RifEnsembleParametersReader: Invalid file format in line %1" ).arg( lineNo ) );
|
||||
}
|
||||
|
||||
QString& name = cols[0];
|
||||
QString& name = cols[0];
|
||||
QString& strValue = cols[1];
|
||||
|
||||
if (RiaStdStringTools::startsWithAlphabetic(strValue.toStdString()))
|
||||
if ( RiaStdStringTools::startsWithAlphabetic( strValue.toStdString() ) )
|
||||
{
|
||||
m_parameters->addParameter(name, strValue);
|
||||
m_parameters->addParameter( name, strValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!RiaStdStringTools::isNumber(strValue.toStdString(), QLocale::c().decimalPoint().toLatin1()))
|
||||
if ( !RiaStdStringTools::isNumber( strValue.toStdString(), QLocale::c().decimalPoint().toLatin1() ) )
|
||||
{
|
||||
throw FileParseException(QString("RifEnsembleParametersReader: Invalid number format in line %1").arg(lineNo));
|
||||
throw FileParseException(
|
||||
QString( "RifEnsembleParametersReader: Invalid number format in line %1" ).arg( lineNo ) );
|
||||
}
|
||||
|
||||
bool parseOk = true;
|
||||
double value = QLocale::c().toDouble(strValue, &parseOk);
|
||||
if (!parseOk)
|
||||
bool parseOk = true;
|
||||
double value = QLocale::c().toDouble( strValue, &parseOk );
|
||||
if ( !parseOk )
|
||||
{
|
||||
throw FileParseException(QString("RifEnsembleParametersReader: Invalid number format in line %1").arg(lineNo));
|
||||
throw FileParseException(
|
||||
QString( "RifEnsembleParametersReader: Invalid number format in line %1" ).arg( lineNo ) );
|
||||
}
|
||||
|
||||
m_parameters->addParameter(name, value);
|
||||
m_parameters->addParameter( name, value );
|
||||
}
|
||||
}
|
||||
|
||||
closeDataStream();
|
||||
}
|
||||
catch (...)
|
||||
catch ( ... )
|
||||
{
|
||||
closeDataStream();
|
||||
throw;
|
||||
@@ -185,22 +188,22 @@ void RifCaseRealizationParametersReader::parse()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QTextStream* RifCaseRealizationParametersReader::openDataStream()
|
||||
{
|
||||
auto file = openFile();
|
||||
|
||||
m_textStream = new QTextStream(file);
|
||||
m_textStream = new QTextStream( file );
|
||||
return m_textStream;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifCaseRealizationParametersReader::closeDataStream()
|
||||
{
|
||||
if (m_textStream)
|
||||
if ( m_textStream )
|
||||
{
|
||||
delete m_textStream;
|
||||
m_textStream = nullptr;
|
||||
@@ -209,80 +212,85 @@ void RifCaseRealizationParametersReader::closeDataStream()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifCaseRealizationRunspecificationReader::RifCaseRealizationRunspecificationReader(const QString& fileName) :
|
||||
RifCaseRealizationReader(fileName)
|
||||
RifCaseRealizationRunspecificationReader::RifCaseRealizationRunspecificationReader( const QString& fileName )
|
||||
: RifCaseRealizationReader( fileName )
|
||||
{
|
||||
m_xmlStream = nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifCaseRealizationRunspecificationReader::~RifCaseRealizationRunspecificationReader()
|
||||
{
|
||||
if (m_xmlStream)
|
||||
if ( m_xmlStream )
|
||||
{
|
||||
delete m_xmlStream;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifCaseRealizationRunspecificationReader::parse()
|
||||
{
|
||||
auto xml = openDataStream();
|
||||
auto xml = openDataStream();
|
||||
QString paramName;
|
||||
|
||||
while (!xml->atEnd())
|
||||
while ( !xml->atEnd() )
|
||||
{
|
||||
xml->readNext();
|
||||
|
||||
if (xml->isStartElement())
|
||||
if ( xml->isStartElement() )
|
||||
{
|
||||
if (xml->name() == "modifier")
|
||||
if ( xml->name() == "modifier" )
|
||||
{
|
||||
paramName = "";
|
||||
}
|
||||
|
||||
if (xml->name() == "id")
|
||||
if ( xml->name() == "id" )
|
||||
{
|
||||
paramName = xml->readElementText();
|
||||
}
|
||||
|
||||
if(xml->name() == "value")
|
||||
if ( xml->name() == "value" )
|
||||
{
|
||||
QString paramStrValue = xml->readElementText();
|
||||
|
||||
if (paramName.isEmpty()) continue;
|
||||
if ( paramName.isEmpty() ) continue;
|
||||
|
||||
if (RiaStdStringTools::startsWithAlphabetic(paramStrValue.toStdString()))
|
||||
if ( RiaStdStringTools::startsWithAlphabetic( paramStrValue.toStdString() ) )
|
||||
{
|
||||
m_parameters->addParameter(paramName, paramStrValue);
|
||||
m_parameters->addParameter( paramName, paramStrValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!RiaStdStringTools::isNumber(paramStrValue.toStdString(), QLocale::c().decimalPoint().toLatin1()))
|
||||
if ( !RiaStdStringTools::isNumber( paramStrValue.toStdString(),
|
||||
QLocale::c().decimalPoint().toLatin1() ) )
|
||||
{
|
||||
throw FileParseException(QString("RifEnsembleParametersReader: Invalid number format in line %1").arg(xml->lineNumber()));
|
||||
throw FileParseException(
|
||||
QString( "RifEnsembleParametersReader: Invalid number format in line %1" )
|
||||
.arg( xml->lineNumber() ) );
|
||||
}
|
||||
|
||||
bool parseOk = true;
|
||||
double value = QLocale::c().toDouble(paramStrValue, &parseOk);
|
||||
if (!parseOk)
|
||||
bool parseOk = true;
|
||||
double value = QLocale::c().toDouble( paramStrValue, &parseOk );
|
||||
if ( !parseOk )
|
||||
{
|
||||
throw FileParseException(QString("RifEnsembleParametersReader: Invalid number format in line %1").arg(xml->lineNumber()));
|
||||
throw FileParseException(
|
||||
QString( "RifEnsembleParametersReader: Invalid number format in line %1" )
|
||||
.arg( xml->lineNumber() ) );
|
||||
}
|
||||
|
||||
m_parameters->addParameter(paramName, value);
|
||||
m_parameters->addParameter( paramName, value );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (xml->isEndElement())
|
||||
else if ( xml->isEndElement() )
|
||||
{
|
||||
if (xml->name() == "modifier")
|
||||
if ( xml->name() == "modifier" )
|
||||
{
|
||||
paramName = "";
|
||||
}
|
||||
@@ -291,22 +299,22 @@ void RifCaseRealizationRunspecificationReader::parse()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QXmlStreamReader * RifCaseRealizationRunspecificationReader::openDataStream()
|
||||
QXmlStreamReader* RifCaseRealizationRunspecificationReader::openDataStream()
|
||||
{
|
||||
auto file = openFile();
|
||||
|
||||
m_xmlStream = new QXmlStreamReader(file);
|
||||
m_xmlStream = new QXmlStreamReader( file );
|
||||
return m_xmlStream;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifCaseRealizationRunspecificationReader::closeDataStream()
|
||||
{
|
||||
if (m_xmlStream)
|
||||
if ( m_xmlStream )
|
||||
{
|
||||
delete m_xmlStream;
|
||||
m_xmlStream = nullptr;
|
||||
@@ -315,33 +323,35 @@ void RifCaseRealizationRunspecificationReader::closeDataStream()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RifCaseRealizationParametersFileLocator::locate(const QString& modelPath)
|
||||
QString RifCaseRealizationParametersFileLocator::locate( const QString& modelPath )
|
||||
{
|
||||
int MAX_LEVELS_UP = 3;
|
||||
int dirLevel = 0;
|
||||
int MAX_LEVELS_UP = 3;
|
||||
int dirLevel = 0;
|
||||
|
||||
QDir qdir(modelPath);
|
||||
QDir qdir( modelPath );
|
||||
|
||||
const QFileInfo dir(modelPath);
|
||||
if (dir.isFile()) qdir.cdUp();
|
||||
else if (!dir.isDir()) return "";
|
||||
const QFileInfo dir( modelPath );
|
||||
if ( dir.isFile() )
|
||||
qdir.cdUp();
|
||||
else if ( !dir.isDir() )
|
||||
return "";
|
||||
|
||||
do
|
||||
{
|
||||
QStringList files = qdir.entryList(QDir::Files | QDir::NoDotAndDotDot);
|
||||
for (const QString& file : files)
|
||||
QStringList files = qdir.entryList( QDir::Files | QDir::NoDotAndDotDot );
|
||||
for ( const QString& file : files )
|
||||
{
|
||||
if (QString::compare(file, PARAMETERS_FILE_NAME, Qt::CaseInsensitive) == 0 ||
|
||||
QString::compare(file, RUNSPEC_FILE_NAME, Qt::CaseInsensitive) == 0)
|
||||
if ( QString::compare( file, PARAMETERS_FILE_NAME, Qt::CaseInsensitive ) == 0 ||
|
||||
QString::compare( file, RUNSPEC_FILE_NAME, Qt::CaseInsensitive ) == 0 )
|
||||
{
|
||||
return qdir.absoluteFilePath(file);
|
||||
return qdir.absoluteFilePath( file );
|
||||
}
|
||||
}
|
||||
qdir.cdUp();
|
||||
|
||||
} while (dirLevel++ < MAX_LEVELS_UP);
|
||||
} while ( dirLevel++ < MAX_LEVELS_UP );
|
||||
|
||||
return "";
|
||||
}
|
||||
Reference in new issue
Block a user