diff --git a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C index ba9d957fcd2993bcd1fda31c59ee22d1781524c8..8fca84428d867fb736aa2add85ea851dc66c7bb9 100644 --- a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C +++ b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C @@ -425,7 +425,7 @@ void Foam::ITstream::append(token&& t, const bool lazy) } -void Foam::ITstream::append(const tokenList& newTokens, const bool lazy) +void Foam::ITstream::append(const UList<token>& newTokens, const bool lazy) { reserveCapacity(tokenIndex_ + newTokens.size(), lazy); tokenList& toks = *this; @@ -438,7 +438,7 @@ void Foam::ITstream::append(const tokenList& newTokens, const bool lazy) } -void Foam::ITstream::append(tokenList&& newTokens, const bool lazy) +void Foam::ITstream::append(List<token>&& newTokens, const bool lazy) { reserveCapacity(tokenIndex_ + newTokens.size(), lazy); tokenList& toks = *this; @@ -465,7 +465,7 @@ void Foam::ITstream::operator=(const ITstream& is) } -void Foam::ITstream::operator=(const tokenList& toks) +void Foam::ITstream::operator=(const UList<token>& toks) { tokenList::operator=(toks); @@ -473,7 +473,7 @@ void Foam::ITstream::operator=(const tokenList& toks) } -void Foam::ITstream::operator=(tokenList&& toks) +void Foam::ITstream::operator=(List<token>&& toks) { tokenList::operator=(std::move(toks)); diff --git a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H index 546f354b2448def4cf5dae31e8712fcc07bc6c0f..923d7512f3798e35c762d838eadf3451df5bcd8a 100644 --- a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H +++ b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H @@ -99,6 +99,22 @@ public: setGood(); } + //- Construct empty stream with given name + explicit ITstream + ( + const string& name, + IOstreamOption streamOpt = IOstreamOption() + ) + : + Istream(streamOpt), + tokenList(), + name_(name), + tokenIndex_(0) + { + setOpened(); + setGood(); + } + //- Construct from components ITstream ( @@ -300,21 +316,21 @@ public: //- incrementing the index. void append(token&& t, const bool lazy); - //- Copy append a tokenList at the current tokenIndex, + //- 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 tokenList& newTokens, const bool lazy); + void append(const UList<token>& newTokens, const bool lazy); - //- Move append a tokenList at the current tokenIndex, + //- 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(tokenList&& newTokens, const bool lazy); + void append(List<token>&& newTokens, const bool lazy); //- Set flags of stream ios_base::fmtflags flags(const ios_base::fmtflags) @@ -339,10 +355,10 @@ public: void operator=(const ITstream& is); //- Copy assignment of tokens, with rewind() - void operator=(const tokenList& toks); + void operator=(const UList<token>& toks); //- Move assignment of tokens, with rewind() - void operator=(tokenList&& toks); + void operator=(List<token>&& toks); }; diff --git a/src/OpenFOAM/db/IOstreams/Tstreams/OTstream.H b/src/OpenFOAM/db/IOstreams/Tstreams/OTstream.H index b476ec020d73d9d1fff3766ea6fe3f32111b452e..b7b56ecaf311307dc968bf4f7283e44d4297ee48 100644 --- a/src/OpenFOAM/db/IOstreams/Tstreams/OTstream.H +++ b/src/OpenFOAM/db/IOstreams/Tstreams/OTstream.H @@ -80,12 +80,8 @@ public: versionNumber ver = currentVersion ) : - Ostream(fmt, ver), - DynamicList<token>() - { - setOpened(); - setGood(); - } + OTstream(IOstreamOption(fmt, ver)) + {} //- Copy construct OTstream(const OTstream& os) diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H index 82c6749de25441d28005ee9651964485216a12d6..8c79e5a699d532d4403606e178537bee1714644d 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.H +++ b/src/OpenFOAM/db/dictionary/dictionary.H @@ -187,7 +187,7 @@ public: public: - //- Construct null + //- Default construct Searcher() : dict_(nullptr), @@ -388,7 +388,7 @@ public: // Constructors - //- Construct top-level dictionary null + //- Default construct, a top-level empty dictionary dictionary(); //- Construct top-level empty dictionary with given name diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C index 4149df3e7005e0a3cc20ea6530e5a57c899843b7..c665f89cbc8bf222470f1acc053b32cd7717dfcc 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.C @@ -213,13 +213,11 @@ bool Foam::primitiveEntry::expandVariable // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::primitiveEntry::primitiveEntry(const keyType& key, const ITstream& is) +Foam::primitiveEntry::primitiveEntry(const keyType& key) : entry(key), - ITstream(is) -{ - name() += '.' + keyword(); -} + ITstream(key, tokenList()) +{} Foam::primitiveEntry::primitiveEntry(const keyType& key, const token& tok) @@ -251,6 +249,15 @@ Foam::primitiveEntry::primitiveEntry {} +Foam::primitiveEntry::primitiveEntry(const keyType& key, const ITstream& is) +: + entry(key), + ITstream(is) +{ + name() += '.' + key; +} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::label Foam::primitiveEntry::startLineNumber() const diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H index 605c196a8d5805f67bbdd823aebb4e2e20a427ae..86060abe73fe6073109c69642f3cdfa0ef7a9a86 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -54,6 +54,7 @@ SourceFiles namespace Foam { +// Forward Declarations class dictionary; /*---------------------------------------------------------------------------*\ @@ -104,14 +105,9 @@ public: // Constructors - //- Construct from keyword and a Istream - primitiveEntry(const keyType& key, Istream& is); - - //- Construct from keyword, parent dictionary and Istream - primitiveEntry(const keyType& key, const dictionary& dict, Istream& is); - - //- Construct from keyword and a ITstream - primitiveEntry(const keyType& key, const ITstream& is); + //- Construct from keyword and no tokens. + // Contents to be filled with a later assignment + explicit primitiveEntry(const keyType& key); //- Construct from keyword and a single token primitiveEntry(const keyType& key, const token& tok); @@ -122,10 +118,20 @@ public: //- Construct from keyword and by transferring a list of tokens primitiveEntry(const keyType& key, List<token>&& tokens); - //- Construct from keyword and a T + //- Construct from keyword and ITstream tokens + primitiveEntry(const keyType& key, const ITstream& is); + + //- Construct from keyword and Istream + primitiveEntry(const keyType& key, Istream& is); + + //- Construct from keyword, parent dictionary and Istream + primitiveEntry(const keyType& key, const dictionary& dict, Istream& is); + + //- Construct from keyword and a value. Uses string stream serialization template<class T> primitiveEntry(const keyType& key, const T& val); + //- Clone the entry autoPtr<entry> clone(const dictionary&) const { return autoPtr<entry>(new primitiveEntry(*this));