mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: provide Istream::rewind() implementation
- base implementation drops any putback token
This commit is contained in:
@ -275,9 +275,11 @@ const std::istream& Foam::IFstream::stdStream() const
|
||||
|
||||
void Foam::IFstream::rewind()
|
||||
{
|
||||
Istream::rewind(); // Drop any putback
|
||||
lineNumber_ = 1; // Reset line number
|
||||
|
||||
if (IOstreamOption::COMPRESSED == ifstreamPointer::whichCompression())
|
||||
{
|
||||
lineNumber_ = 1; // Reset line number
|
||||
ifstreamPointer::reopen_gz(this->name());
|
||||
setState(ifstreamPointer::get()->rdstate());
|
||||
}
|
||||
|
||||
@ -218,6 +218,12 @@ char Foam::Istream::readEndList(const char* funcName)
|
||||
}
|
||||
|
||||
|
||||
void Foam::Istream::rewind()
|
||||
{
|
||||
putBackClear(); // Drop any putback
|
||||
}
|
||||
|
||||
|
||||
Foam::Istream& Foam::Istream::operator()() const
|
||||
{
|
||||
if (!good())
|
||||
|
||||
@ -175,7 +175,8 @@ public:
|
||||
//- operation.
|
||||
virtual Istream& readRaw(char* data, std::streamsize count) = 0;
|
||||
|
||||
//- Rewind the stream so that it may be read again
|
||||
//- Rewind the stream so that it may be read again.
|
||||
// The base implementation clears any putback.
|
||||
virtual void rewind() = 0;
|
||||
|
||||
|
||||
|
||||
@ -563,6 +563,8 @@ Foam::label Foam::UIPstreamBase::remaining() const noexcept
|
||||
|
||||
void Foam::UIPstreamBase::rewind()
|
||||
{
|
||||
Istream::rewind(); // Drop any putback
|
||||
|
||||
recvBufPos_ = 0; // Assume the entire buffer is for us to read from
|
||||
setOpened();
|
||||
setGood();
|
||||
|
||||
@ -1084,6 +1084,7 @@ bool Foam::ISstream::endRawRead()
|
||||
|
||||
void Foam::ISstream::rewind()
|
||||
{
|
||||
Istream::rewind(); // Drop any putback
|
||||
lineNumber_ = 1; // Reset line number
|
||||
|
||||
stdStream().clear(); // Clear the iostate error state flags
|
||||
|
||||
@ -531,7 +531,11 @@ public:
|
||||
virtual bool endRawRead() override { return false; }
|
||||
|
||||
//- Rewind the stream so that it may be read again. Same as seek(0)
|
||||
virtual void rewind() override { ITstream::seek(0); }
|
||||
virtual void rewind() override
|
||||
{
|
||||
Istream::rewind();
|
||||
ITstream::seek(0);
|
||||
}
|
||||
|
||||
|
||||
// Output
|
||||
|
||||
@ -357,6 +357,7 @@ public:
|
||||
//- Rewind the stream, clearing any old errors
|
||||
virtual void rewind() override
|
||||
{
|
||||
Istream::rewind();
|
||||
stream_.rewind();
|
||||
syncState();
|
||||
}
|
||||
|
||||
@ -419,6 +419,7 @@ public:
|
||||
//- Rewind the stream, clearing any old errors
|
||||
virtual void rewind() override
|
||||
{
|
||||
Istream::rewind();
|
||||
stream_.rewind();
|
||||
syncState();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user