From 9dc3d2bf4097894a7e1dd7f4fb9867af4af4b3c4 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@esi-group.com>
Date: Mon, 19 Apr 2021 11:06:19 +0200
Subject: [PATCH] ENH: additional ITstream constructors

- additional default construct

- add explicit zero-size constructor for ITstream.
  For tagged dispatching, without ambiguity

- elminate mandatory name for parsing versions.
  This makes it easier to use ITstream, IStringStream, UListStream
  interchangeable.
---
 applications/test/bitSet2/Test-bitSet2.C      |   3 +-
 src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C | 123 +++++--
 src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H | 316 +++++++-----------
 src/OpenFOAM/db/IOstreams/Tstreams/OTstream.H |  34 +-
 .../db/IOstreams/memory/UIListStream.H        |  24 --
 src/OpenFOAM/db/dictionary/dictionary.H       |   2 +-
 .../dictionaryEntry/dictionaryEntry.H         |   2 +-
 src/OpenFOAM/db/dictionary/entry/entry.H      |  12 +-
 .../primitiveEntry/primitiveEntry.C           |  14 +-
 .../primitiveEntry/primitiveEntry.H           |   4 +-
 src/OpenFOAM/global/argList/argListI.H        |  12 +-
 .../fileOperation/fileOperation.C             |   2 +-
 .../PDRblockMesh/PDRblockBlockMesh.C          |   4 +-
 13 files changed, 254 insertions(+), 298 deletions(-)

diff --git a/applications/test/bitSet2/Test-bitSet2.C b/applications/test/bitSet2/Test-bitSet2.C
index caa3800fb71..df3bd8f938e 100644
--- a/applications/test/bitSet2/Test-bitSet2.C
+++ b/applications/test/bitSet2/Test-bitSet2.C
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2018-2020 OpenCFD Ltd.
+    Copyright (C) 2018-2021 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -370,7 +370,6 @@ int main(int argc, char *argv[])
     (
         ITstream
         (
-            "input",
             "(1 n 1 n 1 n 1 1 off 0 0 f f 0 y yes y true y false on t)"
         )()
     );
