ENH: strip C/C++ comments from expressions by default

This commit is contained in:
Mark Olesen
2019-12-03 08:39:41 +01:00
parent ec2c014980
commit 4030ed4543
4 changed files with 22 additions and 22 deletions

View File

@ -361,12 +361,12 @@ Foam::exprTools::expressionEntry::getExpression
( (
const word& name, const word& name,
const dictionary& dict, const dictionary& dict,
const bool removeComments const bool stripComments
) )
{ {
string str(dict.get<string>(name)); string str(dict.get<string>(name));
if (removeComments) if (stripComments)
{ {
stringOps::inplaceRemoveComments(str); stringOps::inplaceRemoveComments(str);
} }

View File

@ -141,13 +141,13 @@ public:
const dictionary& dict const dictionary& dict
); );
//- Get and expand expression with dictionary entries //- Get and expand expression with dictionary entries,
// Optionally strip C/C++ comments from the input //- and strip C/C++ comments from the input
static expressions::exprString getExpression static expressions::exprString getExpression
( (
const word& name, const word& name,
const dictionary& dict, const dictionary& dict,
const bool removeComments = false const bool stripComments = false
); );

View File

@ -35,10 +35,10 @@ Foam::expressions::exprString&
Foam::expressions::exprString::expand Foam::expressions::exprString::expand
( (
const dictionary& dict, const dictionary& dict,
const bool removeComments const bool stripComments
) )
{ {
if (removeComments) if (stripComments)
{ {
stringOps::inplaceRemoveComments(*this); stringOps::inplaceRemoveComments(*this);
} }

View File

@ -83,31 +83,31 @@ public:
//- Construct as copy of character array //- Construct as copy of character array
inline explicit exprString(const char* s, bool doValidate=true); inline explicit exprString(const char* s, bool doValidate=true);
//- Copy construct and expand with dictionary variables //- Copy construct and expand with dictionary variables,
// Optionally strip C/C++ comments from the input //- and strip C/C++ comments from the input
inline exprString inline exprString
( (
const std::string& str, const std::string& str,
const dictionary& dict, const dictionary& dict,
const bool removeComments = false const bool stripComments = true
); );
//- Move construct and expand with dictionary variables //- Move construct and expand with dictionary variables,
// Optionally strip C/C++ comments from the input //- and strip C/C++ comments from the input
inline exprString inline exprString
( (
std::string&& str, std::string&& str,
const dictionary& dict, const dictionary& dict,
const bool removeComments = false const bool stripComments = true
); );
//- Construct from Istream and expand with dictionary variables //- Construct from Istream and expand with dictionary variables,
// Optionally strip C/C++ comments from the input //- and strip C/C++ comments from the input
inline exprString inline exprString
( (
Istream& is, Istream& is,
const dictionary& dict, const dictionary& dict,
const bool removeComments = false const bool stripComments = true
); );
@ -125,12 +125,12 @@ public:
// No expansions, know what you are doing. // No expansions, know what you are doing.
inline static exprString toExpr(std::string&& str); inline static exprString toExpr(std::string&& str);
//- Inplace expansion with dictionary variables //- Inplace expansion with dictionary variables,
// Optionally strip C/C++ comments from the input //- and strip C/C++ comments from the input
exprString& expand exprString& expand
( (
const dictionary& dict, const dictionary& dict,
const bool removeComments = false const bool stripComments = true
); );
//- Check for unexpanded '$' entries. Fatal if any exist. //- Check for unexpanded '$' entries. Fatal if any exist.
@ -145,13 +145,13 @@ public:
//- Move assign //- Move assign
exprString& operator=(exprString&& str) = default; 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); 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); 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); inline exprString& operator=(std::string&& str);
}; };