From 4030ed4543b23630256fea590eb0900f27dc5f31 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 3 Dec 2019 08:39:41 +0100 Subject: [PATCH] ENH: strip C/C++ comments from expressions by default --- .../expressions/exprEntry/expressionEntry.C | 4 +-- .../expressions/exprEntry/expressionEntry.H | 6 ++-- .../expressions/exprString/exprString.C | 4 +-- .../expressions/exprString/exprString.H | 30 +++++++++---------- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/OpenFOAM/expressions/exprEntry/expressionEntry.C b/src/OpenFOAM/expressions/exprEntry/expressionEntry.C index 09cbf9477f..8d7090242f 100644 --- a/src/OpenFOAM/expressions/exprEntry/expressionEntry.C +++ b/src/OpenFOAM/expressions/exprEntry/expressionEntry.C @@ -361,12 +361,12 @@ Foam::exprTools::expressionEntry::getExpression ( const word& name, const dictionary& dict, - const bool removeComments + const bool stripComments ) { string str(dict.get(name)); - if (removeComments) + if (stripComments) { stringOps::inplaceRemoveComments(str); } diff --git a/src/OpenFOAM/expressions/exprEntry/expressionEntry.H b/src/OpenFOAM/expressions/exprEntry/expressionEntry.H index 48003ca086..65a83ca237 100644 --- a/src/OpenFOAM/expressions/exprEntry/expressionEntry.H +++ b/src/OpenFOAM/expressions/exprEntry/expressionEntry.H @@ -141,13 +141,13 @@ public: const dictionary& dict ); - //- Get and expand expression with dictionary entries - // Optionally strip C/C++ comments from the input + //- Get and expand expression with dictionary entries, + //- and strip C/C++ comments from the input static expressions::exprString getExpression ( const word& name, const dictionary& dict, - const bool removeComments = false + const bool stripComments = false ); diff --git a/src/OpenFOAM/expressions/exprString/exprString.C b/src/OpenFOAM/expressions/exprString/exprString.C index 9fd594f180..32d0cf6506 100644 --- a/src/OpenFOAM/expressions/exprString/exprString.C +++ b/src/OpenFOAM/expressions/exprString/exprString.C @@ -35,10 +35,10 @@ Foam::expressions::exprString& Foam::expressions::exprString::expand ( const dictionary& dict, - const bool removeComments + const bool stripComments ) { - if (removeComments) + if (stripComments) { stringOps::inplaceRemoveComments(*this); } diff --git a/src/OpenFOAM/expressions/exprString/exprString.H b/src/OpenFOAM/expressions/exprString/exprString.H index cd7d09f87c..8d8faf857e 100644 --- a/src/OpenFOAM/expressions/exprString/exprString.H +++ b/src/OpenFOAM/expressions/exprString/exprString.H @@ -83,31 +83,31 @@ public: //- Construct as copy of character array inline explicit exprString(const char* s, bool doValidate=true); - //- Copy construct and expand with dictionary variables - // Optionally strip C/C++ comments from the input + //- Copy construct and expand with dictionary variables, + //- and strip C/C++ comments from the input inline exprString ( const std::string& str, const dictionary& dict, - const bool removeComments = false + const bool stripComments = true ); - //- Move construct and expand with dictionary variables - // Optionally strip C/C++ comments from the input + //- Move construct and expand with dictionary variables, + //- and strip C/C++ comments from the input inline exprString ( std::string&& str, const dictionary& dict, - const bool removeComments = false + const bool stripComments = true ); - //- Construct from Istream and expand with dictionary variables - // Optionally strip C/C++ comments from the input + //- Construct from Istream and expand with dictionary variables, + //- and strip C/C++ comments from the input inline exprString ( Istream& is, const dictionary& dict, - const bool removeComments = false + const bool stripComments = true ); @@ -125,12 +125,12 @@ public: // No expansions, know what you are doing. inline static exprString toExpr(std::string&& str); - //- Inplace expansion with dictionary variables - // Optionally strip C/C++ comments from the input + //- Inplace expansion with dictionary variables, + //- and strip C/C++ comments from the input exprString& expand ( const dictionary& dict, - const bool removeComments = false + const bool stripComments = true ); //- Check for unexpanded '$' entries. Fatal if any exist. @@ -145,13 +145,13 @@ public: //- Move assign exprString& operator=(exprString&& str) = default; - //- Copy assign from c-string (no expansions) + //- Copy assign from c-string. No expansions, no comment stripping inline exprString& operator=(const char* str); - //- Copy assign from string (no expansions) + //- Copy assign from string. No expansions, no comment stripping inline exprString& operator=(const std::string& str); - //- Move assign from string (no expansions) + //- Move assign from string. No expansions, no comment stripping inline exprString& operator=(std::string&& str); };