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

View File

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

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2012-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
Copyright (C) 2012-2018 Bernhard Gschaider
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 * * * * * * * * * * * * * * * //
Foam::expressions::exprResult::~exprResult()

View File

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

View File

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

View File

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