mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Expose STL std streams in a consistent manner for serial streams.
Previously Fstreams had stdStream() as a public member and the other streams had stream() as a protected member. All serial streams now have public method stdStream() and the stream() method has been eliminated. This is not only more consistent, but also avoids confusion (for the programmer, not the compiler) with the ITstream::stream() method.
This commit is contained in:
@ -78,17 +78,6 @@ Foam::IFstreamAllocator::~IFstreamAllocator()
|
||||
}
|
||||
|
||||
|
||||
std::istream& Foam::IFstreamAllocator::stdStream()
|
||||
{
|
||||
if (!ifPtr_)
|
||||
{
|
||||
FatalErrorIn("IFstreamAllocator::stdStream()")
|
||||
<< "No stream allocated" << abort(FatalError);
|
||||
}
|
||||
return *ifPtr_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::IFstream::IFstream
|
||||
@ -143,6 +132,28 @@ Foam::IFstream::~IFstream()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
std::istream& Foam::IFstream::stdStream()
|
||||
{
|
||||
if (!ifPtr_)
|
||||
{
|
||||
FatalErrorIn("IFstream::stdStream()")
|
||||
<< "No stream allocated" << abort(FatalError);
|
||||
}
|
||||
return *ifPtr_;
|
||||
}
|
||||
|
||||
|
||||
const std::istream& Foam::IFstream::stdStream() const
|
||||
{
|
||||
if (!ifPtr_)
|
||||
{
|
||||
FatalErrorIn("IFstream::stdStream() const")
|
||||
<< "No stream allocated" << abort(FatalError);
|
||||
}
|
||||
return *ifPtr_;
|
||||
}
|
||||
|
||||
|
||||
void Foam::IFstream::print(Ostream& os) const
|
||||
{
|
||||
// Print File data
|
||||
|
||||
@ -51,7 +51,7 @@ namespace Foam
|
||||
class IFstream;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class IFstreamAllocator Declaration
|
||||
Class IFstreamAllocator Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- A std::istream with ability to handle compressed files
|
||||
@ -74,19 +74,11 @@ class IFstreamAllocator
|
||||
// Destructor
|
||||
|
||||
~IFstreamAllocator();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Access to underlying std::istream (for e.g. lexer)
|
||||
istream& stdStream();
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class IFstream Declaration
|
||||
Class IFstream Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class IFstream
|
||||
@ -136,6 +128,16 @@ public:
|
||||
return pathname_;
|
||||
}
|
||||
|
||||
|
||||
// STL stream
|
||||
|
||||
//- Access to underlying std::istream
|
||||
virtual istream& stdStream();
|
||||
|
||||
//- Const access to underlying std::istream
|
||||
virtual const istream& stdStream() const;
|
||||
|
||||
|
||||
// Print
|
||||
|
||||
//- Print description of IOstream to Ostream
|
||||
|
||||
@ -81,17 +81,6 @@ Foam::OFstreamAllocator::~OFstreamAllocator()
|
||||
}
|
||||
|
||||
|
||||
std::ostream& Foam::OFstreamAllocator::stdStream()
|
||||
{
|
||||
if (!ofPtr_)
|
||||
{
|
||||
FatalErrorIn("OFstreamAllocator::stdStream()")
|
||||
<< "No stream allocated." << abort(FatalError);
|
||||
}
|
||||
return *ofPtr_;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::OFstream::OFstream
|
||||
@ -131,7 +120,7 @@ Foam::OFstream::OFstream
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::OFstream::~OFstream()
|
||||
{}
|
||||
@ -139,6 +128,28 @@ Foam::OFstream::~OFstream()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
std::ostream& Foam::OFstream::stdStream()
|
||||
{
|
||||
if (!ofPtr_)
|
||||
{
|
||||
FatalErrorIn("OFstream::stdStream()")
|
||||
<< "No stream allocated." << abort(FatalError);
|
||||
}
|
||||
return *ofPtr_;
|
||||
}
|
||||
|
||||
|
||||
const std::ostream& Foam::OFstream::stdStream() const
|
||||
{
|
||||
if (!ofPtr_)
|
||||
{
|
||||
FatalErrorIn("OFstreamAllocator::stdStream() const")
|
||||
<< "No stream allocated." << abort(FatalError);
|
||||
}
|
||||
return *ofPtr_;
|
||||
}
|
||||
|
||||
|
||||
void Foam::OFstream::print(Ostream& os) const
|
||||
{
|
||||
os << " OFstream: ";
|
||||
|
||||
@ -51,7 +51,7 @@ namespace Foam
|
||||
class OFstream;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class OFstreamAllocator Declaration
|
||||
Class OFstreamAllocator Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
//- A std::ostream with ability to handle compressed files
|
||||
@ -74,18 +74,11 @@ class OFstreamAllocator
|
||||
|
||||
~OFstreamAllocator();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Access to underlying std::ostream
|
||||
ostream& stdStream();
|
||||
};
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class OFstream Declaration
|
||||
Class OFstream Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class OFstream
|
||||
@ -138,6 +131,15 @@ public:
|
||||
}
|
||||
|
||||
|
||||
// STL stream
|
||||
|
||||
//- Access to underlying std::ostream
|
||||
virtual ostream& stdStream();
|
||||
|
||||
//- Const access to underlying std::ostream
|
||||
virtual const ostream& stdStream() const;
|
||||
|
||||
|
||||
// Print
|
||||
|
||||
//- Print description of IOstream to Ostream
|
||||
@ -146,8 +148,8 @@ public:
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
// Global predefined null output stream
|
||||
|
||||
//- Global predefined null output stream "/dev/null"
|
||||
extern OFstream Snull;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Reference in New Issue
Block a user