Skip to content

Commit

Permalink
#10649 ApplicationLibCode: Use collection.empty() instead of comparin…
Browse files Browse the repository at this point in the history
…g with size
  • Loading branch information
kriben committed Sep 27, 2023
1 parent 1412ef5 commit ea72a55
Show file tree
Hide file tree
Showing 220 changed files with 432 additions and 431 deletions.
6 changes: 3 additions & 3 deletions ApplicationLibCode/Application/RiaApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ bool RiaApplication::openOdbCaseFromFile( const QString& fileName, bool applyTim
//--------------------------------------------------------------------------------------------------
std::vector<RimWellPath*> RiaApplication::addWellPathsToModel( QList<QString> wellPathFilePaths, gsl::not_null<QStringList*> errorMessages )
{
if ( m_project == nullptr || m_project->oilFields.size() < 1 ) return {};
if ( m_project == nullptr || m_project->oilFields.empty() ) return {};

RimOilField* oilField = m_project->activeOilField();
if ( oilField == nullptr ) return {};
Expand Down Expand Up @@ -963,7 +963,7 @@ std::vector<RimWellPath*> RiaApplication::addWellPathsToModel( QList<QString> we
//--------------------------------------------------------------------------------------------------
void RiaApplication::addWellPathFormationsToModel( QList<QString> wellPathFormationsFilePaths )
{
if ( m_project == nullptr || m_project->oilFields.size() < 1 ) return;
if ( m_project == nullptr || m_project->oilFields.empty() ) return;

RimOilField* oilField = m_project->activeOilField();
if ( oilField == nullptr ) return;
Expand All @@ -989,7 +989,7 @@ void RiaApplication::addWellPathFormationsToModel( QList<QString> wellPathFormat
std::vector<RimWellLogFile*> RiaApplication::addWellLogsToModel( const QList<QString>& wellLogFilePaths,
gsl::not_null<QStringList*> errorMessages )
{
if ( m_project == nullptr || m_project->oilFields.size() < 1 ) return {};
if ( m_project == nullptr || m_project->oilFields.empty() ) return {};

RimOilField* oilField = m_project->activeOilField();
if ( oilField == nullptr ) return {};
Expand Down
4 changes: 2 additions & 2 deletions ApplicationLibCode/Application/RiaGuiApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ RimViewWindow* RiaGuiApplication::activePlotWindow() const
if ( m_mainPlotWindow )
{
QList<QMdiSubWindow*> subwindows = m_mainPlotWindow->subWindowList( QMdiArea::StackingOrder );
if ( subwindows.size() > 0 )
if ( !subwindows.empty() )
{
viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget( subwindows.back()->widget() );
}
Expand Down Expand Up @@ -1059,7 +1059,7 @@ RimViewWindow* RiaGuiApplication::activeViewWindow()
RiuPlotMainWindow* mainPlotWindow = dynamic_cast<RiuPlotMainWindow*>( mainWindowWidget );

QList<QMdiSubWindow*> subwindows = mainPlotWindow->subWindowList( QMdiArea::StackingOrder );
if ( subwindows.size() > 0 )
if ( !subwindows.empty() )
{
viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget( subwindows.back()->widget() );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ std::string removeCommonStart( const std::string& mask, const std::string& filen
//--------------------------------------------------------------------------------------------------
void RiaImageCompareReporter::generateHTMLReport( const std::string& fileName, const std::string& diff2htmlHeaderText )
{
if ( m_directorySets.size() == 0 ) return;
if ( m_directorySets.empty() ) return;

std::ofstream output( fileName.c_str() );
if ( !output )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void RiaProjectFileVersionTools::decodeVersionString( const QString& projectFile

QStringList subStrings = projectFileVersion.split( "." );

if ( subStrings.size() > 0 )
if ( !subStrings.empty() )
{
*majorVersion = subStrings[0].toInt();
}
Expand Down
8 changes: 4 additions & 4 deletions ApplicationLibCode/Application/Tools/RiaProjectModifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,17 +123,17 @@ void RiaProjectModifier::invalidateExternalFilePaths( RimProject* project )
//--------------------------------------------------------------------------------------------------
bool RiaProjectModifier::applyModificationsToProject( RimProject* project )
{
if ( m_caseIdToGridFileNameMap.size() > 0 )
if ( !m_caseIdToGridFileNameMap.empty() )
{
replaceCase( project );
}

if ( m_groupIdToGridFileNamesMap.size() > 0 )
if ( !m_groupIdToGridFileNamesMap.empty() )
{
replaceSourceCases( project );
}

if ( m_caseIdToPropertiesFolderMap.size() > 0 )
if ( !m_caseIdToPropertiesFolderMap.empty() )
{
replacePropertiesFolder( project );
}
Expand Down Expand Up @@ -309,7 +309,7 @@ int RiaProjectModifier::firstGroupId( RimProject* project )
RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : nullptr;
if ( analysisModels )
{
if ( analysisModels->caseGroups.size() > 0 )
if ( !analysisModels->caseGroups.empty() )
{
return analysisModels->caseGroups[0]->groupId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ QList<caf::PdmOptionItemInfo> RiaSimWellBranchTools::valueOptionsForBranchIndexF
QList<caf::PdmOptionItemInfo> options;

size_t branchCount = simulationWellPaths.size();
if ( simulationWellPaths.size() == 0 )
if ( simulationWellPaths.empty() )
{
options.push_front( caf::PdmOptionItemInfo( "None", -1 ) );
}
Expand Down Expand Up @@ -111,7 +111,7 @@ int RiaSimWellBranchTools::clampBranchIndex( const QString& simWellName, int bra
{
auto branches = RiaSimWellBranchTools::simulationWellBranches( simWellName, branchDetection );

if ( branches.size() == 0 )
if ( branches.empty() )
{
return -1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void RicWellPathImportPerforationIntervalsFeature::onActionTriggered( bool isChe
defaultDir,
"Well Path Perforation Intervals (*.ev);;All Files (*.*)" );

if ( wellPathFilePaths.size() < 1 ) return;
if ( wellPathFilePaths.empty() ) return;

// Remember the path to next time
app->setLastUsedDialogDirectory( "WELLPATH_DIR", QFileInfo( wellPathFilePaths.last() ).absolutePath() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
bool RicEclipseWellFeatureImpl::isAnyWellSelected()
{
std::vector<RimSimWellInView*> selection = selectedWells();
return selection.size() > 0;
return !selection.empty();
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ bool RicEclipseWellShowLabelFeature::isCommandEnabled() const
bool RicEclipseWellShowLabelFeature::isCommandChecked() const
{
std::vector<RimSimWellInView*> selection = RicEclipseWellFeatureImpl::selectedWells();
if ( selection.size() > 0 )
if ( !selection.empty() )
{
RimSimWellInView* well = selection[0];

Expand Down Expand Up @@ -111,7 +111,7 @@ bool RicEclipseWellShowHeadFeature::isCommandEnabled() const
bool RicEclipseWellShowHeadFeature::isCommandChecked() const
{
std::vector<RimSimWellInView*> selection = RicEclipseWellFeatureImpl::selectedWells();
if ( selection.size() > 0 )
if ( !selection.empty() )
{
RimSimWellInView* well = selection[0];

Expand Down Expand Up @@ -159,7 +159,7 @@ bool RicEclipseWellShowPipeFeature::isCommandEnabled() const
bool RicEclipseWellShowPipeFeature::isCommandChecked() const
{
std::vector<RimSimWellInView*> selection = RicEclipseWellFeatureImpl::selectedWells();
if ( selection.size() > 0 )
if ( !selection.empty() )
{
RimSimWellInView* well = selection[0];

Expand Down Expand Up @@ -207,7 +207,7 @@ bool RicEclipseWellShowSpheresFeature::isCommandEnabled() const
bool RicEclipseWellShowSpheresFeature::isCommandChecked() const
{
std::vector<RimSimWellInView*> selection = RicEclipseWellFeatureImpl::selectedWells();
if ( selection.size() > 0 )
if ( !selection.empty() )
{
RimSimWellInView* well = selection[0];

Expand Down Expand Up @@ -255,7 +255,7 @@ bool RicEclipseWellShowWellCellsFeature::isCommandEnabled() const
bool RicEclipseWellShowWellCellsFeature::isCommandChecked() const
{
std::vector<RimSimWellInView*> selection = RicEclipseWellFeatureImpl::selectedWells();
if ( selection.size() > 0 )
if ( !selection.empty() )
{
RimSimWellInView* well = selection[0];

Expand Down Expand Up @@ -303,7 +303,7 @@ bool RicEclipseWellShowWellCellFenceFeature::isCommandEnabled() const
bool RicEclipseWellShowWellCellFenceFeature::isCommandChecked() const
{
std::vector<RimSimWellInView*> selection = RicEclipseWellFeatureImpl::selectedWells();
if ( selection.size() > 0 )
if ( !selection.empty() )
{
RimSimWellInView* well = selection[0];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ CAF_CMD_SOURCE_INIT( RicComputeStatisticsFeature, "RicComputeStatisticsFeature"
bool RicComputeStatisticsFeature::isCommandEnabled() const
{
std::vector<RimEclipseStatisticsCase*> selection = selectedCases();
if ( selection.size() > 0 )
if ( !selection.empty() )
{
RimEclipseStatisticsCase* statisticsCase = selection[0];
if ( statisticsCase )
{
RimIdenticalGridCaseGroup* gridCaseGroup = statisticsCase->firstAncestorOrThisOfType<RimIdenticalGridCaseGroup>();

RimCaseCollection* caseCollection = gridCaseGroup ? gridCaseGroup->caseCollection() : nullptr;
return caseCollection ? caseCollection->reservoirs.size() > 0 : false;
return caseCollection ? !caseCollection->reservoirs.empty() : false;
}
}

Expand All @@ -59,7 +59,7 @@ bool RicComputeStatisticsFeature::isCommandEnabled() const
void RicComputeStatisticsFeature::onActionTriggered( bool isChecked )
{
std::vector<RimEclipseStatisticsCase*> selection = selectedCases();
if ( selection.size() > 0 )
if ( !selection.empty() )
{
RimEclipseStatisticsCase* statisticsCase = selection[0];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ bool RicEclipseCaseNewGroupFeature::isCommandEnabled() const
std::vector<RimEclipseCaseCollection*> caseCollSelection;
caf::SelectionManager::instance()->objectsByType( &caseCollSelection );

return caseSelection.size() > 0 || caseCollSelection.size() > 0;
return !caseSelection.empty() || !caseCollSelection.empty();
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ caf::PdmUiItem* RicNewStatisticsCaseFeature::selectedValidUIItem()
std::vector<RimEclipseStatisticsCaseCollection*> statisticsCaseCollections;
caf::SelectionManager::instance()->objectsByType( &statisticsCaseCollections );

if ( statisticsCaseCollections.size() > 0 )
if ( !statisticsCaseCollections.empty() )
{
return statisticsCaseCollections[0];
}

std::vector<RimCaseCollection*> caseCollections;
caf::SelectionManager::instance()->objectsByType( &caseCollections );

if ( caseCollections.size() > 0 )
if ( !caseCollections.empty() )
{
if ( RimIdenticalGridCaseGroup::isStatisticsCaseCollection( caseCollections[0] ) )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ bool RicExportFaultsFeature::isCommandEnabled() const

caf::SelectionManager::instance()->objectsByType( &selectedFaults );

return ( selectedFaults.size() > 0 );
return ( !selectedFaults.empty() );
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -64,7 +64,7 @@ void RicExportFaultsFeature::onActionTriggered( bool isChecked )

caf::SelectionManager::instance()->objectsByType( &selectedFaults );

if ( selectedFaults.size() == 0 ) return;
if ( selectedFaults.empty() ) return;

QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallbackToProjectFolder( "FAULTS" );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ bool RicExportToLasFileFeature::isCommandEnabled() const
if ( RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot() ) return false;
if ( RicWellLogPlotCurveFeatureImpl::parentWellRftPlot() ) return false;

return RicWellLogPlotCurveFeatureImpl::selectedWellLogCurves().size() > 0;
return !RicWellLogPlotCurveFeatureImpl::selectedWellLogCurves().empty();
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -136,7 +136,7 @@ void RicExportToLasFileFeature::onActionTriggered( bool isChecked )
if ( RicWellLogPlotCurveFeatureImpl::parentWellAllocationPlot() ) return;

std::vector<RimWellLogCurve*> curves = RicWellLogPlotCurveFeatureImpl::selectedWellLogCurves();
if ( curves.size() == 0 ) return;
if ( curves.empty() ) return;

QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallbackToProjectFolder( "WELL_LOGS_DIR" );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,5 @@ RimEclipseInputProperty* RicSaveEclipseInputPropertyFeature::selectedInputProper
std::vector<RimEclipseInputProperty*> selection;
caf::SelectionManager::instance()->objectsByType( &selection );

return selection.size() > 0 ? selection[0] : nullptr;
return !selection.empty() ? selection[0] : nullptr;
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ RimEclipseView* RicSaveEclipseResultAsInputPropertyFeature::selectedEclipseView(
std::vector<RimEclipseView*> selection;
caf::SelectionManager::instance()->objectsByType( &selection );

if ( selection.size() > 0 )
if ( !selection.empty() )
{
return selection[0];
}
Expand All @@ -63,7 +63,7 @@ RimEclipseCellColors* RicSaveEclipseResultAsInputPropertyFeature::selectedEclips
std::vector<RimEclipseCellColors*> selection;
caf::SelectionManager::instance()->objectsByType( &selection );

if ( selection.size() > 0 )
if ( !selection.empty() )
{
return selection[0];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ QList<caf::PdmOptionItemInfo> RicSelectViewUI::calculateValueOptions( const caf:
//--------------------------------------------------------------------------------------------------
void RicSelectViewUI::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
if ( m_currentCase && m_currentCase->views().size() == 0 )
if ( m_currentCase && m_currentCase->views().empty() )
{
m_createNewView = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bool RicShowTotalAllocationDataFeature::isCommandEnabled() const
{
std::set<RimWellAllocationPlot*> wellAllocPlots = RicShowTotalAllocationDataFeature::selectedWellAllocationPlots();

return wellAllocPlots.size() > 0;
return !wellAllocPlots.empty();
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ bool RicShowWellAllocationPlotFeature::isCommandEnabled() const
std::vector<RimSimWellInView*> simWellCollection;
caf::SelectionManager::instance()->objectsByType( &simWellCollection );

if ( simWellCollection.size() > 0 )
if ( !simWellCollection.empty() )
{
return true;
}
Expand Down Expand Up @@ -81,11 +81,11 @@ void RicShowWellAllocationPlotFeature::onActionTriggered( bool isChecked )

RimSimWellInView* simWell = nullptr;

if ( collection.size() > 0 )
if ( !collection.empty() )
{
simWell = collection[0];
}
else if ( wellPathCollection.size() > 0 )
else if ( !wellPathCollection.empty() )
{
Rim3dView* view = RiaApplication::instance()->activeMainOrComparisonGridView();
if ( !view ) return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool RicPasteEllipseFractureFeature::isCommandEnabled() const
std::vector<caf::PdmPointer<RimEllipseFractureTemplate>> typedObjects;
objectGroup.objectsByType( &typedObjects );

if ( typedObjects.size() == 0 )
if ( typedObjects.empty() )
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool RicPasteStimPlanFractureFeature::isCommandEnabled() const
std::vector<caf::PdmPointer<RimStimPlanFractureTemplate>> typedObjects;
objectGroup.objectsByType( &typedObjects );

if ( typedObjects.size() == 0 )
if ( typedObjects.empty() )
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void RicImportGeoMechCaseFeature::onActionTriggered( bool isChecked )
"Import Geo-Mechanical Model",
defaultDir,
"Abaqus results (*.odb);;Abaqus input file (*.inp)" );
if ( fileNames.size() ) defaultDir = QFileInfo( fileNames.last() ).absolutePath();
if ( !fileNames.empty() ) defaultDir = QFileInfo( fileNames.last() ).absolutePath();
app->setLastUsedDialogDirectory( "GEOMECH_MODEL", defaultDir );

for ( const auto& fileName : fileNames )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void RicImportGeoMechCaseTimeStepFilterFeature::onActionTriggered( bool isChecke
QString defaultDir = app->lastUsedDialogDirectory( "GEOMECH_MODEL" );
QStringList fileNames =
RiuFileDialogTools::getOpenFileNames( nullptr, "Import Geo-Mechanical Model", defaultDir, "Abaqus results (*.odb)" );
if ( fileNames.size() ) defaultDir = QFileInfo( fileNames.last() ).absolutePath();
if ( !fileNames.empty() ) defaultDir = QFileInfo( fileNames.last() ).absolutePath();
for ( QString fileName : fileNames )
{
if ( !fileName.isEmpty() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void RicRunFaultReactModelingFeature::onActionTriggered( bool isChecked )
{
gCase->reloadDataAndUpdate();
auto& views = gCase->geoMechViews();
if ( views.size() > 0 )
if ( !views.empty() )
{
Riu3DMainWindowTools::selectAsCurrentItem( views[0] );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void RicShowFaultReactModelFeature::onActionTriggered( bool isChecked )
{
gCase->reloadDataAndUpdate();
auto& views = gCase->geoMechViews();
if ( views.size() > 0 )
if ( !views.empty() )
{
Riu3DMainWindowTools::selectAsCurrentItem( views[0] );
}
Expand Down
Loading

0 comments on commit ea72a55

Please sign in to comment.