mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4683 clang-format on all files in ApplicationCode
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -19,117 +19,117 @@
|
||||
#include "RifcCommandFileReader.h"
|
||||
|
||||
#include "RicfCommandObject.h"
|
||||
#include "RicfObjectCapability.h"
|
||||
#include "RicfMessages.h"
|
||||
#include "RicfObjectCapability.h"
|
||||
|
||||
#include "cafPdmObjectFactory.h"
|
||||
|
||||
#include <QTextStream>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RicfCommandObject*> RicfCommandFileReader::readCommands(QTextStream& inputStream,
|
||||
caf::PdmObjectFactory* objectFactory,
|
||||
RicfMessages* errorMessageContainer)
|
||||
std::vector<RicfCommandObject*> RicfCommandFileReader::readCommands( QTextStream& inputStream,
|
||||
caf::PdmObjectFactory* objectFactory,
|
||||
RicfMessages* errorMessageContainer )
|
||||
{
|
||||
std::vector<RicfCommandObject*> readCommands;
|
||||
|
||||
while ( !inputStream.atEnd() )
|
||||
{
|
||||
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
|
||||
errorMessageContainer->skipWhiteSpaceWithLineNumberCount( inputStream );
|
||||
// Read command name
|
||||
QString commandName;
|
||||
{
|
||||
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
|
||||
errorMessageContainer->skipWhiteSpaceWithLineNumberCount( inputStream );
|
||||
while ( !inputStream.atEnd() )
|
||||
{
|
||||
QChar currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream);
|
||||
QChar currentChar = errorMessageContainer->readCharWithLineNumberCount( inputStream );
|
||||
|
||||
if (currentChar == QChar('#'))
|
||||
if ( currentChar == QChar( '#' ) )
|
||||
{
|
||||
errorMessageContainer->skipLineWithLineNumberCount(inputStream);
|
||||
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
|
||||
errorMessageContainer->skipLineWithLineNumberCount( inputStream );
|
||||
errorMessageContainer->skipWhiteSpaceWithLineNumberCount( inputStream );
|
||||
currentChar = QChar();
|
||||
}
|
||||
else if ( currentChar.isSpace() )
|
||||
{
|
||||
errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream);
|
||||
QChar isBracket('a');
|
||||
isBracket = errorMessageContainer->readCharWithLineNumberCount(inputStream);
|
||||
if ( isBracket != QChar('(') )
|
||||
errorMessageContainer->skipWhiteSpaceWithLineNumberCount( inputStream );
|
||||
QChar isBracket( 'a' );
|
||||
isBracket = errorMessageContainer->readCharWithLineNumberCount( inputStream );
|
||||
if ( isBracket != QChar( '(' ) )
|
||||
{
|
||||
// Error, could not find start bracket for command
|
||||
errorMessageContainer->addError("Could not find start bracket for command " + commandName);
|
||||
errorMessageContainer->addError( "Could not find start bracket for command " + commandName );
|
||||
|
||||
return readCommands;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if ( currentChar == QChar('(') )
|
||||
else if ( currentChar == QChar( '(' ) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (!currentChar.isNull())
|
||||
if ( !currentChar.isNull() )
|
||||
{
|
||||
commandName += currentChar;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (commandName.isEmpty() && inputStream.atEnd())
|
||||
if ( commandName.isEmpty() && inputStream.atEnd() )
|
||||
{
|
||||
// Read past the last command
|
||||
break;
|
||||
}
|
||||
|
||||
CAF_ASSERT(objectFactory);
|
||||
caf::PdmObjectHandle* obj = objectFactory->create(commandName);
|
||||
RicfCommandObject* cObj = dynamic_cast<RicfCommandObject*>(obj);
|
||||
CAF_ASSERT( objectFactory );
|
||||
caf::PdmObjectHandle* obj = objectFactory->create( commandName );
|
||||
RicfCommandObject* cObj = dynamic_cast<RicfCommandObject*>( obj );
|
||||
|
||||
if ( cObj == nullptr )
|
||||
{
|
||||
errorMessageContainer->addError("The command: \"" + commandName + "\" does not exist.");
|
||||
errorMessageContainer->addError( "The command: \"" + commandName + "\" does not exist." );
|
||||
|
||||
// Error: Unknown command
|
||||
// Skip to end of command
|
||||
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( '\"' ) )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
readCommands.push_back(cObj);
|
||||
auto rcfCap = cObj->capability<RicfObjectCapability>();
|
||||
readCommands.push_back( cObj );
|
||||
auto rcfCap = cObj->capability<RicfObjectCapability>();
|
||||
errorMessageContainer->currentCommand = commandName;
|
||||
rcfCap->readFields(inputStream, objectFactory, errorMessageContainer);
|
||||
rcfCap->readFields( inputStream, objectFactory, errorMessageContainer );
|
||||
errorMessageContainer->currentCommand = "";
|
||||
}
|
||||
}
|
||||
@@ -138,19 +138,20 @@ std::vector<RicfCommandObject*> RicfCommandFileReader::readCommands(QTextStream&
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicfCommandFileReader::writeCommands(QTextStream& outputStream, const std::vector<RicfCommandObject*>& commandsToWrite)
|
||||
void RicfCommandFileReader::writeCommands( QTextStream& outputStream,
|
||||
const std::vector<RicfCommandObject*>& commandsToWrite )
|
||||
{
|
||||
for (const auto& cmdObj : commandsToWrite)
|
||||
for ( const auto& cmdObj : commandsToWrite )
|
||||
{
|
||||
auto rcfCap = cmdObj->capability<RicfObjectCapability>();
|
||||
if (!rcfCap) continue;
|
||||
if ( !rcfCap ) continue;
|
||||
|
||||
outputStream << cmdObj->classKeyword();
|
||||
outputStream << "(";
|
||||
|
||||
rcfCap->writeFields(outputStream);
|
||||
rcfCap->writeFields( outputStream );
|
||||
|
||||
outputStream << ")";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user