#4683 clang-format on all files in ApplicationCode

This commit is contained in:
Magne Sjaastad
2019-09-06 10:40:57 +02:00
parent 3a317504bb
commit fe9e567825
2092 changed files with 117952 additions and 111846 deletions

View File

@@ -1,72 +1,67 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RicfObjectCapability.h"
#include "cafPdmObjectHandle.h"
#include <QTextStream>
#include "RicfFieldHandle.h"
#include "cafPdmXmlFieldHandle.h"
#include "RicfMessages.h"
#include "cafPdmObjectHandle.h"
#include "cafPdmXmlFieldHandle.h"
#include <QTextStream>
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RicfObjectCapability::RicfObjectCapability(caf::PdmObjectHandle* owner, bool giveOwnership)
RicfObjectCapability::RicfObjectCapability( caf::PdmObjectHandle* owner, bool giveOwnership )
{
m_owner = owner;
m_owner->addCapability(this, giveOwnership);
m_owner->addCapability( this, giveOwnership );
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RicfObjectCapability::~RicfObjectCapability()
{
}
RicfObjectCapability::~RicfObjectCapability() {}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RicfObjectCapability::readFields(QTextStream& inputStream,
caf::PdmObjectFactory* objectFactory,
RicfMessages* errorMessageContainer)
void RicfObjectCapability::readFields( QTextStream& inputStream,
caf::PdmObjectFactory* objectFactory,
RicfMessages* errorMessageContainer )
{
std::set<QString> readFields;
bool isLastArgumentRead = false;
bool isLastArgumentRead = false;
while ( !inputStream.atEnd() && !isLastArgumentRead )
{
// Read field keyword
bool fieldDataFound = false;
bool isEndOfArgumentFound = false;
bool fieldDataFound = false;
bool isEndOfArgumentFound = false;
QString keyword;
{
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
errorMessageContainer->skipWhiteSpaceWithLineNumberCount( inputStream );
{
QChar currentChar;
while (!inputStream.atEnd())
while ( !inputStream.atEnd() )
{
currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
currentChar = errorMessageContainer->readCharWithLineNumberCount( inputStream );
if (currentChar == QChar('=') || currentChar == QChar(')') || currentChar == QChar(',') || currentChar.isSpace())
if ( currentChar == QChar( '=' ) || currentChar == QChar( ')' ) || currentChar == QChar( ',' ) ||
currentChar.isSpace() )
{
break;
}
@@ -74,105 +69,115 @@ void RicfObjectCapability::readFields(QTextStream& inputStream,
{
keyword += currentChar;
}
}
if (currentChar.isSpace())
if ( currentChar.isSpace() )
{
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
errorMessageContainer->skipWhiteSpaceWithLineNumberCount( inputStream );
currentChar = errorMessageContainer->readCharWithLineNumberCount( inputStream );
}
if (currentChar == QChar('='))
if ( currentChar == QChar( '=' ) )
{
fieldDataFound = true;
}
else if (currentChar == QChar(')'))
else if ( currentChar == QChar( ')' ) )
{
if (!keyword.isNull())
if ( !keyword.isNull() )
{
errorMessageContainer->addError(QString("Can't find the '=' after the argument named '%1' in the command '%2'").arg(keyword).arg(errorMessageContainer->currentCommand));
errorMessageContainer->addError(
QString( "Can't find the '=' after the argument named '%1' in the command '%2'" )
.arg( keyword )
.arg( errorMessageContainer->currentCommand ) );
}
isLastArgumentRead = true;
}
else if (currentChar == QChar(','))
else if ( currentChar == QChar( ',' ) )
{
errorMessageContainer->addError(QString("Can't find the '=' after the argument named '%1' in the command '%2'").arg(keyword).arg(errorMessageContainer->currentCommand));
errorMessageContainer->addError(
QString( "Can't find the '=' after the argument named '%1' in the command '%2'" )
.arg( keyword )
.arg( errorMessageContainer->currentCommand ) );
isEndOfArgumentFound = true;
}
else
{
errorMessageContainer->addError(QString("Can't find the '=' after the argument named '%1' in the command '%2'").arg(keyword).arg(errorMessageContainer->currentCommand));
errorMessageContainer->addError(
QString( "Can't find the '=' after the argument named '%1' in the command '%2'" )
.arg( keyword )
.arg( errorMessageContainer->currentCommand ) );
}
}
if ( readFields.count(keyword) )
if ( readFields.count( keyword ) )
{
// Warning message: Referenced the same argument several times
errorMessageContainer->addWarning("The argument: \"" + keyword + "\" is referenced several times in the command: \"" + errorMessageContainer->currentCommand + "\"" );
errorMessageContainer->addWarning( "The argument: \"" + keyword +
"\" is referenced several times in the command: \"" +
errorMessageContainer->currentCommand + "\"" );
}
}
if (fieldDataFound)
if ( fieldDataFound )
{
// Make field read its data
caf::PdmFieldHandle* fieldHandle = m_owner->findField(keyword);
caf::PdmFieldHandle* fieldHandle = m_owner->findField( keyword );
if ( fieldHandle && fieldHandle->xmlCapability() && fieldHandle->capability<RicfFieldHandle>() )
{
caf::PdmXmlFieldHandle* xmlFieldHandle = fieldHandle->xmlCapability();
RicfFieldHandle* rcfField = fieldHandle->capability<RicfFieldHandle>();
RicfFieldHandle* rcfField = fieldHandle->capability<RicfFieldHandle>();
if ( xmlFieldHandle->isIOReadable() )
{
errorMessageContainer->currentArgument = keyword;
rcfField->readFieldData(inputStream, objectFactory, errorMessageContainer);
rcfField->readFieldData( inputStream, objectFactory, errorMessageContainer );
errorMessageContainer->currentArgument = keyword;
}
}
else
{
// Error message: Unknown argument name
errorMessageContainer->addWarning("The argument: \"" + keyword + "\" does not exist in the command: \"" + errorMessageContainer->currentCommand + "\"");
errorMessageContainer->addWarning( "The argument: \"" + keyword + "\" does not exist in the command: \"" +
errorMessageContainer->currentCommand + "\"" );
}
}
// Skip to end of argument ',' or end of call ')'
if (!(isLastArgumentRead || isEndOfArgumentFound) )
// Skip to end of argument ',' or end of call ')'
if ( !( isLastArgumentRead || isEndOfArgumentFound ) )
{
QChar currentChar;
bool isOutsideQuotes = true;
bool isOutsideQuotes = true;
while ( !inputStream.atEnd() )
{
currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
currentChar = errorMessageContainer->readCharWithLineNumberCount( inputStream );
if ( isOutsideQuotes )
{
if ( currentChar == QChar(',') )
if ( currentChar == QChar( ',' ) )
{
break;
}
if ( currentChar == QChar(')') )
if ( currentChar == QChar( ')' ) )
{
isLastArgumentRead = true;
break;
}
if ( currentChar == QChar('\"') )
if ( currentChar == QChar( '\"' ) )
{
isOutsideQuotes = false;
}
}
else
{
if ( currentChar == QChar('\"') )
if ( currentChar == QChar( '\"' ) )
{
isOutsideQuotes = true;
}
if ( currentChar == QChar('\\') )
if ( currentChar == QChar( '\\' ) )
{
currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
currentChar = errorMessageContainer->readCharWithLineNumberCount( inputStream );
}
}
}
@@ -181,21 +186,21 @@ void RicfObjectCapability::readFields(QTextStream& inputStream,
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RicfObjectCapability::writeFields(QTextStream& outputStream) const
void RicfObjectCapability::writeFields( QTextStream& outputStream ) const
{
std::vector<caf::PdmFieldHandle*> fields;
m_owner->fields(fields);
m_owner->fields( fields );
int writtenFieldCount = 0;
for ( size_t it = 0; it < fields.size(); ++it )
{
const caf::PdmXmlFieldHandle* xmlField = fields[it]->xmlCapability();
const RicfFieldHandle* rcfField = fields[it]->capability<RicfFieldHandle>();
const RicfFieldHandle* rcfField = fields[it]->capability<RicfFieldHandle>();
if ( rcfField && xmlField && xmlField->isIOWritable() )
{
QString keyword = xmlField->fieldHandle()->keyword();
CAF_ASSERT(caf::PdmXmlObjectHandle::isValidXmlElementName(keyword));
CAF_ASSERT( caf::PdmXmlObjectHandle::isValidXmlElementName( keyword ) );
if ( writtenFieldCount >= 1 )
{
@@ -203,8 +208,8 @@ void RicfObjectCapability::writeFields(QTextStream& outputStream) const
}
outputStream << keyword << " = ";
rcfField->writeFieldData(outputStream);
rcfField->writeFieldData( outputStream );
writtenFieldCount++;
}
}