ENH: adjust fileName methods for similarity to std::filesystem::path

- stem(), replace_name(), replace_ext(), remove_ext() etc

- string::contains() method - similar to C++23 method

  Eg,
      if (keyword.contains('/')) ...
  vs
      if (keyword.find('/') != std::string::npos) ...
This commit is contained in:
Mark Olesen
2022-10-06 11:33:07 +02:00
parent 98a510c317
commit 779a2ca084
89 changed files with 686 additions and 580 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,14 +43,16 @@ namespace functionObjects
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::functionObjects::zeroGradient::checkFormatName
(
const std::string& str
)
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace Foam
{
if (std::string::npos == str.find("@@"))
// Check that string contains the appropriate substitution token(s)
static bool checkFormatName(const word& str)
{
if (!str.contains("@@"))
{
WarningInFunction
<< "Bad result naming (no '@@' token found)."
@ -70,6 +72,10 @@ bool Foam::functionObjects::zeroGradient::checkFormatName
return true;
}
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
int Foam::functionObjects::zeroGradient::process(const word& fieldName)
{
@ -95,7 +101,7 @@ Foam::functionObjects::zeroGradient::zeroGradient
:
fvMeshFunctionObject(name, runTime, dict),
selectFields_(),
resultName_(string::null),
resultName_(),
results_()
{
read(dict);

View File

@ -137,10 +137,6 @@ class zeroGradient
// Private Member Functions
//- Check that string contains the appropriate substitution token(s)
static bool checkFormatName(const std::string& str);
//- Accept unless field only has constraint patches
// (ie, empty/zero-gradient/processor)
// This should also avoid fields that were already processed by