diff --git a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C
index 41876f5e2ae..7803f3a2a38 100644
--- a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C
+++ b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C
@@ -72,7 +72,7 @@ Foam::tokenList Foam::ITstream::parse
     IOstreamOption streamOpt
 )
 {
-    UIListStream is(input.data(), input.size(), streamOpt);
+    UIListStream is(input.data(), input.length(), streamOpt);
 
     tokenList tokens;
     parseStream(is, tokens);
@@ -131,11 +131,34 @@ void Foam::ITstream::reserveCapacity
 
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
+Foam::ITstream::ITstream(const ITstream& is)
+:
+    Istream(static_cast<IOstreamOption>(is)),
+    tokenList(is),
+    name_(is.name_),
+    tokenIndex_(0)
+{
+    setOpened();
+    setGood();
+}
+
+
+Foam::ITstream::ITstream(ITstream&& is)
+:
+    Istream(static_cast<IOstreamOption>(is)),
+    tokenList(std::move(static_cast<tokenList&>(is))),
+    name_(std::move(is.name_)),
+    tokenIndex_(0)
+{
+    setOpened();
+    setGood();
+}
+
+
 Foam::ITstream::ITstream
 (
-    const string& name,
-    const UList<char>& input,
-    IOstreamOption streamOpt
+    IOstreamOption streamOpt,
+    const string& name
 )
 :
     Istream(streamOpt.format(), streamOpt.version()),
@@ -143,43 +166,96 @@ Foam::ITstream::ITstream
     name_(name),
     tokenIndex_(0)
 {
-    UIListStream is(input, streamOpt);
-
-    parseStream(is, static_cast<tokenList&>(*this));
-    ITstream::rewind();
+    setOpened();
+    setGood();
 }
 
 
 Foam::ITstream::ITstream
 (
+    const Foam::zero,
     const string& name,
-    const std::string& input,
+    IOstreamOption streamOpt
+)
+:
+    ITstream(streamOpt, name)
+{}
+
+
+Foam::ITstream::ITstream
+(
+    const string& name,
+    const UList<token>& tokens,
     IOstreamOption streamOpt
 )
 :
     Istream(streamOpt.format(), streamOpt.version()),
-    tokenList(),
+    tokenList(tokens),
     name_(name),
     tokenIndex_(0)
 {
-    UIListStream is(input.data(), input.size(), streamOpt);
-
-    parseStream(is, static_cast<tokenList&>(*this));
-    ITstream::rewind();
+    setOpened();
+    setGood();
 }
 
 
 Foam::ITstream::ITstream
 (
     const string& name,
-    const char* input,
+    List<token>&& tokens,
     IOstreamOption streamOpt
 )
 :
     Istream(streamOpt.format(), streamOpt.version()),
-    tokenList(),
+    tokenList(std::move(tokens)),
     name_(name),
     tokenIndex_(0)
+{
+    setOpened();
+    setGood();
+}
+
+
+Foam::ITstream::ITstream
+(
+    const UList<char>& input,
+    IOstreamOption streamOpt,
+    const string& name
+)
+:
+    ITstream(streamOpt, name)
+{
+    UIListStream is(input, streamOpt);
+
+    parseStream(is, static_cast<tokenList&>(*this));
+    ITstream::rewind();
+}
+
+
+Foam::ITstream::ITstream
+(
+    const std::string& input,
+    IOstreamOption streamOpt,
+    const string& name
+)
+:
+    ITstream(streamOpt, name)
+{
+    UIListStream is(input.data(), input.length(), streamOpt);
+
+    parseStream(is, static_cast<tokenList&>(*this));
+    ITstream::rewind();
+}
+
+
+Foam::ITstream::ITstream
+(
+    const char* input,
+    IOstreamOption streamOpt,
+    const string& name
+)
+:
+    ITstream(streamOpt, name)
 {
     UIListStream is(input, strlen(input), streamOpt);
 
@@ -448,18 +524,20 @@ void Foam::ITstream::append(List<token>&& newTokens, const bool lazy)
 
 void Foam::ITstream::operator=(const ITstream& is)
 {
-    Istream::operator=(is);
-    tokenList::operator=(is);
-    name_ = is.name_;
-
-    rewind();
+    // Self-assignment is a no-op
+    if (this != &is)
+    {
+        Istream::operator=(is);
+        tokenList::operator=(is);
+        name_ = is.name_;
+        rewind();
+    }
 }
 
 
 void Foam::ITstream::operator=(const UList<token>& toks)
 {
     tokenList::operator=(toks);
-
     rewind();
 }
 
@@ -467,7 +545,6 @@ void Foam::ITstream::operator=(const UList<token>& toks)
 void Foam::ITstream::operator=(List<token>&& toks)
 {
     tokenList::operator=(std::move(toks));
-
     rewind();
 }
 
diff --git a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H
index 394e1df4280..19c36c263b7 100644
--- a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H
+++ b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H
@@ -88,92 +88,67 @@ public:
     // Constructors
 
         //- Copy construct
-        ITstream(const ITstream& is)
-        :
-            Istream(ASCII, currentVersion),
-            tokenList(is),
-            name_(is.name_),
-            tokenIndex_(0)
-        {
-            setOpened();
-            setGood();
-        }
+        ITstream(const ITstream& is);
 
-        //- Construct empty stream with given name
+        //- Move construct
+        ITstream(ITstream&& is);
+
+        //- Default construct. Empty stream, optionally with given name
         explicit ITstream
         (
-            const string& name,
+            IOstreamOption streamOpt = IOstreamOption(),
+            const string& name = "input"
+        );
+
+        //- Construct empty, optionally with given name
+        explicit ITstream
+        (
+            const Foam::zero,
+            const string& name = "input",
             IOstreamOption streamOpt = IOstreamOption()
-        )
-        :
-            Istream(streamOpt),
-            tokenList(),
-            name_(name),
-            tokenIndex_(0)
-        {
-            setOpened();
-            setGood();
-        }
+        );
 
-        //- Construct from components, copying the tokens
+        //- Copy construct from tokens, with given name
         ITstream
         (
             const string& name,
             const UList<token>& tokens,
             IOstreamOption streamOpt = IOstreamOption()
-        )
-        :
-            Istream(streamOpt.format(), streamOpt.version()),
-            tokenList(tokens),
-            name_(name),
-            tokenIndex_(0)
-        {
-            setOpened();
-            setGood();
-        }
+        );
 
