ENH: more consistent order of ITstream constructor parameters

This commit is contained in:
Mark Olesen 2022-09-06 09:30:27 +02:00
parent 097008544c
commit 500ec9dd12
5 changed files with 46 additions and 21 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -104,7 +104,7 @@ void readList
{
OTstream os;
os << input;
ITstream is("input", os.tokens());
ITstream is(os.tokens());
is >> output;
}
@ -118,7 +118,7 @@ void readList
{
OTstream os;
os << input;
ITstream is("input", os.tokens());
ITstream is(os.tokens());
is >> output;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
Copyright (C) 2020-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -132,7 +132,7 @@ int main(int argc, char *argv[])
OTstream os;
os << poly;
ITstream is("input", std::move(os.tokens()));
ITstream is(std::move(os.tokens()));
is >> polyfunc;
}

View File

@ -210,9 +210,9 @@ Foam::ITstream::ITstream
Foam::ITstream::ITstream
(
const string& name,
const UList<token>& tokens,
IOstreamOption streamOpt
IOstreamOption streamOpt,
const string& name
)
:
Istream(streamOpt.format(), streamOpt.version()),
@ -227,9 +227,9 @@ Foam::ITstream::ITstream
Foam::ITstream::ITstream
(
const string& name,
List<token>&& tokens,
IOstreamOption streamOpt
IOstreamOption streamOpt,
const string& name
)
:
Istream(streamOpt.format(), streamOpt.version()),

View File

@ -101,20 +101,20 @@ public:
IOstreamOption streamOpt = IOstreamOption()
);
//- Copy construct from tokens, with given name
ITstream
//- Copy construct from tokens, optionally with given name
explicit ITstream
(
const string& name,
const UList<token>& tokens,
IOstreamOption streamOpt = IOstreamOption()
IOstreamOption streamOpt = IOstreamOption(),
const string& name = "input"
);
//- Move construct from tokens, with given name
ITstream
//- Move construct from tokens, optionally with given name
explicit ITstream
(
const string& name,
List<token>&& tokens,
IOstreamOption streamOpt = IOstreamOption()
IOstreamOption streamOpt = IOstreamOption(),
const string& name = "input"
);
//- Construct token list by parsing the input character sequence
@ -145,6 +145,31 @@ public:
);
// Additional constructors
//- Copy construct from tokens, with given name
ITstream
(
const string& name,
const UList<token>& tokens,
IOstreamOption streamOpt = IOstreamOption()
)
:
ITstream(tokens, streamOpt, name)
{}
//- Move construct from tokens, with given name
ITstream
(
const string& name,
List<token>&& tokens,
IOstreamOption streamOpt = IOstreamOption()
)
:
ITstream(std::move(tokens), streamOpt, name)
{}
//- Destructor
virtual ~ITstream() = default;

View File

@ -64,7 +64,7 @@ void Foam::simpleObjectRegistry::setValues
IStringStream is(os.str());
// Or alternatively?
// ITstream is(name, dEntry.dict().tokens());
// ITstream is(dEntry.dict().tokens());
for (simpleRegIOobject* obj : objects)
{
@ -129,11 +129,11 @@ void Foam::simpleObjectRegistry::setNamedValue
if (objPtr)
{
// The generic interface requires an Istream.
ITstream is("", tokenList(Foam::one{}, tok));
Log << name.c_str() << '=' << tok << nl;
// The generic interface requires an Istream.
ITstream is(tokenList(Foam::one{}, std::move(tok)));
const List<simpleRegIOobject*>& objects = *objPtr;
for (simpleRegIOobject* obj : objects)