mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Move RicfMessages to CAF and simplify RicfFieldCapability
This commit is contained in:
@@ -36,7 +36,6 @@
|
||||
#include "RicImportGeneralDataFeature.h"
|
||||
#include "RicfCommandFileExecutor.h"
|
||||
#include "RicfFieldHandle.h"
|
||||
#include "RicfMessages.h"
|
||||
#include "RicfObjectCapability.h"
|
||||
|
||||
#include "Rim2dIntersectionViewCollection.h"
|
||||
@@ -98,6 +97,7 @@
|
||||
#include "cafPdmCodeGenerator.h"
|
||||
#include "cafPdmDataValueField.h"
|
||||
#include "cafPdmDefaultObjectFactory.h"
|
||||
#include "cafPdmScriptIOMessages.h"
|
||||
#include "cafPdmSettings.h"
|
||||
#include "cafPdmUiModelChangeDetector.h"
|
||||
#include "cafProgressInfo.h"
|
||||
@@ -1260,8 +1260,8 @@ QVariant RiaApplication::cacheDataObject( const QString& key ) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaApplication::executeCommandFile( const QString& commandFile )
|
||||
{
|
||||
QFile file( commandFile );
|
||||
RicfMessages messages;
|
||||
QFile file( commandFile );
|
||||
caf::PdmScriptIOMessages messages;
|
||||
if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
|
||||
{
|
||||
// TODO : Error logging?
|
||||
|
||||
@@ -31,13 +31,13 @@
|
||||
#include "RiuPlotMainWindow.h"
|
||||
|
||||
#include "RicfCommandFileExecutor.h"
|
||||
#include "RicfMessages.h"
|
||||
|
||||
#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h"
|
||||
#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h"
|
||||
#include "ExportCommands/RicSnapshotViewToFileFeature.h"
|
||||
#include "RicImportSummaryCasesFeature.h"
|
||||
|
||||
#include "cafPdmScriptIOMessages.h"
|
||||
#include "cvfProgramOptions.h"
|
||||
#include "cvfqtUtils.h"
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfFieldCapability.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfFieldHandle.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfObjectCapability.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifcCommandFileReader.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfMessages.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -16,7 +15,6 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfFieldCapability.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfFieldHandle.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfObjectCapability.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RifcCommandFileReader.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicfMessages.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicfFieldCapability.h"
|
||||
#include "RicfMessages.h"
|
||||
|
||||
#include "RiaColorTools.h"
|
||||
|
||||
@@ -26,10 +25,10 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicfFieldReader<QString>::readFieldData( QString& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
RicfMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted )
|
||||
void RicfFieldIOHandler<QString>::writeToField( QString& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
caf::PdmScriptIOMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted )
|
||||
{
|
||||
fieldValue = "";
|
||||
|
||||
@@ -99,10 +98,10 @@ void RicfFieldReader<QString>::readFieldData( QString& fieldValue,
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicfFieldWriter<QString>::writeFieldData( const QString& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings,
|
||||
bool quoteNonBuiltin )
|
||||
void RicfFieldIOHandler<QString>::readFromField( const QString& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings,
|
||||
bool quoteNonBuiltin )
|
||||
{
|
||||
outputStream << "\"";
|
||||
for ( int i = 0; i < fieldValue.size(); ++i )
|
||||
@@ -119,10 +118,10 @@ void RicfFieldWriter<QString>::writeFieldData( const QString& fieldValue,
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicfFieldReader<bool>::readFieldData( bool& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
RicfMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted )
|
||||
void RicfFieldIOHandler<bool>::writeToField( bool& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
caf::PdmScriptIOMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted )
|
||||
{
|
||||
errorMessageContainer->skipWhiteSpaceWithLineNumberCount( inputStream );
|
||||
QString accumulatedFieldValue;
|
||||
@@ -158,10 +157,10 @@ void RicfFieldReader<bool>::readFieldData( bool& fieldValue,
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicfFieldWriter<bool>::writeFieldData( const bool& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings,
|
||||
bool quoteNonBuiltin )
|
||||
void RicfFieldIOHandler<bool>::readFromField( const bool& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings,
|
||||
bool quoteNonBuiltin )
|
||||
{
|
||||
// Lower-case true/false is used in the documentation.
|
||||
outputStream << ( fieldValue ? "true" : "false" );
|
||||
@@ -170,13 +169,13 @@ void RicfFieldWriter<bool>::writeFieldData( const bool& fieldValue,
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicfFieldReader<cvf::Color3f>::readFieldData( cvf::Color3f& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
RicfMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted )
|
||||
void RicfFieldIOHandler<cvf::Color3f>::writeToField( cvf::Color3f& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
caf::PdmScriptIOMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted )
|
||||
{
|
||||
QString fieldStringValue;
|
||||
RicfFieldReader<QString>::readFieldData( fieldStringValue, inputStream, errorMessageContainer, stringsAreQuoted );
|
||||
RicfFieldIOHandler<QString>::writeToField( fieldStringValue, inputStream, errorMessageContainer, stringsAreQuoted );
|
||||
|
||||
QColor qColor( fieldStringValue );
|
||||
if ( qColor.isValid() )
|
||||
@@ -188,12 +187,12 @@ void RicfFieldReader<cvf::Color3f>::readFieldData( cvf::Color3f& fieldValue,
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicfFieldWriter<cvf::Color3f>::writeFieldData( const cvf::Color3f& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings,
|
||||
bool quoteNonBuiltin )
|
||||
void RicfFieldIOHandler<cvf::Color3f>::readFromField( const cvf::Color3f& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings,
|
||||
bool quoteNonBuiltin )
|
||||
{
|
||||
QColor qColor = RiaColorTools::toQColor( fieldValue );
|
||||
QString fieldStringValue = qColor.name();
|
||||
RicfFieldWriter<QString>::writeFieldData( fieldStringValue, outputStream, quoteStrings );
|
||||
RicfFieldIOHandler<QString>::readFromField( fieldStringValue, outputStream, quoteStrings );
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "RicfFieldHandle.h"
|
||||
#include "RicfMessages.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmScriptIOMessages.h"
|
||||
|
||||
#include "cvfColor3.h"
|
||||
|
||||
@@ -29,12 +29,12 @@
|
||||
#include <QTextStream>
|
||||
|
||||
template <typename DataType>
|
||||
struct RicfFieldReader
|
||||
struct RicfFieldIOHandler
|
||||
{
|
||||
static void readFieldData( DataType& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
RicfMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted = true )
|
||||
static void writeToField( DataType& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
caf::PdmScriptIOMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted = true )
|
||||
{
|
||||
inputStream >> fieldValue;
|
||||
if ( inputStream.status() == QTextStream::ReadCorruptData )
|
||||
@@ -46,81 +46,62 @@ struct RicfFieldReader
|
||||
inputStream.setStatus( QTextStream::Ok );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename DataType>
|
||||
struct RicfFieldWriter
|
||||
{
|
||||
static void writeFieldData( const DataType& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings = true,
|
||||
bool quoteNonBuiltins = false )
|
||||
static void readFromField( const DataType& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings = true,
|
||||
bool quoteNonBuiltins = false )
|
||||
{
|
||||
outputStream << fieldValue;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct RicfFieldReader<QString>
|
||||
struct RicfFieldIOHandler<QString>
|
||||
{
|
||||
static void readFieldData( QString& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
RicfMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted = true );
|
||||
static void writeToField( QString& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
caf::PdmScriptIOMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted = true );
|
||||
static void readFromField( const QString& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings = true,
|
||||
bool quoteNonBuiltins = false );
|
||||
};
|
||||
|
||||
template <>
|
||||
struct RicfFieldWriter<QString>
|
||||
struct RicfFieldIOHandler<bool>
|
||||
{
|
||||
static void writeFieldData( const QString& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings = true,
|
||||
bool quoteNonBuiltins = false );
|
||||
static void writeToField( bool& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
caf::PdmScriptIOMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted = true );
|
||||
static void readFromField( const bool& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings = true,
|
||||
bool quoteNonBuiltins = false );
|
||||
};
|
||||
|
||||
template <>
|
||||
struct RicfFieldReader<bool>
|
||||
struct RicfFieldIOHandler<cvf::Color3f>
|
||||
{
|
||||
static void readFieldData( bool& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
RicfMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted = true );
|
||||
};
|
||||
|
||||
template <>
|
||||
struct RicfFieldWriter<bool>
|
||||
{
|
||||
static void writeFieldData( const bool& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings = true,
|
||||
bool quoteNonBuiltins = false );
|
||||
};
|
||||
|
||||
template <>
|
||||
struct RicfFieldReader<cvf::Color3f>
|
||||
{
|
||||
static void readFieldData( cvf::Color3f& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
RicfMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted = true );
|
||||
};
|
||||
|
||||
template <>
|
||||
struct RicfFieldWriter<cvf::Color3f>
|
||||
{
|
||||
static void writeFieldData( const cvf::Color3f& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings = true,
|
||||
bool quoteNonBuiltins = false );
|
||||
static void writeToField( cvf::Color3f& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
caf::PdmScriptIOMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted = true );
|
||||
static void readFromField( const cvf::Color3f& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings = true,
|
||||
bool quoteNonBuiltins = false );
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct RicfFieldReader<caf::AppEnum<T>>
|
||||
struct RicfFieldIOHandler<caf::AppEnum<T>>
|
||||
{
|
||||
static void readFieldData( caf::AppEnum<T>& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
RicfMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted = true )
|
||||
static void writeToField( caf::AppEnum<T>& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
caf::PdmScriptIOMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted = true )
|
||||
{
|
||||
errorMessageContainer->skipWhiteSpaceWithLineNumberCount( inputStream );
|
||||
QString accumulatedFieldValue;
|
||||
@@ -148,15 +129,11 @@ struct RicfFieldReader<caf::AppEnum<T>>
|
||||
errorMessageContainer->currentCommand + "\"" );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct RicfFieldWriter<caf::AppEnum<T>>
|
||||
{
|
||||
static void writeFieldData( const caf::AppEnum<T>& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings = true,
|
||||
bool quoteNonBuiltins = false )
|
||||
static void readFromField( const caf::AppEnum<T>& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings = true,
|
||||
bool quoteNonBuiltins = false )
|
||||
{
|
||||
if ( quoteNonBuiltins )
|
||||
{
|
||||
@@ -170,12 +147,12 @@ struct RicfFieldWriter<caf::AppEnum<T>>
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct RicfFieldReader<std::vector<T>>
|
||||
struct RicfFieldIOHandler<std::vector<T>>
|
||||
{
|
||||
static void readFieldData( std::vector<T>& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
RicfMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted = true )
|
||||
static void writeToField( std::vector<T>& fieldValue,
|
||||
QTextStream& inputStream,
|
||||
caf::PdmScriptIOMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted = true )
|
||||
{
|
||||
errorMessageContainer->skipWhiteSpaceWithLineNumberCount( inputStream );
|
||||
QChar chr = errorMessageContainer->readCharWithLineNumberCount( inputStream );
|
||||
@@ -197,7 +174,7 @@ struct RicfFieldReader<std::vector<T>>
|
||||
}
|
||||
|
||||
T value;
|
||||
RicfFieldReader<T>::readFieldData( value, inputStream, errorMessageContainer, true );
|
||||
RicfFieldIOHandler<T>::writeToField( value, inputStream, errorMessageContainer, true );
|
||||
fieldValue.push_back( value );
|
||||
}
|
||||
}
|
||||
@@ -208,20 +185,16 @@ struct RicfFieldReader<std::vector<T>>
|
||||
errorMessageContainer->currentCommand + "\"" );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct RicfFieldWriter<std::vector<T>>
|
||||
{
|
||||
static void writeFieldData( const std::vector<T>& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings = true,
|
||||
bool quoteNonBuiltins = false )
|
||||
static void readFromField( const std::vector<T>& fieldValue,
|
||||
QTextStream& outputStream,
|
||||
bool quoteStrings = true,
|
||||
bool quoteNonBuiltins = false )
|
||||
{
|
||||
outputStream << "[";
|
||||
for ( size_t i = 0; i < fieldValue.size(); ++i )
|
||||
{
|
||||
RicfFieldWriter<T>::writeFieldData( fieldValue[i], outputStream, quoteNonBuiltins );
|
||||
RicfFieldIOHandler<T>::readFromField( fieldValue[i], outputStream, quoteNonBuiltins );
|
||||
if ( i < fieldValue.size() - 1 )
|
||||
{
|
||||
outputStream << ", ";
|
||||
@@ -250,14 +223,14 @@ public:
|
||||
public:
|
||||
void readFieldData( QTextStream& inputStream,
|
||||
caf::PdmObjectFactory* objectFactory,
|
||||
RicfMessages* errorMessageContainer,
|
||||
caf::PdmScriptIOMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted = true ) override
|
||||
{
|
||||
typename FieldType::FieldDataType value;
|
||||
RicfFieldReader<typename FieldType::FieldDataType>::readFieldData( value,
|
||||
inputStream,
|
||||
errorMessageContainer,
|
||||
stringsAreQuoted );
|
||||
RicfFieldIOHandler<typename FieldType::FieldDataType>::writeToField( value,
|
||||
inputStream,
|
||||
errorMessageContainer,
|
||||
stringsAreQuoted );
|
||||
|
||||
if ( this->isIOWriteable() )
|
||||
{
|
||||
@@ -267,10 +240,10 @@ public:
|
||||
|
||||
void writeFieldData( QTextStream& outputStream, bool quoteStrings = true, bool quoteNonBuiltins = false ) const override
|
||||
{
|
||||
RicfFieldWriter<typename FieldType::FieldDataType>::writeFieldData( m_field->value(),
|
||||
outputStream,
|
||||
quoteStrings,
|
||||
quoteNonBuiltins );
|
||||
RicfFieldIOHandler<typename FieldType::FieldDataType>::readFromField( m_field->value(),
|
||||
outputStream,
|
||||
quoteStrings,
|
||||
quoteNonBuiltins );
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -25,10 +25,9 @@ namespace caf
|
||||
{
|
||||
class PdmObjectFactory;
|
||||
class PdmFieldHandle;
|
||||
class PdmScriptIOMessages;
|
||||
} // namespace caf
|
||||
|
||||
class RicfMessages;
|
||||
|
||||
class QTextStream;
|
||||
|
||||
//==================================================================================================
|
||||
@@ -42,10 +41,10 @@ public:
|
||||
RicfFieldHandle( caf::PdmFieldHandle* owner, const QString& scriptFieldName, bool giveOwnership );
|
||||
~RicfFieldHandle() override;
|
||||
|
||||
virtual void readFieldData( QTextStream& inputStream,
|
||||
caf::PdmObjectFactory* objectFactory,
|
||||
RicfMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted = true ) = 0;
|
||||
virtual void readFieldData( QTextStream& inputStream,
|
||||
caf::PdmObjectFactory* objectFactory,
|
||||
caf::PdmScriptIOMessages* errorMessageContainer,
|
||||
bool stringsAreQuoted = true ) = 0;
|
||||
|
||||
private:
|
||||
caf::PdmFieldHandle* m_owner;
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#include "RicfMessages.h"
|
||||
#include <QTextStream>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicfMessages::addWarning( const QString& message )
|
||||
{
|
||||
m_messages.push_back(
|
||||
std::make_pair( MESSAGE_WARNING, "Line " + QString::number( m_currentLineNumber ) + ": " + message ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicfMessages::addError( const QString& message )
|
||||
{
|
||||
m_messages.push_back(
|
||||
std::make_pair( MESSAGE_ERROR, "Line " + QString::number( m_currentLineNumber ) + ": " + message ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicfMessages::skipWhiteSpaceWithLineNumberCount( QTextStream& inputStream )
|
||||
{
|
||||
while ( !inputStream.atEnd() )
|
||||
{
|
||||
QChar ch = readCharWithLineNumberCount( inputStream );
|
||||
if ( !ch.isSpace() )
|
||||
{
|
||||
inputStream.seek( inputStream.pos() - 1 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QChar RicfMessages::readCharWithLineNumberCount( QTextStream& inputStream )
|
||||
{
|
||||
QChar ch;
|
||||
inputStream >> ch;
|
||||
if ( ch == QChar( '\n' ) )
|
||||
{
|
||||
m_currentLineNumber++;
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QChar RicfMessages::peekNextChar( QTextStream& inputStream )
|
||||
{
|
||||
QChar ch;
|
||||
if ( !inputStream.atEnd() )
|
||||
{
|
||||
inputStream >> ch;
|
||||
inputStream.seek( inputStream.pos() - 1 );
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicfMessages::skipLineWithLineNumberCount( QTextStream& inputStream )
|
||||
{
|
||||
inputStream.readLine();
|
||||
m_currentLineNumber++;
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
|
||||
#include <QString>
|
||||
#include <vector>
|
||||
|
||||
class QTextStream;
|
||||
|
||||
class RicfMessages
|
||||
{
|
||||
public:
|
||||
RicfMessages()
|
||||
: m_currentLineNumber( 1 )
|
||||
{
|
||||
}
|
||||
|
||||
enum MessageType
|
||||
{
|
||||
MESSAGE_WARNING,
|
||||
MESSAGE_ERROR
|
||||
};
|
||||
|
||||
void addWarning( const QString& message );
|
||||
void addError( const QString& message );
|
||||
|
||||
void skipWhiteSpaceWithLineNumberCount( QTextStream& inputStream );
|
||||
void skipLineWithLineNumberCount( QTextStream& inputStream );
|
||||
|
||||
QChar readCharWithLineNumberCount( QTextStream& inputStream );
|
||||
QChar peekNextChar( QTextStream& inputStream );
|
||||
|
||||
QString currentCommand;
|
||||
QString currentArgument;
|
||||
std::vector<std::pair<MessageType, QString>> m_messages;
|
||||
|
||||
private:
|
||||
int m_currentLineNumber;
|
||||
};
|
||||
@@ -18,10 +18,10 @@
|
||||
|
||||
#include "RicfObjectCapability.h"
|
||||
#include "RicfFieldHandle.h"
|
||||
#include "RicfMessages.h"
|
||||
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmObjectHandle.h"
|
||||
#include "cafPdmScriptIOMessages.h"
|
||||
#include "cafPdmXmlFieldHandle.h"
|
||||
|
||||
#include <QTextStream>
|
||||
@@ -45,9 +45,9 @@ RicfObjectCapability::~RicfObjectCapability()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicfObjectCapability::readFields( QTextStream& inputStream,
|
||||
caf::PdmObjectFactory* objectFactory,
|
||||
RicfMessages* errorMessageContainer )
|
||||
void RicfObjectCapability::readFields( QTextStream& inputStream,
|
||||
caf::PdmObjectFactory* objectFactory,
|
||||
caf::PdmScriptIOMessages* errorMessageContainer )
|
||||
{
|
||||
std::set<QString> readFields;
|
||||
bool isLastArgumentRead = false;
|
||||
|
||||
@@ -28,10 +28,10 @@ namespace caf
|
||||
class PdmObject;
|
||||
class PdmObjectHandle;
|
||||
class PdmObjectFactory;
|
||||
class PdmScriptIOMessages;
|
||||
} // namespace caf
|
||||
|
||||
class QTextStream;
|
||||
class RicfMessages;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
@@ -45,7 +45,9 @@ public:
|
||||
|
||||
~RicfObjectCapability() override;
|
||||
|
||||
void readFields( QTextStream& inputStream, caf::PdmObjectFactory* objectFactory, RicfMessages* errorMessageContainer );
|
||||
void readFields( QTextStream& inputStream,
|
||||
caf::PdmObjectFactory* objectFactory,
|
||||
caf::PdmScriptIOMessages* errorMessageContainer );
|
||||
void writeFields( QTextStream& outputStream ) const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -19,19 +19,19 @@
|
||||
#include "RifcCommandFileReader.h"
|
||||
|
||||
#include "RicfCommandObject.h"
|
||||
#include "RicfMessages.h"
|
||||
#include "RicfObjectCapability.h"
|
||||
|
||||
#include "cafPdmObjectFactory.h"
|
||||
#include "cafPdmScriptIOMessages.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,
|
||||
caf::PdmScriptIOMessages* errorMessageContainer )
|
||||
{
|
||||
std::vector<RicfCommandObject*> readCommands;
|
||||
|
||||
|
||||
@@ -26,9 +26,8 @@ class QTextStream;
|
||||
namespace caf
|
||||
{
|
||||
class PdmObjectFactory;
|
||||
}
|
||||
|
||||
class RicfMessages;
|
||||
class PdmScriptIOMessages;
|
||||
} // namespace caf
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
@@ -38,9 +37,9 @@ class RicfMessages;
|
||||
class RicfCommandFileReader
|
||||
{
|
||||
public:
|
||||
static std::vector<RicfCommandObject*> readCommands( QTextStream& inputStream,
|
||||
caf::PdmObjectFactory* objectFactory,
|
||||
RicfMessages* errorMessageContainer );
|
||||
static std::vector<RicfCommandObject*> readCommands( QTextStream& inputStream,
|
||||
caf::PdmObjectFactory* objectFactory,
|
||||
caf::PdmScriptIOMessages* errorMessageContainer );
|
||||
|
||||
static void writeCommands( QTextStream& outputStream, const std::vector<RicfCommandObject*>& commandsToWrite );
|
||||
};
|
||||
|
||||
@@ -61,7 +61,7 @@ RicfCommandFileExecutor::~RicfCommandFileExecutor()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicfCommandFileExecutor::executeCommands( QTextStream& stream )
|
||||
{
|
||||
RicfMessages messages;
|
||||
caf::PdmScriptIOMessages messages;
|
||||
std::vector<RicfCommandObject*> executableCommands;
|
||||
{
|
||||
clearCachedData();
|
||||
@@ -70,7 +70,7 @@ void RicfCommandFileExecutor::executeCommands( QTextStream& stream )
|
||||
RicfCommandFileReader::readCommands( stream, caf::PdmDefaultObjectFactory::instance(), &messages );
|
||||
for ( auto message : messages.m_messages )
|
||||
{
|
||||
if ( message.first == RicfMessages::MESSAGE_WARNING )
|
||||
if ( message.first == caf::PdmScriptIOMessages::MESSAGE_WARNING )
|
||||
{
|
||||
RiaLogging::warning( QString( "Command file parsing warning: %1" ).arg( message.second ) );
|
||||
}
|
||||
|
||||
@@ -18,9 +18,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RicfMessages.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
#include "cafPdmScriptIOMessages.h"
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "RimProject.h"
|
||||
|
||||
#include "RicfFieldHandle.h"
|
||||
#include "RicfMessages.h"
|
||||
#include "RicfObjectCapability.h"
|
||||
|
||||
#include "cafPdmChildArrayField.h"
|
||||
@@ -31,6 +30,7 @@
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmObjectScriptabilityRegister.h"
|
||||
#include "cafPdmProxyValueField.h"
|
||||
#include "cafPdmScriptIOMessages.h"
|
||||
#include "cafPdmXmlFieldHandle.h"
|
||||
|
||||
#include <grpcpp/grpcpp.h>
|
||||
@@ -173,8 +173,8 @@ bool RiaGrpcServiceInterface::assignFieldValue( const QString& stringValue,
|
||||
auto ricfHandle = field->template capability<RicfFieldHandle>();
|
||||
if ( field && ricfHandle != nullptr )
|
||||
{
|
||||
QTextStream stream( stringValue.toLatin1() );
|
||||
RicfMessages messages;
|
||||
QTextStream stream( stringValue.toLatin1() );
|
||||
caf::PdmScriptIOMessages messages;
|
||||
*oldValue = field->toQVariant();
|
||||
ricfHandle->readFieldData( stream, nullptr, &messages, false );
|
||||
*newValue = field->toQVariant();
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
#include "RicfCommandFileExecutor.h"
|
||||
#include "RicfCommandObject.h"
|
||||
#include "RicfMessages.h"
|
||||
#include "RifcCommandFileReader.h"
|
||||
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmScriptIOMessages.h"
|
||||
|
||||
class TestCommand1 : public RicfCommandObject
|
||||
{
|
||||
@@ -80,8 +80,8 @@ TEST( RicfCommands, Test1 )
|
||||
|
||||
// std::cout << commandString.toStdString() << std::endl;
|
||||
|
||||
QTextStream inputStream( &commandString );
|
||||
RicfMessages errors;
|
||||
QTextStream inputStream( &commandString );
|
||||
caf::PdmScriptIOMessages errors;
|
||||
|
||||
auto objects = RicfCommandFileReader::readCommands( inputStream, caf::PdmDefaultObjectFactory::instance(), &errors );
|
||||
EXPECT_EQ( (size_t)5, objects.size() );
|
||||
@@ -138,8 +138,8 @@ TEST( RicfCommands, ErrorMessages )
|
||||
|
||||
std::cout << commandString.toStdString() << std::endl;
|
||||
|
||||
QTextStream inputStream( &commandString );
|
||||
RicfMessages errors;
|
||||
QTextStream inputStream( &commandString );
|
||||
caf::PdmScriptIOMessages errors;
|
||||
|
||||
auto objects = RicfCommandFileReader::readCommands( inputStream, caf::PdmDefaultObjectFactory::instance(), &errors );
|
||||
|
||||
@@ -155,7 +155,7 @@ TEST( RicfCommands, ErrorMessages )
|
||||
for ( const auto& msg : errors.m_messages )
|
||||
{
|
||||
QString label;
|
||||
if ( msg.first == RicfMessages::MESSAGE_ERROR )
|
||||
if ( msg.first == caf::PdmScriptIOMessages::MESSAGE_ERROR )
|
||||
{
|
||||
label = "Error : ";
|
||||
}
|
||||
@@ -180,8 +180,8 @@ TEST( RicfCommands, EmptyArgumentList )
|
||||
// Ensure no error messages when command with no arguments is read
|
||||
QString commandString( "TestCommand1()" );
|
||||
|
||||
QTextStream inputStream( &commandString );
|
||||
RicfMessages errors;
|
||||
QTextStream inputStream( &commandString );
|
||||
caf::PdmScriptIOMessages errors;
|
||||
|
||||
auto objects = RicfCommandFileReader::readCommands( inputStream, caf::PdmDefaultObjectFactory::instance(), &errors );
|
||||
|
||||
@@ -215,8 +215,8 @@ TEST( RicfCommands, TransformFileCommandObjectsToExecutableCommandObjects )
|
||||
|
||||
)";
|
||||
|
||||
QTextStream inputStream( &commandString );
|
||||
RicfMessages errors;
|
||||
QTextStream inputStream( &commandString );
|
||||
caf::PdmScriptIOMessages errors;
|
||||
|
||||
auto objects = RicfCommandFileReader::readCommands( inputStream, caf::PdmDefaultObjectFactory::instance(), &errors );
|
||||
EXPECT_TRUE( errors.m_messages.empty() );
|
||||
@@ -252,8 +252,8 @@ TEST( RicfCommands, IgnoreCommentLines )
|
||||
|
||||
)";
|
||||
|
||||
QTextStream inputStream( &commandString );
|
||||
RicfMessages errors;
|
||||
QTextStream inputStream( &commandString );
|
||||
caf::PdmScriptIOMessages errors;
|
||||
|
||||
auto objects = RicfCommandFileReader::readCommands( inputStream, caf::PdmDefaultObjectFactory::instance(), &errors );
|
||||
EXPECT_TRUE( errors.m_messages.empty() );
|
||||
@@ -283,8 +283,8 @@ TEST( RicfCommands, IgnoreCommentLinesShowErrorLine )
|
||||
|
||||
)";
|
||||
|
||||
QTextStream inputStream( &commandString );
|
||||
RicfMessages errors;
|
||||
QTextStream inputStream( &commandString );
|
||||
caf::PdmScriptIOMessages errors;
|
||||
|
||||
auto objects = RicfCommandFileReader::readCommands( inputStream, caf::PdmDefaultObjectFactory::instance(), &errors );
|
||||
EXPECT_EQ( (size_t)1, errors.m_messages.size() );
|
||||
@@ -315,8 +315,8 @@ TEST( RicfCommands, WriteCommand )
|
||||
}
|
||||
|
||||
{
|
||||
QTextStream inputStream( &commandString );
|
||||
RicfMessages errors;
|
||||
QTextStream inputStream( &commandString );
|
||||
caf::PdmScriptIOMessages errors;
|
||||
|
||||
auto objects =
|
||||
RicfCommandFileReader::readCommands( inputStream, caf::PdmDefaultObjectFactory::instance(), &errors );
|
||||
|
||||
@@ -10,6 +10,8 @@ set( PROJECT_FILES
|
||||
cafPdmObjectScriptabilityRegister.cpp
|
||||
cafPdmPythonGenerator.h
|
||||
cafPdmPythonGenerator.cpp
|
||||
cafPdmScriptIOMessages.h
|
||||
cafPdmScriptIOMessages.cpp
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user