diff --git a/src/OpenFOAM/db/IOobject/IOobject.H b/src/OpenFOAM/db/IOobject/IOobject.H index 2496c63b5c617afbe6c94f2aa03101dbd7e67b56..f164c1ee7f478de7193dcb8e0fb79871459190c5 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.H +++ b/src/OpenFOAM/db/IOobject/IOobject.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -94,7 +94,7 @@ SourceFiles namespace Foam { -// Forward declarations +// Forward Declarations class Time; class objectRegistry; @@ -106,7 +106,7 @@ class IOobject { public: - // Public data types + // Public Data Types //- Enumeration defining the valid states of an IOobject enum objectState : char @@ -198,7 +198,7 @@ protected: public: - //- Runtime type information + //- Declare type-name, virtual type (with debug switch) TypeName("IOobject"); @@ -208,7 +208,7 @@ public: static fileCheckTypes fileModificationChecking; - // Static Member Functions + // Static Functions //- Split path into instance, local, name components // @@ -267,6 +267,15 @@ public: ); + // Generated Methods + + //- Copy construct + IOobject(const IOobject&) = default; + + //- Destructor + virtual ~IOobject() = default; + + // Constructors //- Construct from name, instance, registry, io options @@ -309,14 +318,14 @@ public: bool globalObject = false ); - //- Construct as copy resetting registry + //- Copy construct, resetting registry IOobject ( const IOobject& io, const objectRegistry& registry ); - //- Construct as copy resetting name + //- Copy construct, resetting name IOobject ( const IOobject& io, @@ -336,10 +345,6 @@ public: } - //- Destructor - virtual ~IOobject() = default; - - // Member Functions // General access diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/baseIOdictionary.C b/src/OpenFOAM/db/IOobjects/IOdictionary/baseIOdictionary.C index f761b155bfaffc57485c25fdb045cf44f7306f35..9b2940e1482219f6b1129a4fc7f7b0855125c076 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/baseIOdictionary.C +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/baseIOdictionary.C @@ -34,12 +34,12 @@ License namespace Foam { -defineTypeNameAndDebug(baseIOdictionary, 0); + defineTypeNameAndDebug(baseIOdictionary, 0); -bool baseIOdictionary::writeDictionaries -( - debug::infoSwitch("writeDictionaries", 0) -); + bool baseIOdictionary::writeDictionaries + ( + debug::infoSwitch("writeDictionaries", 0) + ); } @@ -77,12 +77,6 @@ Foam::baseIOdictionary::baseIOdictionary } -// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // - -Foam::baseIOdictionary::~baseIOdictionary() -{} - - // * * * * * * * * * * * * * * * Members Functions * * * * * * * * * * * * * // const Foam::word& Foam::baseIOdictionary::name() const diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/baseIOdictionary.H b/src/OpenFOAM/db/IOobjects/IOdictionary/baseIOdictionary.H index 1cbe9a27bb8105c4e8072bec1f646789a4bd70c0..184f6ed19ee149f1ba9e0bedcf012670e1b32c4d 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/baseIOdictionary.H +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/baseIOdictionary.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,15 +60,28 @@ class baseIOdictionary public regIOobject, public dictionary { - // Private data + // Private Data static bool writeDictionaries; public: + //- Declare type-name, virtual type (with debug switch) TypeName("dictionary"); + // Generated Methods + + //- Copy construct + baseIOdictionary(const baseIOdictionary&) = default; + + //- Move construct + baseIOdictionary(baseIOdictionary&&) = default; + + //- Destructor + virtual ~baseIOdictionary() = default; + + // Constructors //- Construct given an IOobject @@ -80,35 +94,33 @@ public: baseIOdictionary(const IOobject&, Istream&); - //- Destructor - virtual ~baseIOdictionary(); - - - // Member functions + // Member Functions //- Return complete path + object name if the file exists - // either in the case/processor or case otherwise null + //- either in the case/processor or case otherwise null virtual fileName filePath() const = 0; //- Name function is needed to disambiguate those inherited - // from regIOobject and dictionary + //- from regIOobject and dictionary const word& name() const; - //- ReadData function required for regIOobject read operation + //- The readData function required by regIOobject read operation virtual bool readData(Istream&); - //- WriteData function required for regIOobject write operation + //- The writeData function required by regIOobject write operation virtual bool writeData(Ostream&) const; //- Is object global virtual bool global() const = 0; - // Member operators + // Member Operators - //- Assignment of other baseIOdictionary's entries to this - // baseIOdictionary + //- Copy assignment of dictionary entries (leave regIOobject untouched) void operator=(const baseIOdictionary&); + + //- Copy assignment of dictionary entries + using dictionary::operator=; }; diff --git a/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.H b/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.H index 0b7a9e84690d3c851d10afb176a929bb7db41557..91debf850645c579da151e1593936cd0a8e3fd68 100644 --- a/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.H +++ b/src/OpenFOAM/db/IOstreams/Fstreams/IFstream.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011 OpenFOAM Foundation - Copyright (C) 2017-2018 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,7 +43,6 @@ SourceFiles #include "className.H" #include <fstream> -using std::ifstream; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -85,7 +84,6 @@ protected: //- Delete the stream pointer void deallocate(); - }; } // End namespace Detail @@ -102,14 +100,14 @@ class IFstream { public: - // Declare name of the class and its debug switch + //- Declare type-name (with debug switch) ClassName("IFstream"); // Constructors //- Construct from pathname - IFstream + explicit IFstream ( const fileName& pathname, streamFormat format=ASCII, @@ -143,7 +141,7 @@ public: // Print - //- Print description of IOstream to Ostream + //- Print stream description to Ostream virtual void print(Ostream& os) const; diff --git a/src/OpenFOAM/db/IOstreams/Fstreams/OFstream.H b/src/OpenFOAM/db/IOstreams/Fstreams/OFstream.H index baa676902e7bcce5dc77b18854cc6e3849f94fd3..c88400a05d5d6276e99b13c1d2ab699987085246 100644 --- a/src/OpenFOAM/db/IOstreams/Fstreams/OFstream.H +++ b/src/OpenFOAM/db/IOstreams/Fstreams/OFstream.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2017-2018 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,7 +43,6 @@ SourceFiles #include "className.H" #include <fstream> -using std::ofstream; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -87,7 +86,6 @@ protected: //- Delete the stream pointer void deallocate(); - }; } // End namespace Detail @@ -104,14 +102,14 @@ class OFstream { public: - // Declare name of the class and its debug switch + //- Declare type-name (with debug switch) ClassName("OFstream"); // Constructors //- Construct from pathname - OFstream + explicit OFstream ( const fileName& pathname, streamFormat format=ASCII, @@ -125,7 +123,7 @@ public: ~OFstream() = default; - // Member functions + // Member Functions // Access @@ -144,7 +142,7 @@ public: // Print - //- Print description of IOstream to Ostream + //- Print stream description to Ostream void print(Ostream& os) const; }; diff --git a/src/OpenFOAM/db/IOstreams/Fstreams/masterOFstream.C b/src/OpenFOAM/db/IOstreams/Fstreams/masterOFstream.C index 41df9856a562e2ae536e803ee39d85c289226f8e..2aa4c10c604832aebd5050182e2f33cc308e78de 100644 --- a/src/OpenFOAM/db/IOstreams/Fstreams/masterOFstream.C +++ b/src/OpenFOAM/db/IOstreams/Fstreams/masterOFstream.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -31,15 +32,23 @@ License #include "PstreamBuffers.H" #include "masterUncollatedFileOperation.H" #include "boolList.H" +#include <algorithm> // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::masterOFstream::checkWrite ( const fileName& fName, - const string& str + const char* str, + std::streamsize len ) { + if (!len) + { + // Can probably skip all of this if there is nothing to write + return; + } + mkDir(fName.path()); OFstream os @@ -53,43 +62,35 @@ void Foam::masterOFstream::checkWrite if (!os.good()) { FatalIOErrorInFunction(os) - << "Could not open file " << fName + << "Could not open file " << fName << nl << exit(FatalIOError); } - os.writeQuoted(str, false); + // Use writeRaw() instead of writeQuoted(string,false) to output + // characters directly. + + os.writeRaw(str, len); + if (!os.good()) { FatalIOErrorInFunction(os) - << "Failed writing to " << fName + << "Failed writing to " << fName << nl << exit(FatalIOError); } } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::masterOFstream::masterOFstream +void Foam::masterOFstream::checkWrite ( - const fileName& pathName, - streamFormat format, - versionNumber version, - compressionType compression, - const bool append, - const bool valid + const fileName& fName, + const std::string& s ) -: - OStringStream(format, version), - pathName_(pathName), - compression_(compression), - append_(append), - valid_(valid) -{} - +{ + checkWrite(fName, &s[0], s.length()); +} -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -Foam::masterOFstream::~masterOFstream() +void Foam::masterOFstream::commit() { if (Pstream::parRun()) { @@ -109,10 +110,13 @@ Foam::masterOFstream::~masterOFstream() { if (Pstream::master() && valid_) { - checkWrite(pathName_, str()); + checkWrite(pathName_, this->str()); } + + this->reset(); return; } + boolList valid(Pstream::nProcs()); valid[Pstream::myProcNo()] = valid_; Pstream::gatherList(valid); @@ -126,7 +130,9 @@ Foam::masterOFstream::~masterOFstream() { UOPstream os(Pstream::masterNo(), pBufs); string s(this->str()); - os.write(&s[0], s.size()); + this->reset(); + + os.write(&s[0], s.length()); } labelList recvSizes; @@ -134,36 +140,70 @@ Foam::masterOFstream::~masterOFstream() if (Pstream::master()) { - // Write my own data + // Write master data + if (valid[Pstream::masterNo()]) { - if (valid[Pstream::myProcNo()]) - { - checkWrite(filePaths[Pstream::myProcNo()], str()); - } + checkWrite(filePaths[Pstream::masterNo()], this->str()); } + this->reset(); + + // Find the max slave size + recvSizes[Pstream::masterNo()] = 0; + List<char> buf + ( + *std::max_element(recvSizes.cbegin(), recvSizes.cend()) + ); - for (label proci = 1; proci < Pstream::nProcs(); proci++) + for (label proci = 1; proci < Pstream::nProcs(); ++proci) { UIPstream is(proci, pBufs); - List<char> buf(recvSizes[proci]); - is.read(buf.begin(), buf.size()); + const std::streamsize count(recvSizes[proci]); + is.read(buf.data(), count); if (valid[proci]) { - checkWrite - ( - filePaths[proci], - string(buf.begin(), buf.size()) - ); + checkWrite(filePaths[proci], buf.cdata(), count); } } } } else { - checkWrite(pathName_, str()); + checkWrite(pathName_, this->str()); + this->reset(); } + + // This method is only called once (internally) + // so no need to clear/flush old buffered data +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::masterOFstream::masterOFstream +( + const fileName& pathName, + streamFormat format, + versionNumber version, + compressionType compression, + const bool append, + const bool valid +) +: + OStringStream(format, version), + pathName_(pathName), + compression_(compression), + append_(append), + valid_(valid) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::masterOFstream::~masterOFstream() +{ + commit(); } diff --git a/src/OpenFOAM/db/IOstreams/Fstreams/masterOFstream.H b/src/OpenFOAM/db/IOstreams/Fstreams/masterOFstream.H index e9864699dc3270fe396ac4adf29b2f562feca88b..7115463330ca7d113350cc356b138d7ca854a7e7 100644 --- a/src/OpenFOAM/db/IOstreams/Fstreams/masterOFstream.H +++ b/src/OpenFOAM/db/IOstreams/Fstreams/masterOFstream.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -52,7 +53,7 @@ class masterOFstream : public OStringStream { - // Private data + // Private Data const fileName pathName_; @@ -66,8 +67,19 @@ class masterOFstream // Private Member Functions - //- Open file with checking - void checkWrite(const fileName& fName, const string& str); + //- Open file with checking and write append contents + void checkWrite + ( + const fileName& fName, + const char* str, + std::streamsize len + ); + + //- Open file with checking and write append contents + void checkWrite(const fileName& fName, const std::string& s); + + //- Commit buffered information, including parallel gather as required + void commit(); public: @@ -75,7 +87,7 @@ public: // Constructors //- Construct and set stream status - masterOFstream + explicit masterOFstream ( const fileName& pathname, streamFormat format=ASCII, @@ -86,7 +98,7 @@ public: ); - //- Destructor + //- Destructor - commits buffered information to file ~masterOFstream(); }; diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/IOstream.H b/src/OpenFOAM/db/IOstreams/IOstreams/IOstream.H index a2f5515fc207058c5ead595c36a93c4260cbe3d0..334faad57f04c64a1014879f5335ed76156e026a 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/IOstream.H +++ b/src/OpenFOAM/db/IOstreams/IOstreams/IOstream.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -147,6 +147,15 @@ protected: public: + // Generated Methods + + //- Copy construct + IOstream(const IOstream&) = default; + + //- Destructor + virtual ~IOstream() = default; + + // Constructors //- Construct with specified stream option @@ -174,10 +183,6 @@ public: {} - //- Destructor - virtual ~IOstream() = default; - - // Member Functions // Access @@ -383,7 +388,7 @@ public: // Print - //- Print description of IOstream to Ostream + //- Print stream description to Ostream virtual void print(Ostream& os) const; //- Print information about the stream state bits diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Istream.H b/src/OpenFOAM/db/IOstreams/IOstreams/Istream.H index c37f55950d66d2a7ecf801e4b53576a6ee6bb663..96fd50d98ee5b6a85e2265e64bf1dbbf6be17648 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/Istream.H +++ b/src/OpenFOAM/db/IOstreams/IOstreams/Istream.H @@ -74,9 +74,18 @@ class Istream public: + // Generated Methods + + //- Copy construct + Istream(const Istream&) = default; + + //- Destructor + virtual ~Istream() = default; + + // Constructors - //- Construct and set stream status + //- Default construct, set stream status Istream ( streamFormat format=ASCII, @@ -89,10 +98,6 @@ public: {} - //- Destructor - virtual ~Istream() = default; - - // Member Functions // Read Functions diff --git a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H index 6b0696e2b1c51e0454fd65c51d9cdead6fa2277c..9d6863757de7fec2df1f211d918a45ec855be390 100644 --- a/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H +++ b/src/OpenFOAM/db/IOstreams/IOstreams/Ostream.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -60,7 +60,7 @@ class Ostream { protected: - // Protected data + // Protected Data //- Indentation of the entry from the start of the keyword static constexpr const unsigned short entryIndentation_ = 16; @@ -74,9 +74,18 @@ protected: public: + // Generated Methods + + //- Copy construct + Ostream(const Ostream&) = default; + + //- Destructor + virtual ~Ostream() = default; + + // Constructors - //- Construct and set stream status + //- Default construct, set stream status Ostream ( streamFormat format=ASCII, @@ -88,10 +97,6 @@ public: {} - //- Destructor - virtual ~Ostream() = default; - - // Member Functions // Write Functions @@ -271,7 +276,7 @@ public: virtual int precision(const int p) = 0; - // Member operators + // Member Operators //- Return a non-const reference to const Ostream // Needed for write functions where the stream argument is temporary: diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C index 67ff84e1201ef6e68f1fa901072a95b8e1a52055..ee148925d6d9f14d544c7d96c2060d684d2a2fb2 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C @@ -249,27 +249,16 @@ Foam::Istream& Foam::UIPstream::read(token& t) return *this; } - // String - case token::tokenType::VERBATIM : - { - // Recurse to read actual string - read(t); - t.setType(token::tokenType::VERBATIM); - return *this; - } - case token::tokenType::VARIABLE : - { - // Recurse to read actual string - read(t); - t.setType(token::tokenType::VARIABLE); - return *this; - } + // String types case token::tokenType::STRING : + case token::tokenType::VARIABLE : + case token::tokenType::VERBATIM : { string val; if (read(val)) { t = std::move(val); + t.setType(token::tokenType(c)); } else { diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H index 065b0ac006f1389c9793049ea601616324447441..e22d4005796f568f5be8b88a4600acbb3e64a795 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H @@ -59,7 +59,7 @@ class UIPstream public UPstream, public Istream { - // Private data + // Private Data int fromProcNo_; @@ -134,7 +134,7 @@ public: } - // Read functions + // Read Functions //- Read into given buffer from given processor and return the // message size @@ -197,10 +197,10 @@ public: } - // Print + // Print - //- Print description of IOstream to Ostream - void print(Ostream&) const; + //- Print stream description to Ostream + void print(Ostream& os) const; }; diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C index 2aaba2327e39b6ca810c3912e7efdeb8d594e790..0b31db15e696cfd970793e1d7920b67343e7cfaf 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C @@ -202,18 +202,11 @@ bool Foam::UOPstream::write(const token& tok) return true; } - case token::tokenType::VERBATIM : - { - writeToBuffer(char(token::tokenType::VERBATIM)); - write(tok.stringToken()); - - return true; - } - case token::tokenType::VARIABLE : + case token::tokenType::VERBATIM : { - writeToBuffer(char(token::tokenType::VARIABLE)); - write(tok.stringToken()); + writeToBuffer(char(tok.type())); + writeStringToBuffer(tok.stringToken()); return true; } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H index 91d5d7df0110cc32aa72551beac9073308de6448..53918be8c40dd8e02f91375acacf33744919ab6b 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H @@ -60,7 +60,7 @@ class UOPstream public UPstream, public Ostream { - // Private data + // Private Data int toProcNo_; @@ -267,10 +267,10 @@ public: } - // Print + // Print - //- Print description of IOstream to Ostream - void print(Ostream& os) const; + //- Print stream description to Ostream + void print(Ostream& os) const; }; diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H index 75b94a22f1251a15cbbca8613b6608f981284bbb..38b60dd6cd8a568876ecfe5c4872d2309c3b5ba8 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2012 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -204,7 +204,7 @@ public: // Print - //- Print description of IOstream to Ostream + //- Print stream description to Ostream virtual void print(Ostream& os) const; }; diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H index 018cd7998713d156df16bec0a81cf30ca2daab0b..8ebc483eec1a48be03253eabe454397de7f93bb9 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/OSstream.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2014 OpenFOAM Foundation - Copyright (C) 2017-2018 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,20 +56,24 @@ class OSstream : public Ostream { - // Private data + // Private Data fileName name_; + std::ostream& os_; - // Private Member Functions +public: + + // Generated Methods + + //- Copy construct + OSstream(const OSstream&) = default; //- No copy assignment void operator=(const OSstream&) = delete; -public: - // Constructors //- Construct as wrapper around std::ostream and set stream status @@ -83,7 +87,7 @@ public: ); - // Member functions + // Member Functions // Enquiry @@ -218,7 +222,7 @@ public: // Print - //- Print description of IOstream to Ostream + //- Print stream description to Ostream virtual void print(Ostream& os) const; }; diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.H b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.H index 2fabbfdcaeaf405b0b4fec65fef7c759711bf800..3520058a2d42802f2264d85077ad34eb09cd32dd 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/prefixOSstream.H @@ -55,9 +55,10 @@ class prefixOSstream : public OSstream { - // Private data + // Private Data bool printPrefix_; + string prefix_; @@ -81,7 +82,7 @@ public: ); - // Member functions + // Member Functions // Enquiry @@ -98,7 +99,7 @@ public: } - // Write functions + // Write Functions //- Write token to stream or otherwise handle it. // \return false if the token type was not handled by this method @@ -143,10 +144,10 @@ public: virtual void indent(); - // Print + // Print - //- Print description of IOstream to Ostream - virtual void print(Ostream& os) const; + //- Print stream description to Ostream + virtual void print(Ostream& os) const; }; diff --git a/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H b/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H index 824bcf82fb64ebcfdd5f233dae3924f40e2824e1..49e23bc9b026a4c37375b2b0e5171fcf2079e811 100644 --- a/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H +++ b/src/OpenFOAM/db/IOstreams/StringStreams/StringStream.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,7 +59,7 @@ class StringStreamAllocator { protected: - // Member Data + // Protected Member Data //- The stream type typedef StreamType stream_type; @@ -70,23 +70,22 @@ protected: // Constructors - //- Construct null + //- Default construct StringStreamAllocator() : stream_() {} - //- Copy construct from string - StringStreamAllocator(const std::string& buffer) + StringStreamAllocator(const std::string& s) : - stream_(buffer) + stream_(s) {} public: - // Public Member Functions + // Member Functions //- Get the string - as Foam::string rather than std::string Foam::string str() const @@ -120,35 +119,44 @@ public: // Constructors - //- Construct from string - IStringStream + //- Default construct + explicit IStringStream ( - const Foam::string& buffer, + streamFormat format=ASCII, + versionNumber version=currentVersion + ) + : + allocator_type(), + ISstream(stream_, "input", format, version) + {} + + //- Construct from std::string + explicit IStringStream + ( + const std::string& s, streamFormat format=ASCII, versionNumber version=currentVersion, const Foam::string& name="input" ) : - allocator_type(buffer), + allocator_type(s), ISstream(stream_, name, format, version) {} - //- Construct from char* - IStringStream + explicit IStringStream ( - const char* buffer, + const char* s, streamFormat format=ASCII, versionNumber version=currentVersion, const Foam::string& name="input" ) : - allocator_type(buffer), + allocator_type(s), ISstream(stream_, name, format, version) {} - - //- Construct as copy of content + //- Copy construct, copies content and format IStringStream(const IStringStream& str) : allocator_type(str.str()), @@ -165,11 +173,11 @@ public: this->rewind(); } - //- Print description to Ostream + //- Print stream description to Ostream virtual void print(Ostream& os) const; - // Member operators + // Member Operators //- Return a non-const reference to const Istream // Needed for read-constructors where the stream argument is temporary. @@ -177,7 +185,6 @@ public: { return const_cast<IStringStream&>(*this); } - }; @@ -197,8 +204,8 @@ public: // Constructors - //- Construct and set stream status - OStringStream + //- Default construct + explicit OStringStream ( streamFormat format=ASCII, versionNumber version=currentVersion @@ -208,8 +215,7 @@ public: OSstream(stream_, "output", format, version) {} - - //- Construct as copy of content + //- Copy construct, copies content and format OStringStream(const OStringStream& str) : allocator_type(str.str()), @@ -233,9 +239,8 @@ public: stream_.rdbuf()->pubseekpos(0, std::ios_base::out); } - //- Print description to Ostream + //- Print stream description to Ostream virtual void print(Ostream& os) const; - }; diff --git a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C index f61de4c53b055a5dcd2477a8f708271dd62a7c0a..ba9d957fcd2993bcd1fda31c59ee22d1781524c8 100644 --- a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C +++ b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -453,4 +453,32 @@ void Foam::ITstream::append(tokenList&& newTokens, const bool lazy) } +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +void Foam::ITstream::operator=(const ITstream& is) +{ + Istream::operator=(is); + tokenList::operator=(is); + name_ = is.name_; + + rewind(); +} + + +void Foam::ITstream::operator=(const tokenList& toks) +{ + tokenList::operator=(toks); + + rewind(); +} + + +void Foam::ITstream::operator=(tokenList&& 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 170285844ea5566282fa9a61ff2d493676abdc28..546f354b2448def4cf5dae31e8712fcc07bc6c0f 100644 --- a/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H +++ b/src/OpenFOAM/db/IOstreams/Tstreams/ITstream.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,7 +46,7 @@ SourceFiles namespace Foam { -// Forward declaration +// Forward Declarations class ISstream; /*---------------------------------------------------------------------------*\ @@ -58,9 +58,9 @@ class ITstream public Istream, public tokenList { - // Private data + // Private Data - //- Name of ITstream + //- Name associated with the stream fileName name_; //- Index of token currently being read @@ -87,6 +87,18 @@ public: // Constructors + //- Copy construct + ITstream(const ITstream& is) + : + Istream(ASCII, currentVersion), + tokenList(is), + name_(is.name_), + tokenIndex_(0) + { + setOpened(); + setGood(); + } + //- Construct from components ITstream ( @@ -105,7 +117,6 @@ public: setGood(); } - //- Construct from components, transferring the tokens ITstream ( @@ -124,7 +135,6 @@ public: setGood(); } - //- Construct token list by parsing the input character sequence // Uses UIListStream internally. ITstream @@ -135,7 +145,6 @@ public: versionNumber version=currentVersion ); - //- Construct token list by parsing the input string // Uses UIListStream internally. ITstream @@ -146,7 +155,6 @@ public: versionNumber version=currentVersion ); - //- Construct token list by parsing the input character sequence // Uses UIListStream internally. ITstream @@ -158,21 +166,8 @@ public: ); - //- Copy construct - ITstream(const ITstream& is) - : - Istream(ASCII, currentVersion), - tokenList(is), - name_(is.name_), - tokenIndex_(0) - { - setOpened(); - setGood(); - } - - - //- Destructor - virtual ~ITstream() = default; + //- Destructor + virtual ~ITstream() = default; // Static Functions @@ -230,7 +225,7 @@ public: return tokenIndex_; } - //- Return the number of remaining tokens + //- The number of remaining tokens label nRemainingTokens() const { return size() - tokenIndex_; @@ -328,14 +323,26 @@ public: } - // Output + // Output + + //- Print stream description to Ostream + void print(Ostream& os) const; + + //- Concatenate tokens into a space-separated std::string. + //- The resulting string may contain quote characters. + std::string toString() const; + + + // Member Operators + + //- Copy assignment, with rewind() + void operator=(const ITstream& is); - //- Print description of stream to Ostream - void print(Ostream& os) const; + //- Copy assignment of tokens, with rewind() + void operator=(const tokenList& toks); - //- Concatenate tokens into a space-separated std::string. - //- The resulting string may contain quote characters. - std::string toString() const; + //- Move assignment of tokens, with rewind() + void operator=(tokenList&& toks); }; diff --git a/src/OpenFOAM/db/IOstreams/Tstreams/OTstream.H b/src/OpenFOAM/db/IOstreams/Tstreams/OTstream.H index be4a7d43c270dc0588881addb9ee094d5311d423..8f75c253de2c47face5062905bbeb82181505f1c 100644 --- a/src/OpenFOAM/db/IOstreams/Tstreams/OTstream.H +++ b/src/OpenFOAM/db/IOstreams/Tstreams/OTstream.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -62,8 +62,8 @@ public: // Constructors - //- Construct and set stream status - OTstream + //- Default construct, set stream status + explicit OTstream ( streamFormat format=ASCII, versionNumber version=currentVersion @@ -227,7 +227,6 @@ public: } - // Inquiry //- Return flags of output stream @@ -260,7 +259,7 @@ public: DynamicList<token>::clear(); } - //- Print description of IOstream to Ostream + //- Print stream description to Ostream void print(Ostream& os) const; }; diff --git a/src/OpenFOAM/db/IOstreams/dummy/dummyISstream.H b/src/OpenFOAM/db/IOstreams/dummy/dummyISstream.H index 315a4faf9a7daf53580c68fd16b8ce6ba5c2e2f7..01ebb38d6835fc8a7d8bbc76c915da8ea4535785 100644 --- a/src/OpenFOAM/db/IOstreams/dummy/dummyISstream.H +++ b/src/OpenFOAM/db/IOstreams/dummy/dummyISstream.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,9 +28,15 @@ Class Foam::dummyISstream Description - Dummy stream for input. Aborts at any attempt to read from it. + Dummy input stream, which can be used as a placeholder for interfaces + taking an Istream or ISstream. Aborts at any attempt to read from it. + +Note + The inheritance from an empty IStringStream is solely for convenience + of implementation and should not be relied upon. SourceFiles + dummyISstream.H \*---------------------------------------------------------------------------*/ @@ -54,17 +60,13 @@ class dummyISstream { public: - // Constructors - - //- Construct null - dummyISstream() - : - IStringStream(string::null) - {} + // Generated Methods + //- Default construct + dummyISstream() = default; - //- Destructor - virtual ~dummyISstream() = default; + //- Destructor + virtual ~dummyISstream() = default; // Member Functions diff --git a/src/OpenFOAM/db/IOstreams/dummy/dummyIstream.H b/src/OpenFOAM/db/IOstreams/dummy/dummyIstream.H index 5f97dbed994a3e6fecaf74a5a43801de072666c5..bc362749f9a45a06d9a21c16e4063ccd55b61b5e 100644 --- a/src/OpenFOAM/db/IOstreams/dummy/dummyIstream.H +++ b/src/OpenFOAM/db/IOstreams/dummy/dummyIstream.H @@ -5,8 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -24,142 +23,25 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -Class +Typedef Foam::dummyIstream Description - Dummy stream for input. Aborts at any attempt to read from it. - -SourceFiles + Dummy input stream, currently the same as Foam::dummyISstream. \*---------------------------------------------------------------------------*/ #ifndef dummyIstream_H #define dummyIstream_H -#include "Istream.H" +#include "dummyISstream.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -/*---------------------------------------------------------------------------*\ - Class dummyIstream Declaration -\*---------------------------------------------------------------------------*/ - -class dummyIstream -: - public Istream -{ -public: - - // Constructors - - //- Construct null - dummyIstream() = default; - - - //- Destructor - ~dummyIstream() = default; - - - // Member Functions - - // Read Functions - - //- Return next token from stream - virtual Istream& read(token&) - { - NotImplemented; - return *this; - } - - //- Read a character - virtual Istream& read(char&) - { - NotImplemented; - return *this; - } - - //- Read a word - virtual Istream& read(word&) - { - NotImplemented; - return *this; - } - - // Read a string (including enclosing double-quotes) - virtual Istream& read(string&) - { - NotImplemented; - return *this; - } - - //- Read a label - virtual Istream& read(label&) - { - NotImplemented; - return *this; - } - - //- Read a floatScalar - virtual Istream& read(floatScalar&) - { - NotImplemented; - return *this; - } - - //- Read a doubleScalar - virtual Istream& read(doubleScalar&) - { - NotImplemented; - return *this; - } - - //- Read binary block - virtual Istream& read(char*, std::streamsize) - { - NotImplemented; - return *this; - } - - //- Low-level raw binary read - virtual Istream& readRaw(char*, std::streamsize) - { - NotImplemented; - return *this; - } - - //- Start of low-level raw binary read - virtual bool beginRawRead() - { - return false; - } - - //- End of low-level raw binary read - virtual bool endRawRead() - { - return false; - } - - //- Rewind the stream so that it may be read again - virtual void rewind() - {} - - //- Return flags of stream - virtual ios_base::fmtflags flags() const - { - return ios_base::fmtflags(0); - } - - //- Set flags of stream - virtual ios_base::fmtflags flags(const ios_base::fmtflags) - { - return ios_base::fmtflags(0); - } -}; - +typedef dummyISstream dummyIstream; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/IOstreams/hashes/base64Layer.H b/src/OpenFOAM/db/IOstreams/hashes/base64Layer.H index 8f71557c89f275667a59125be039701d43ba0964..602b63553152b7c7ef43668d872ba1c1f0b60832 100644 --- a/src/OpenFOAM/db/IOstreams/hashes/base64Layer.H +++ b/src/OpenFOAM/db/IOstreams/hashes/base64Layer.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2017 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -55,7 +55,7 @@ namespace Foam class base64Layer { - // Private data + // Private Data //- The output stream for the layer std::ostream& os_; @@ -97,10 +97,10 @@ public: // Constructors //- Construct and attach to an output stream - base64Layer(std::ostream& os); + explicit base64Layer(std::ostream& os); - //- Destructor + //- Destructor. Performs close() ~base64Layer(); @@ -117,11 +117,11 @@ public: void reset(); //- End the encoding sequence, padding the final characters with '='. - // Return false if no encoding was actually performed. + // \return false if no encoding was actually performed. bool close(); - }; + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/db/IOstreams/memory/IListStream.H b/src/OpenFOAM/db/IOstreams/memory/IListStream.H index 7f125d2f3df67512c8c7921be7c5c736ef14ac88..260ea509abde74dbe9b0c16f52c1e1c608291b5c 100644 --- a/src/OpenFOAM/db/IOstreams/memory/IListStream.H +++ b/src/OpenFOAM/db/IOstreams/memory/IListStream.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,7 +66,7 @@ protected: // Constructors - //- Construct empty + //- Default construct IListStreamAllocator() : List<char>(), @@ -142,21 +142,20 @@ public: // Constructors - //- Construct with an empty list - IListStream + //- Default construct with an empty list + explicit IListStream ( streamFormat format=ASCII, - versionNumber version=currentVersion, - const Foam::string& name="input" + versionNumber version=currentVersion ) : allocator_type(), - ISstream(stream_, name, format, version) + ISstream(stream_, "input", format, version) {} //- Move construct from List - IListStream + explicit IListStream ( ::Foam::List<char>&& buffer, // Fully qualify (issue #1521) streamFormat format=ASCII, @@ -171,7 +170,7 @@ public: //- Move construct from DynamicList template<int SizeMin> - IListStream + explicit IListStream ( DynamicList<char,SizeMin>&& buffer, streamFormat format=ASCII, @@ -204,11 +203,11 @@ public: } - //- Print description to Ostream + //- Print stream description to Ostream virtual void print(Ostream& os) const; - // Member operators + // Member Operators //- A non-const reference to const Istream // Needed for read-constructors where the stream argument is temporary diff --git a/src/OpenFOAM/db/IOstreams/memory/OCountStream.H b/src/OpenFOAM/db/IOstreams/memory/OCountStream.H index d8adf3cea366b1181bd3c6341ab46a557eff253c..cc1d325695fb2525a29dc0f912ef8e9e88539ce3 100644 --- a/src/OpenFOAM/db/IOstreams/memory/OCountStream.H +++ b/src/OpenFOAM/db/IOstreams/memory/OCountStream.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2018 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -81,7 +81,7 @@ protected: public: - //- Construct null, or with precount size + //- Default construct, or with precount size countstreambuf(std::streamsize precount=0) : size_(precount) @@ -116,7 +116,7 @@ class ocountstream { public: - //- Construct null + //- Default construct ocountstream() : countstreambuf(), @@ -148,7 +148,7 @@ class OCountStreamAllocator { protected: - // Protected data + // Protected Data typedef std::ostream stream_type; @@ -161,7 +161,7 @@ protected: // Constructors - //- Construct null, or with precount size + //- Default construct, or with precount size OCountStreamAllocator(std::streamsize precount=0) : buf_(precount), @@ -213,22 +213,22 @@ public: // Constructors - //- Construct and set stream status - OCountStream + //- Default construct + explicit OCountStream ( streamFormat format=ASCII, versionNumber version=currentVersion ) : allocator_type(), - OSstream(stream_, "output", format, version) + OSstream(stream_, "count", format, version) {} //- Copy construct - OCountStream(const OCountStream& os) + OCountStream(const OCountStream& str) : - allocator_type(os.size()), - OSstream(stream_, os.name(), os.format(), os.version()) + allocator_type(str.size()), + OSstream(stream_, str.name(), str.format(), str.version()) {} @@ -241,11 +241,11 @@ public: setGood(); // resynchronize with internal state } - //- Print description to Ostream + //- Print stream description to Ostream virtual void print(Ostream& os) const; - }; + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/db/IOstreams/memory/OListStream.H b/src/OpenFOAM/db/IOstreams/memory/OListStream.H index 149e5d7c866cd64281df9fb7d95a602157f9450d..c556e3ebd3055f74b796d15e77c346cfe9180320 100644 --- a/src/OpenFOAM/db/IOstreams/memory/OListStream.H +++ b/src/OpenFOAM/db/IOstreams/memory/OListStream.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2019 OpenCFD Ltd. + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -178,7 +178,7 @@ class OListStreamAllocator // Constructors - //- Construct with an empty list, or specified number of reserved bytes + //- Default construct, with initial reserved number of bytes dynbuf(size_t nbytes = 512) : storage_() @@ -275,7 +275,7 @@ protected: // Constructors - //- Construct with an empty list or specified number of reserved bytes + //- Default construct, with initial reserved number of bytes OListStreamAllocator(size_t nbytes = 512) : buf_(nbytes), @@ -406,8 +406,8 @@ public: // Constructors - //- Construct with an empty list - OListStream + //- Default construct (empty output) + explicit OListStream ( streamFormat format=ASCII, versionNumber version=currentVersion @@ -417,9 +417,8 @@ public: OSstream(stream_, "output", format, version) {} - - //- Construct with a specified number of reserved bytes - OListStream + //- Construct with initial reserved number of bytes + explicit OListStream ( size_t nbytes, streamFormat format=ASCII, @@ -430,9 +429,8 @@ public: OSstream(stream_, "output", format, version) {} - //- Move construct from an existing List - OListStream + explicit OListStream ( List<char>&& buffer, streamFormat format=ASCII, @@ -443,10 +441,9 @@ public: OSstream(stream_, "output", format, version) {} - //- Move construct from an existing DynamicList template<int SizeMin> - OListStream + explicit OListStream ( DynamicList<char,SizeMin>&& buffer, streamFormat format=ASCII, @@ -467,9 +464,8 @@ public: setGood(); // resynchronize with internal state } - //- Print description to Ostream + //- Print stream description to Ostream virtual void print(Ostream& os) const; - }; diff --git a/src/OpenFOAM/db/IOstreams/memory/UIListStream.H b/src/OpenFOAM/db/IOstreams/memory/UIListStream.H index 33cabf0900d43117a628765ae477d6d6861a270c..3a6c6e98aad6a06a34aab1b340197c7458f8963d 100644 --- a/src/OpenFOAM/db/IOstreams/memory/UIListStream.H +++ b/src/OpenFOAM/db/IOstreams/memory/UIListStream.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2018 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -123,7 +123,7 @@ class UIListStreamAllocator { protected: - // Protected data + // Protected Data typedef std::istream stream_type; @@ -137,7 +137,7 @@ protected: // Constructors //- Construct for character array and number of bytes - UIListStreamAllocator(char *buffer, size_t nbytes) + UIListStreamAllocator(char* buffer, size_t nbytes) : buf_(buffer, nbytes), stream_(&buf_) @@ -147,7 +147,7 @@ protected: // Protected Member Functions //- Reset buffer pointers - inline void reset(char *buffer, size_t nbytes) + inline void reset(char* buffer, size_t nbytes) { buf_.resetg(buffer, nbytes); } @@ -159,7 +159,7 @@ protected: public: - // Public Member Functions + // Member Functions //- Const UList access to the input characters (shallow copy). inline const UList<char> list() const @@ -228,7 +228,7 @@ public: //- Construct using data area from a FixedList template<unsigned N> - UIListStream + explicit UIListStream ( const FixedList<char, N>& buffer, streamFormat format=ASCII, @@ -255,7 +255,7 @@ public: //- Construct using data area from a List and its inherent storage size // Uses addressed size, thus no special treatment for a DynamicList - UIListStream + explicit UIListStream ( const UList<char>& buffer, streamFormat format=ASCII, @@ -282,7 +282,7 @@ public: setGood(); // resynchronize with internal state } - //- Print description to Ostream + //- Print stream description to Ostream virtual void print(Ostream& os) const; @@ -294,7 +294,6 @@ public: { return const_cast<Istream&>(static_cast<const Istream&>(*this)); } - }; diff --git a/src/OpenFOAM/db/IOstreams/memory/UOListStream.H b/src/OpenFOAM/db/IOstreams/memory/UOListStream.H index ff17be04a705f5e75617b09224ec27b1b18b468b..34487f262065e2634543a56df65d5286c9f7e77c 100644 --- a/src/OpenFOAM/db/IOstreams/memory/UOListStream.H +++ b/src/OpenFOAM/db/IOstreams/memory/UOListStream.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2018 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -104,7 +104,7 @@ class UOListStreamAllocator { protected: - // Protected data + // Protected Data typedef std::ostream stream_type; @@ -118,7 +118,7 @@ protected: // Constructors //- Construct for character array and number of bytes - UOListStreamAllocator(char *buffer, size_t nbytes) + UOListStreamAllocator(char* buffer, size_t nbytes) : buf_(buffer, nbytes), stream_(&buf_) @@ -131,7 +131,7 @@ protected: public: - // Public Member Functions + // Member Functions //- Const UList access to the characters written (shallow copy). inline const UList<char> list() const @@ -198,7 +198,6 @@ public: OSstream(stream_, "output", format, version) {} - //- Construct using data area from a List and number of bytes UOListStream ( @@ -213,7 +212,7 @@ public: //- Construct using data area from a FixedList template<unsigned N> - UOListStream + explicit UOListStream ( FixedList<char, N>& buffer, streamFormat format=ASCII, @@ -224,7 +223,7 @@ public: {} //- Construct using data area from a List and its inherent storage size - UOListStream + explicit UOListStream ( UList<char>& buffer, streamFormat format=ASCII, @@ -237,7 +236,7 @@ public: //- Construct using data area from a DynamicList and its capacity template<int SizeMin> - UOListStream + explicit UOListStream ( DynamicList<char,SizeMin>& buffer, streamFormat format=ASCII, @@ -257,9 +256,8 @@ public: setGood(); // resynchronize with internal state } - //- Print description to Ostream + //- Print stream description to Ostream virtual void print(Ostream& os) const; - }; diff --git a/src/OpenFOAM/db/IOstreams/memory/memoryStreamBuffer.H b/src/OpenFOAM/db/IOstreams/memory/memoryStreamBuffer.H index c39a3642f37b35b4ae9b2573bdf7d6205e1a5158..fe72912421cec4d213beadcfcae13f90c4fcc593 100644 --- a/src/OpenFOAM/db/IOstreams/memory/memoryStreamBuffer.H +++ b/src/OpenFOAM/db/IOstreams/memory/memoryStreamBuffer.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -44,7 +44,7 @@ Description namespace Foam { -// Forward declarations +// Forward Declarations class Ostream; /*---------------------------------------------------------------------------*\ @@ -146,7 +146,7 @@ protected: public: - // Forward declarations + // Forward Declarations class in; class out; }; @@ -163,7 +163,7 @@ class memorybuf::in { protected: - //- Default construct null + //- Default construct in() = default; //- Get sequence of characters @@ -244,7 +244,7 @@ class memorybuf::out { protected: - //- Default construct null + //- Default construct out() = default; //- Put sequence of characters diff --git a/src/fileFormats/ensight/file/ensightFile.H b/src/fileFormats/ensight/file/ensightFile.H index a3f93d95b4389da3f6eca6ac73a0a40dd2a6e62a..6f78b573321099c7f2e06398b43dc6d0a88584f4 100644 --- a/src/fileFormats/ensight/file/ensightFile.H +++ b/src/fileFormats/ensight/file/ensightFile.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2016-2019 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,7 +56,7 @@ class ensightFile : public OFstream { - // Private data + // Private Data //- Allow undef in results static bool allowUndef_; @@ -85,7 +85,7 @@ class ensightFile public: - // Static Member Functions + // Static Functions //- Return a null ensightFile inline static const ensightFile& null() @@ -96,9 +96,9 @@ public: // Constructors - //- Construct from pathname. - // The entire pathname is checked for valid ensight naming. - ensightFile + //- Construct from pathName. + // The entire pathName is checked for valid ensight naming. + explicit ensightFile ( const fileName& pathname, IOstream::streamFormat format=IOstream::BINARY @@ -202,7 +202,6 @@ public: //- Write an indirect list of scalars as "%12.5e" or as binary // With carriage return after each value (ascii stream) void writeList(const UList<scalar>& field, const labelUList& addr); - }; diff --git a/src/fileFormats/ensight/file/ensightGeoFile.H b/src/fileFormats/ensight/file/ensightGeoFile.H index 5f0057d2c0bf7bf893fae873b7a72bfd33911891..1415ecf69f82a37b5c98c6daa0bea1d3eccf36e7 100644 --- a/src/fileFormats/ensight/file/ensightGeoFile.H +++ b/src/fileFormats/ensight/file/ensightGeoFile.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation - Copyright (C) 2016 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -64,7 +64,7 @@ class ensightGeoFile public: - // Static Member Functions + // Static Functions //- Return a null ensightGeoFile inline static const ensightGeoFile& null() @@ -75,9 +75,9 @@ public: // Constructors - //- Construct from pathname. - // The entire pathname is checked for valid ensight naming. - ensightGeoFile + //- Construct from pathName. + // The entire pathName is checked for valid ensight naming. + explicit ensightGeoFile ( const fileName& pathname, IOstream::streamFormat format=IOstream::BINARY @@ -113,9 +113,9 @@ public: //- Begin a "coordinates" block void beginCoordinates(const label npoints); - }; + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/surfMesh/surfaceFormats/obj/OBJstream.H b/src/surfMesh/surfaceFormats/obj/OBJstream.H index 5079e815a3510781baa4fc3f0433c0199a0ac67e..699c8438fcab3e2dacfae91ee537204608a8264c 100644 --- a/src/surfMesh/surfaceFormats/obj/OBJstream.H +++ b/src/surfMesh/surfaceFormats/obj/OBJstream.H @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2015 OpenFOAM Foundation + Copyright (C) 2017-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,6 +49,7 @@ SourceFiles namespace Foam { +// Forward Declarations class treeBoundBox; /*---------------------------------------------------------------------------*\ @@ -58,7 +60,7 @@ class OBJstream : public OFstream { - // Private data + // Private Data bool startOfLine_; @@ -71,14 +73,14 @@ class OBJstream public: - // Declare name of the class and its debug switch + //- Declare type-name (with debug switch) ClassName("OBJstream"); // Constructors //- Construct from pathname - OBJstream + explicit OBJstream ( const fileName& pathname, streamFormat format=ASCII, @@ -184,7 +186,6 @@ public: const treeBoundBox& bb, const bool lines = true ); - };