-        //- Construct from components, transferring the tokens
+        //- Move construct from tokens, with given name
         ITstream
         (
             const string& name,
             List<token>&& tokens,
             IOstreamOption streamOpt = IOstreamOption()
-        )
-        :
-            Istream(streamOpt.format(), streamOpt.version()),
-            tokenList(std::move(tokens)),
-            name_(name),
-            tokenIndex_(0)
-        {
-            setOpened();
-            setGood();
-        }
+        );
 
         //- Construct token list by parsing the input character sequence
-        //  Uses UIListStream internally.
-        ITstream
+        //  Uses static parse function internally.
+        explicit ITstream
         (
-            const string& name,
             const UList<char>& input,
-            IOstreamOption streamOpt = IOstreamOption()
+            IOstreamOption streamOpt = IOstreamOption(),
+            const string& name = "input"
         );
 
         //- Construct token list by parsing the input string
-        //  Uses UIListStream internally.
-        ITstream
+        //  Uses static parse function internally.
+        explicit ITstream
         (
-            const string& name,
             const std::string& input,
-            IOstreamOption streamOpt = IOstreamOption()
+            IOstreamOption streamOpt = IOstreamOption(),
+            const string& name = "input"
         );
 
         //- Construct token list by parsing the input character sequence
-        //  Uses UIListStream internally.
-        ITstream
+        //  Uses static parse function internally.
+        explicit ITstream
         (
-            const string& name,
             const char* input,
-            IOstreamOption streamOpt = IOstreamOption()
+            IOstreamOption streamOpt = IOstreamOption(),
+            const string& name = "input"
         );
 
 
@@ -183,24 +158,24 @@ public:
 
     // Static Functions
 
-        //- Create token list by parsing the input character sequence until
-        //- no good tokens remain.
+        //- Create token list by parsing the input character sequence
+        //- until no good tokens remain.
         static tokenList parse
         (
             const UList<char>& input,
             IOstreamOption streamOpt = IOstreamOption()
         );
 
-        //- Create token list by parsing the input string until
-        //- no good tokens remain.
+        //- Create token list by parsing the input string
+        //- until no good tokens remain.
         static tokenList parse
         (
             const std::string& input,
             IOstreamOption streamOpt = IOstreamOption()
         );
 
