From 7a79930ea6a38199ffa8358d350f2c6377686f34 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Tue, 10 Jan 2023 21:17:39 +0100 Subject: [PATCH] Roff: add roff namespace. --- .../FileInterface/RifRoffFileTools.cpp | 32 +++++++++++-------- .../FileInterface/RifRoffFileTools.h | 10 ++++-- ThirdParty/roffcpp | 2 +- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/ApplicationLibCode/FileInterface/RifRoffFileTools.cpp b/ApplicationLibCode/FileInterface/RifRoffFileTools.cpp index 3e2ae76ecb..cfcaa7d542 100644 --- a/ApplicationLibCode/FileInterface/RifRoffFileTools.cpp +++ b/ApplicationLibCode/FileInterface/RifRoffFileTools.cpp @@ -91,13 +91,13 @@ bool RifRoffFileTools::openGridFile( const QString& fileName, RigEclipseCaseData { const auto totalStart = high_resolution_clock::now(); - Reader reader( stream ); + roff::Reader reader( stream ); reader.parse(); const auto tokenizeDone = high_resolution_clock::now(); - std::vector> values = reader.scalarNamedValues(); - std::vector> arrayTypes = reader.getNamedArrayTypes(); + std::vector> values = reader.scalarNamedValues(); + std::vector> arrayTypes = reader.getNamedArrayTypes(); int nx = getInt( values, "dimensions.nX" ); int ny = getInt( values, "dimensions.nY" ); @@ -611,17 +611,17 @@ std::pair> try { - Reader reader( stream ); + roff::Reader reader( stream ); reader.parse(); - std::vector> arrayTypes = reader.getNamedArrayTypes(); + std::vector> arrayTypes = reader.getNamedArrayTypes(); for ( auto [keyword, kind] : arrayTypes ) { size_t keywordLength = reader.getArrayLength( keyword ); RiaLogging::info( QString( "Array found: %1 . Type: %2 Size: %3" ) .arg( QString::fromStdString( keyword ) ) - .arg( QString::fromStdString( Token::kindToString( kind ) ) ) + .arg( QString::fromStdString( roff::Token::kindToString( kind ) ) ) .arg( keywordLength ) ); if ( eclipseCaseData->mainGrid()->cellCount() == keywordLength ) { @@ -657,22 +657,26 @@ std::pair> //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector - RifRoffFileTools::readAndConvertToDouble( int nx, int ny, int nz, const std::string& keyword, Token::Kind kind, Reader& reader ) +std::vector RifRoffFileTools::readAndConvertToDouble( int nx, + int ny, + int nz, + const std::string& keyword, + roff::Token::Kind kind, + roff::Reader& reader ) { std::vector doubleVals; - if ( kind == Token::Kind::FLOAT ) + if ( kind == roff::Token::Kind::FLOAT ) { std::vector values = reader.getFloatArray( keyword ); convertToReservoirIndexOrder( nx, ny, nz, values, doubleVals ); } - else if ( kind == Token::Kind::BOOL ) + else if ( kind == roff::Token::Kind::BOOL ) { std::vector values = reader.getByteArray( keyword ); convertToReservoirIndexOrder( nx, ny, nz, values, doubleVals ); } - else if ( kind == Token::Kind::INT ) + else if ( kind == roff::Token::Kind::INT ) { std::vector values = reader.getIntArray( keyword ); convertToReservoirIndexOrder( nx, ny, nz, values, doubleVals ); @@ -680,7 +684,7 @@ std::vector else { RiaLogging::error( QString( "Unsupported property type '%1' for keyword '%2'." ) - .arg( QString::fromStdString( Token::kindToString( kind ) ) ) + .arg( QString::fromStdString( roff::Token::kindToString( kind ) ) ) .arg( QString::fromStdString( keyword ) ) ); } @@ -693,8 +697,8 @@ std::vector bool RifRoffFileTools::appendNewInputPropertyResult( RigEclipseCaseData* caseData, const QString& resultName, const std::string& keyword, - Token::Kind kind, - Reader& reader ) + roff::Token::Kind kind, + roff::Reader& reader ) { CVF_ASSERT( caseData ); diff --git a/ApplicationLibCode/FileInterface/RifRoffFileTools.h b/ApplicationLibCode/FileInterface/RifRoffFileTools.h index f1a85c7817..ac69f142b2 100644 --- a/ApplicationLibCode/FileInterface/RifRoffFileTools.h +++ b/ApplicationLibCode/FileInterface/RifRoffFileTools.h @@ -30,7 +30,11 @@ class RigEclipseCaseData; class RigMainGrid; + +namespace roff +{ class Reader; +} //================================================================================================== // @@ -80,11 +84,11 @@ private: static double interpolate( const cvf::Vec3d& top, const cvf::Vec3d& bottom, double z, int idx ); static std::vector - readAndConvertToDouble( int nx, int ny, int nz, const std::string& keyword, Token::Kind kind, Reader& reader ); + readAndConvertToDouble( int nx, int ny, int nz, const std::string& keyword, roff::Token::Kind kind, roff::Reader& reader ); static bool appendNewInputPropertyResult( RigEclipseCaseData* caseData, const QString& resultName, const std::string& keyword, - Token::Kind token, - Reader& reader ); + roff::Token::Kind token, + roff::Reader& reader ); }; diff --git a/ThirdParty/roffcpp b/ThirdParty/roffcpp index fffa414c1b..17613c7b57 160000 --- a/ThirdParty/roffcpp +++ b/ThirdParty/roffcpp @@ -1 +1 @@ -Subproject commit fffa414c1bfcf21cc234ce07c9b194b80c051b5e +Subproject commit 17613c7b57788d8708af8fe585194654531be3a3