STYLE: avoid some implicit dictionary construct from Istream

This commit is contained in:
Mark Olesen
2021-03-22 10:24:40 +01:00
parent 9cc497373b
commit f5a931d4b5
6 changed files with 30 additions and 12 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -406,6 +406,7 @@ public:
//- Construct top-level dictionary from Istream, //- Construct top-level dictionary from Istream,
//- reading entries until EOF. Discards the header. //- reading entries until EOF. Discards the header.
// \note this constructor should be explicit
dictionary(Istream& is); dictionary(Istream& is);
//- Construct top-level dictionary from Istream, //- Construct top-level dictionary from Istream,
@ -420,7 +421,7 @@ public:
//- Construct top-level dictionary as copy from pointer to dictionary. //- Construct top-level dictionary as copy from pointer to dictionary.
// A null pointer is treated like an empty dictionary. // A null pointer is treated like an empty dictionary.
dictionary(const dictionary* dict); explicit dictionary(const dictionary* dict);
//- Move construct for given parent dictionary //- Move construct for given parent dictionary
dictionary(const dictionary& parentDict, dictionary&& dict); dictionary(const dictionary& parentDict, dictionary&& dict);
@ -928,7 +929,7 @@ public:
// Emits FatalIOError // Emits FatalIOError
void checkITstream(const ITstream& is, const word& keyword) const; void checkITstream(const ITstream& is, const word& keyword) const;
//- Read dictionary from Istream //- Read dictionary from Istream. Discards the header.
bool read(Istream& is); bool read(Istream& is);
//- Read dictionary from Istream, optionally keeping the header //- Read dictionary from Istream, optionally keeping the header
@ -944,7 +945,7 @@ public:
void writeEntry(const keyType& keyword, Ostream& os) const; void writeEntry(const keyType& keyword, Ostream& os) const;
//- Write dictionary entries. //- Write dictionary entries.
// \param extraNewLine adds additional newline\n between entries // \param extraNewLine adds additional newline between entries
// for "top-level" dictionaries // for "top-level" dictionaries
void writeEntries(Ostream& os, const bool extraNewLine=false) const; void writeEntries(Ostream& os, const bool extraNewLine=false) const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -38,7 +38,7 @@ Foam::dictionaryEntry::dictionaryEntry
) )
: :
entry(keyType(is)), entry(keyType(is)),
dictionary(parentDict, is) dictionary(parentDict, dictionary(is))
{ {
is.fatalCheck(FUNCTION_NAME); is.fatalCheck(FUNCTION_NAME);
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2018 Bernhard Gschaider <bgschaid@hfd-research.com> Copyright (C) 2012-2018 Bernhard Gschaider
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -354,6 +354,17 @@ Foam::expressions::exprResult::New
} }
Foam::autoPtr<Foam::expressions::exprResult>
Foam::expressions::exprResult::New
(
Istream& is
)
{
dictionary dict(is);
return New(dict);
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::expressions::exprResult::~exprResult() Foam::expressions::exprResult::~exprResult()

View File

@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2018 Bernhard Gschaider <bgschaid@hfd-research.com> Copyright (C) 2012-2018 Bernhard Gschaider
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -323,6 +323,9 @@ public:
const bool needsValue = false const bool needsValue = false
); );
//- Construct from Istream as dictionary content
explicit exprResult(Istream& is);
//- Construct by copying a field //- Construct by copying a field
template<class Type> template<class Type>
explicit exprResult(const Field<Type>& fld); explicit exprResult(const Field<Type>& fld);
@ -362,6 +365,9 @@ public:
//- Return a reference to the selected value driver //- Return a reference to the selected value driver
static autoPtr<exprResult> New(const dictionary& dict); static autoPtr<exprResult> New(const dictionary& dict);
//- Construct from Istream as dictionary content
static autoPtr<exprResult> New(Istream& is);
//- Clone //- Clone
virtual autoPtr<exprResult> clone() const virtual autoPtr<exprResult> clone() const
{ {

View File

@ -234,7 +234,7 @@ directionalPressureGradientExplicitSource
if (propsFile.good()) if (propsFile.good())
{ {
Info<< " Reading pressure gradient from file" << endl; Info<< " Reading pressure gradient from file" << endl;
dictionary propsDict(dictionary::null, propsFile); dictionary propsDict(propsFile);
propsDict.readEntry("gradient", gradP0_); propsDict.readEntry("gradient", gradP0_);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -109,7 +109,7 @@ Foam::fv::meanVelocityForce::meanVelocityForce
if (propsFile.good()) if (propsFile.good())
{ {
Info<< " Reading pressure gradient from file" << endl; Info<< " Reading pressure gradient from file" << endl;
dictionary propsDict(dictionary::null, propsFile); dictionary propsDict(propsFile);
propsDict.readEntry("gradient", gradP0_); propsDict.readEntry("gradient", gradP0_);
} }