-        //- Create token list by parsing the input character sequence until
-        //- no good tokens remain.
+        //- Create token list by parsing the input character sequence
+        //- until no good tokens remain.
         static tokenList parse
         (
             const char* input,
@@ -210,43 +185,87 @@ public:
 
     // Member Functions
 
-        // Inquiry
+    // Token Access
 
-            //- Return the name of the stream
-            virtual const fileName& name() const
-            {
-                return name_;
-            }
+        //- The current token index when reading, or the insertion point.
+        label tokenIndex() const
+        {
+            return tokenIndex_;
+        }
 
-            //- Return non-const access to the name of the stream
-            virtual fileName& name()
-            {
-                return name_;
-            }
+        //- Non-const access to the current token index
+        label& tokenIndex()
+        {
+            return tokenIndex_;
+        }
 
-            //- The current token index when reading, or the insertion point.
-            label tokenIndex() const
-            {
-                return tokenIndex_;
-            }
+        //- The number of remaining tokens
+        label nRemainingTokens() const
+        {
+            return size() - tokenIndex_;
+        }
 
-            //- Non-const access to the current token index
-            label& tokenIndex()
-            {
-                return tokenIndex_;
-            }
+        //- Move the tokenIndex to the specified position.
+        //  Using seek(0) is identical to rewind.
+        //  Using seek(-1) moves to the end.
+        void seek(label pos);
 
-            //- The number of remaining tokens
-            label nRemainingTokens() const
-            {
-                return size() - tokenIndex_;
-            }
 
-            //- Return flags of output stream
-            ios_base::fmtflags flags() const
-            {
-                return ios_base::fmtflags(0);
-            }
+    // Inquiry
+
+        //- Get the name of the stream
+        virtual const fileName& name() const
+        {
+            return name_;
+        }
+
+        //- Return stream name for modification
+        virtual fileName& name()
+        {
+            return name_;
+        }
+
+
+    // Token list modification
+
+        //- Copy append a token at the current tokenIndex,
+        //- incrementing the index.
+        void append(const token& t, const bool lazy);
+
+        //- Move append a token at the current tokenIndex,
+        //- incrementing the index.
+        void append(token&& t, const bool lazy);
+
+        //- Copy append a list of tokens at the current tokenIndex,
+        //- incrementing the index.
+        //
+        //  \param newTokens the list of tokens to copy append
+        //  \param lazy leaves any excess capacity for further appends.
+        //      The caller will be responsible for resizing later.
+        void append(const UList<token>& newTokens, const bool lazy);
+
+        //- Move append a list of tokens at the current tokenIndex,
+        //- incrementing the index.
+        //
+        //  \param newTokens the list of tokens to move append
+        //  \param lazy leaves any excess capacity for further appends.
+        //      The caller will be responsible for resizing later.
+        void append(List<token>&& newTokens, const bool lazy);
+
+
+    // Stream State Functions
+
+        //- Get stream flags - always 0
+        virtual ios_base::fmtflags flags() const
+        {
+            return ios_base::fmtflags(0);
+        }
+
+        //- Set flags of stream - ignored
+        ios_base::fmtflags flags(const ios_base::fmtflags)
+        {
+            return ios_base::fmtflags(0);
+        }
 
 
         // Read Functions
@@ -295,44 +314,6 @@ public:
             //- Rewind the stream so that it may be read again
             virtual void rewind();
 
-            //- Move the tokenIndex to the specified position.
-            //  Using seek(0) is identical to rewind.
-            //  Using seek(-1) moves to the end.
-            void seek(label pos);
-
-
-        // Edit
-
-            //- Copy append a token at the current tokenIndex,
-            //- incrementing the index.
-            void append(const token& t, const bool lazy);
-
-            //- Move append a token at the current tokenIndex,
-            //- incrementing the index.
-            void append(token&& t, const bool lazy);
-
-            //- Copy append a list of tokens at the current tokenIndex,
-            //- incrementing the index.
-            //
-            //  \param newTokens the list of tokens to copy append
-            //  \param lazy leaves any excess capacity for further appends.
-            //      The caller will be responsible for resizing later.
-            void append(const UList<token>& newTokens, const bool lazy);
-
-            //- Move append a list of tokens at the current tokenIndex,
-            //- incrementing the index.
-            //
-            //  \param newTokens the list of tokens to move append
-            //  \param lazy leaves any excess capacity for further appends.
-            //      The caller will be responsible for resizing later.
-            void append(List<token>&& newTokens, const bool lazy);
-
-            //- Set flags of stream
-            ios_base::fmtflags flags(const ios_base::fmtflags)
-            {
-                return ios_base::fmtflags(0);
-            }
-
 
     // Output
 
@@ -383,79 +364,6 @@ public:
             ITstream(name, std::move(tokens), IOstreamOption(fmt, ver))
         {}
 
-        //- Construct token list by parsing the input character sequence
-        //  Uses UIListStream internally.
-        ITstream
-        (
-            const string& name,
-            const UList<char>& input,
-            IOstreamOption::streamFormat fmt,
-            IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
-        )
-        :
-            ITstream(name, input, IOstreamOption(fmt, ver))
-        {}
-
-        //- Construct token list by parsing the input string
-        //  Uses UIListStream internally.
-        ITstream
-        (
-            const string& name,
-            const std::string& input,
-            IOstreamOption::streamFormat fmt,
-            IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
-        )
-        :
-            ITstream(name, input, IOstreamOption(fmt, ver))
-        {}
-
-        //- Construct token list by parsing the input character sequence
-        //  Uses UIListStream internally.
-        ITstream
-        (
-            const string& name,
-            const char* input,
-            IOstreamOption::streamFormat fmt,
-            IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
-        )
-        :
-            ITstream(name, input, IOstreamOption(fmt, ver))
-        {}
-
-
-        //- Create token list by parsing the input character sequence until
-        //- no good tokens remain.
-        static tokenList parse
-        (
-            const UList<char>& input,
-            IOstreamOption::streamFormat fmt
-        )
-        {
-            return parse(input, IOstreamOption(fmt));
-        }
-
-        //- Create token list by parsing the input string until
-        //- no good tokens remain.
-        static tokenList parse
-        (
-            const std::string& input,
-            IOstreamOption::streamFormat fmt
-        )
-        {
-            return parse(input, IOstreamOption(fmt));
-        }
-
-        //- Create token list by parsing the input character sequence until
-        //- no good tokens remain.
-        static tokenList parse
-        (
-            const char* input,
-            IOstreamOption::streamFormat fmt
-        )
-        {
-            return parse(input, IOstreamOption(fmt));
-        }
-
     #endif /* Foam_IOstream_extras */
 };
 
