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()
|
void Foam::IFstream::rewind()
|
||||||
{
|
{
|
||||||
|
Istream::rewind(); // Drop any putback
|
||||||
|
lineNumber_ = 1; // Reset line number
|
||||||
|
|
||||||
if (IOstreamOption::COMPRESSED == ifstreamPointer::whichCompression())
|
if (IOstreamOption::COMPRESSED == ifstreamPointer::whichCompression())
|
||||||
{
|
{
|
||||||
lineNumber_ = 1; // Reset line number
|
|
||||||
ifstreamPointer::reopen_gz(this->name());
|
ifstreamPointer::reopen_gz(this->name());
|
||||||
setState(ifstreamPointer::get()->rdstate());
|
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
|
Foam::Istream& Foam::Istream::operator()() const
|
||||||
{
|
{
|
||||||
if (!good())
|
if (!good())
|
||||||
|
|||||||
@ -175,7 +175,8 @@ public:
|
|||||||
//- operation.
|
//- operation.
|
||||||
virtual Istream& readRaw(char* data, std::streamsize count) = 0;
|
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;
|
virtual void rewind() = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -563,6 +563,8 @@ Foam::label Foam::UIPstreamBase::remaining() const noexcept
|
|||||||
|
|
||||||
void Foam::UIPstreamBase::rewind()
|
void Foam::UIPstreamBase::rewind()
|
||||||
{
|
{
|
||||||
|
Istream::rewind(); // Drop any putback
|
||||||
|
|
||||||
recvBufPos_ = 0; // Assume the entire buffer is for us to read from
|
recvBufPos_ = 0; // Assume the entire buffer is for us to read from
|
||||||
setOpened();
|
setOpened();
|
||||||
setGood();
|
setGood();
|
||||||
|
|||||||
@ -1084,6 +1084,7 @@ bool Foam::ISstream::endRawRead()
|
|||||||
|
|
||||||
void Foam::ISstream::rewind()
|
void Foam::ISstream::rewind()
|
||||||
{
|
{
|
||||||
|
Istream::rewind(); // Drop any putback
|
||||||
lineNumber_ = 1; // Reset line number
|
lineNumber_ = 1; // Reset line number
|
||||||
|
|
||||||
stdStream().clear(); // Clear the iostate error state flags
|
stdStream().clear(); // Clear the iostate error state flags
|
||||||
|
|||||||
@ -531,7 +531,11 @@ public:
|
|||||||
virtual bool endRawRead() override { return false; }
|
virtual bool endRawRead() override { return false; }
|
||||||
|
|
||||||
//- Rewind the stream so that it may be read again. Same as seek(0)
|
//- 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
|
// Output
|
||||||
|
|||||||
@ -357,6 +357,7 @@ public:
|
|||||||
//- Rewind the stream, clearing any old errors
|
//- Rewind the stream, clearing any old errors
|
||||||
virtual void rewind() override
|
virtual void rewind() override
|
||||||
{
|
{
|
||||||
|
Istream::rewind();
|
||||||
stream_.rewind();
|
stream_.rewind();
|
||||||
syncState();
|
syncState();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -419,6 +419,7 @@ public:
|
|||||||
//- Rewind the stream, clearing any old errors
|
//- Rewind the stream, clearing any old errors
|
||||||
virtual void rewind() override
|
virtual void rewind() override
|
||||||
{
|
{
|
||||||
|
Istream::rewind();
|
||||||
stream_.rewind();
|
stream_.rewind();
|
||||||
syncState();
|
syncState();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user