diff --git a/src/OpenFOAM/db/IOstreams/Tstreams/OTstream.H b/src/OpenFOAM/db/IOstreams/Tstreams/OTstream.H
index de56b330ba1..2cdd55e2a4f 100644
--- a/src/OpenFOAM/db/IOstreams/Tstreams/OTstream.H
+++ b/src/OpenFOAM/db/IOstreams/Tstreams/OTstream.H
@@ -174,7 +174,19 @@ public:
         {}
 
 
-    // Stream state functions
+    // Stream State Functions
+
+        //- Get flags of output stream
+        virtual ios_base::fmtflags flags() const
+        {
+            return ios_base::fmtflags(0);
+        }
+
+        //- Set flags of stream - ignored
+        std::ios_base::fmtflags flags(const ios_base::fmtflags)
+        {
+            return ios_base::fmtflags(0);
+        }
 
         //- Flush stream
         virtual void flush()
@@ -224,24 +236,6 @@ public:
         }
 
 
-    // Inquiry
-
-        //- Return flags of output stream
-        virtual ios_base::fmtflags flags() const
-        {
-            return ios_base::fmtflags(0);
-        }
-
-
-    // Edit
-
-        //- Set flags of stream
-        ios_base::fmtflags flags(const ios_base::fmtflags)
-        {
-            return ios_base::fmtflags(0);
-        }
-
-
     // Other
 
         //- Reset the output buffer and rewind the stream
@@ -254,6 +248,8 @@ public:
         virtual void rewind()
         {
             DynamicList<token>::clear();
+            setOpened();
+            setGood();
         }
 
         //- Print stream description to Ostream
diff --git a/src/OpenFOAM/db/IOstreams/memory/UIListStream.H b/src/OpenFOAM/db/IOstreams/memory/UIListStream.H
index c0ec65781d8..d1da07127f1 100644
--- a/src/OpenFOAM/db/IOstreams/memory/UIListStream.H
+++ b/src/OpenFOAM/db/IOstreams/memory/UIListStream.H
@@ -64,7 +64,6 @@ See Also
 #ifndef UIListStream_H
 #define UIListStream_H
 
-#include "FixedList.H"
 #include "UList.H"
 #include "ISstream.H"
 #include "memoryStreamBuffer.H"
@@ -245,17 +244,6 @@ public:
             UIListStream(buffer.cdata(), buffer.size(), streamOpt)
         {}
 
-        //- Construct using data area from a FixedList
-        template<unsigned N>
-        explicit UIListStream
-        (
-            const FixedList<char, N>& buffer,
-            IOstreamOption streamOpt = IOstreamOption()
-        )
-        :
-            UIListStream(buffer.cdata(), N, streamOpt)
-        {}
-
 
     // Member Functions
 
@@ -326,18 +314,6 @@ public:
             UIListStream(buf.cdata(), buf.size(), IOstreamOption(fmt, ver))
         {}
 
-        //- Construct using data area from a FixedList
-        template<unsigned N>
-        UIListStream
-        (
-            const FixedList<char, N>& buffer,
-            IOstreamOption::streamFormat fmt,
-            IOstreamOption::versionNumber ver = IOstreamOption::currentVersion
-        )
-        :
-            UIListStream(buffer.cdata(), N, IOstreamOption(fmt, ver))
-        {}
-
     #endif /* Foam_IOstream_extras */
 };
 
diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H
index d60ada722bc..724a9b8efb6 100644
--- a/src/OpenFOAM/db/dictionary/dictionary.H
+++ b/src/OpenFOAM/db/dictionary/dictionary.H
@@ -573,7 +573,7 @@ public:
         ) const;
 
         //- Find and return an entry data stream.
-        //- FatalIOError if not found, or if the number of tokens is incorrect.
+        //- FatalIOError if not found, or not a stream
         //
         //  \param matchOpt the default search is non-recursive with patterns
         ITstream& lookup
diff --git a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H
index 1749f120f1c..080a45915c9 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H
+++ b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H
@@ -119,7 +119,7 @@ public:
             return dictionary::name();
         }
 
-        //- Return the scoped dictionary name (eg, dictA.dictB.dictC)
+        //- Return scoped dictionary name for modification
         virtual fileName& name()
         {
             return dictionary::name();
diff --git a/src/OpenFOAM/db/dictionary/entry/entry.H b/src/OpenFOAM/db/dictionary/entry/entry.H
index c258e5a141f..b9176518d56 100644
--- a/src/OpenFOAM/db/dictionary/entry/entry.H
+++ b/src/OpenFOAM/db/dictionary/entry/entry.H
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2017-2019 OpenCFD Ltd.
+    Copyright (C) 2017-2021 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -54,7 +54,7 @@ SourceFiles
 namespace Foam
 {
 
-// Forward declarations
+// Forward Declarations
 class ITstream;
 class dictionary;
 class entry;
@@ -185,21 +185,21 @@ public:
     // Member Functions
 
         //- Return keyword
-        const keyType& keyword() const
+        const keyType& keyword() const noexcept
         {
             return keyword_;
         }
 
         //- Return non-const access to keyword
-        keyType& keyword()
+        keyType& keyword() noexcept
         {
             return keyword_;
         }
 
-        //- Return the dictionary name
+        //- Return the entry name
         virtual const fileName& name() const = 0;
 
-        //- Return the dictionary name
+        //- Return the entry name for modification
         virtual fileName& name() = 0;
 
         //- Return line number of first token in dictionary
diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C
index c665f89cbc8..53c5b301efd 100644
--- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C
+++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C
@@ -6,7 +6,7 @@
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
     Copyright (C) 2011-2016 OpenFOAM Foundation
-    Copyright (C) 2017-2020 OpenCFD Ltd.
+    Copyright (C) 2017-2021 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -168,7 +168,7 @@ bool Foam::primitiveEntry::expandVariable
 
         // Parse string into a series of tokens
 
-        tokenList toks(ITstream::parse(str, IOstream::ASCII));
+        tokenList toks(ITstream::parse(str));  // ASCII
 
         ITstream::append(std::move(toks), true);  // Lazy resizing
     }
@@ -183,7 +183,7 @@ bool Foam::primitiveEntry::expandVariable
             // Not found or empty:  use ":-" alternative value
             // Found and not empty: use ":+" alternative value
 
-            toks = ITstream::parse(altValue, IOstream::ASCII);
+            toks = ITstream::parse(altValue);  // ASCII
         }
 
         ITstream::append(std::move(toks), true);  // Lazy resizing
@@ -197,7 +197,7 @@ bool Foam::primitiveEntry::expandVariable
             // Not found or empty:  use ":-" alternative value
             // Found and not empty: use ":+" alternative value
 
-            tokenList toks(ITstream::parse(altValue, IOstream::ASCII));
+            tokenList toks(ITstream::parse(altValue));  // ASCII
 
             ITstream::append(std::move(toks), true);  // Lazy resizing
         }
@@ -216,14 +216,14 @@ bool Foam::primitiveEntry::expandVariable
 Foam::primitiveEntry::primitiveEntry(const keyType& key)
 :
     entry(key),
-    ITstream(key, tokenList())
+    ITstream(zero{}, key)
 {}
 
 
 Foam::primitiveEntry::primitiveEntry(const keyType& key, const token& tok)
 :
     entry(key),
-    ITstream(key, tokenList(1, tok))
+    ITstream(key, tokenList(one{}, tok))
 {}
 
 
@@ -254,7 +254,7 @@ Foam::primitiveEntry::primitiveEntry(const keyType& key, const ITstream& is)
     entry(key),
     ITstream(is)
 {
-    name() += '.' + key;
+    ITstream::name() += '.' + key;
 }
 
 
diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H
index 86060abe73f..1cc1428578a 100644
--- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H
+++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H
@@ -143,13 +143,13 @@ public:
         //- Inherit read from ITstream
         using ITstream::read;
 
-        //- Return the dictionary name
+        //- Return the token stream name
         virtual const fileName& name() const
         {
             return ITstream::name();
         }
 
-        //- Return the dictionary name
+        //- Return token stream name for modification
         virtual fileName& name()
         {
             return ITstream::name();
diff --git a/src/OpenFOAM/global/argList/argListI.H b/src/OpenFOAM/global/argList/argListI.H
index 83344cdf2d9..a9e70bfb925 100644
--- a/src/OpenFOAM/global/argList/argListI.H
+++ b/src/OpenFOAM/global/argList/argListI.H
@@ -156,7 +156,7 @@ inline bool Foam::argList::found(const word& optName) const
 
 inline Foam::ITstream Foam::argList::lookup(const word& optName) const
 {
-    return ITstream(optName, options_[optName]);
+    return ITstream(options_[optName]);
 }
 
 
@@ -250,7 +250,7 @@ namespace Foam
 template<class T>
 inline T Foam::argList::get(const label index) const
 {
-    ITstream is(Foam::name(index), args_[index]);
+    ITstream is(args_[index]);
 
     T val;
     is >> val;
@@ -264,7 +264,7 @@ inline T Foam::argList::get(const label index) const
 template<class T>
 inline T Foam::argList::get(const word& optName) const
 {
-    ITstream is(optName, options_[optName]);
+    ITstream is(options_[optName]);
 
     T val;
     is >> val;
@@ -329,7 +329,7 @@ inline bool Foam::argList::readIfPresent
 template<class T>
 inline Foam::List<T> Foam::argList::getList(const label index) const
 {
-    ITstream is(Foam::name(index), args_[index]);
+    ITstream is(args_[index]);
 
     List<T> list;
     readList(is, list);
@@ -351,7 +351,7 @@ inline Foam::List<T> Foam::argList::getList
 
     if (mandatory || found(optName))
     {
-        ITstream is(optName, options_[optName]);
+        ITstream is(options_[optName]);
 
         readList(is, list);
 
@@ -371,7 +371,7 @@ inline bool Foam::argList::readListIfPresent
 {
     if (found(optName))
     {
-        ITstream is(optName, options_[optName]);
+        ITstream is(options_[optName]);
 
         readList(is, list);
 
diff --git a/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C b/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C
index 2d663b6f9a0..60c396b5596 100644
--- a/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C
+++ b/src/OpenFOAM/global/fileOperations/fileOperation/fileOperation.C
@@ -223,7 +223,7 @@ Foam::labelList Foam::fileOperation::ioRanks()
 {
     labelList ranks;
 
-    ITstream is("ioranks", Foam::getEnv("FOAM_IORANKS"));
+    ITstream is(Foam::getEnv("FOAM_IORANKS"));
     if (!is.empty())
     {
         is >> ranks;
diff --git a/src/mesh/blockMesh/PDRblockMesh/PDRblockBlockMesh.C b/src/mesh/blockMesh/PDRblockMesh/PDRblockBlockMesh.C
index 98058904d38..fc95266b0a1 100644
--- a/src/mesh/blockMesh/PDRblockMesh/PDRblockBlockMesh.C
+++ b/src/mesh/blockMesh/PDRblockMesh/PDRblockBlockMesh.C
@@ -5,7 +5,7 @@
     \\  /    A nd           | www.openfoam.com
      \\/     M anipulation  |
 -------------------------------------------------------------------------------
-    Copyright (C) 2020 OpenCFD Ltd.
+    Copyright (C) 2020-2021 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -778,7 +778,7 @@ Foam::dictionary Foam::PDRblock::blockMeshDict() const
     OTstream os;
     blockMeshDict(os);
 
-    ITstream is("blockMeshDict", tokenList());
+    ITstream is;
     is.transfer(os.tokens());
 
     return dictionary(is);
-- 
GitLab