A base calss for input/output streams. More...
Public Types | |
enum | streamAccess : char { CLOSED = 0, OPENED } |
enum | writeFormat : char { ASCII = 0, BINARY } |
Public Member Functions | |
IOstream () | |
Default. More... | |
IOstream (writeFormat wF) | |
Construct and set write format. More... | |
IOstream (const IOstream &)=default | |
Copy. More... | |
virtual | ~IOstream ()=default |
Destructor. More... | |
virtual const word & | name () const |
Return the name of the stream. More... | |
virtual word & | name () |
Return non-const access to the name of the stream. More... | |
virtual bool | check (const char *operation) const |
Check IOstream status for given operation. More... | |
bool | fatalCheck (const char *operation) const |
Check IOstream status for given operation. More... | |
bool | opened () const |
Return true if stream has been opened. More... | |
bool | closed () const |
Return true if stream is closed. More... | |
bool | isBinary () const |
Return true if stream format is binray. More... | |
bool | good () const |
Return true if next operation might succeed. More... | |
bool | eof () const |
Return true if end of input seen. More... | |
bool | fail () const |
Return true if next operation will fail. More... | |
bool | bad () const |
Return true if stream is corrupted. More... | |
operator bool () const | |
Return true if the stream has not failed. More... | |
bool | operator! () const |
Return true if the stream has failed. More... | |
int32 | lineNumber () const |
Const access to the current stream line number. More... | |
int32 & | lineNumber () |
Non-const access to the current stream line number. More... | |
int32 | lineNumber (const int32 num) |
Set the stream line number return the previous value. More... | |
virtual ios_base::fmtflags | flags () const =0 |
Return flags of stream. More... | |
void | setEof () |
Set stream to have reached eof. More... | |
void | setFail () |
Set stream to have failed. More... | |
void | setBad () |
Set stream to be bad. More... | |
virtual ios_base::fmtflags | flags (const ios_base::fmtflags f)=0 |
Set flags of stream. More... | |
ios_base::fmtflags | setf (const ios_base::fmtflags f) |
Set flags of stream. More... | |
ios_base::fmtflags | setf (const ios_base::fmtflags f, const ios_base::fmtflags mask) |
Set flags of given field of stream. More... | |
void | unsetf (const ios_base::fmtflags f) |
Unset flags of stream. More... | |
Static Public Member Functions | |
static unsigned int | defaultPrecision () |
Return the default precision. More... | |
static unsigned int | defaultPrecision (unsigned int prec) |
Reset the default precision return the previous value. More... | |
Static Public Attributes | |
static unsigned int | precision_ = 6 |
Default precision, only works for ASCII. More... | |
Protected Member Functions | |
void | setOpened () |
Set stream opened. More... | |
void | setClosed () |
Set stream closed. More... | |
void | setState (ios_base::iostate state) |
Set stream state. More... | |
void | setWriteFormat (writeFormat wF) |
void | setGood () |
Set stream to be good. More... | |
Protected Attributes | |
streamAccess | openClosed_ |
Is stream open or closed. More... | |
writeFormat | writeFormat_ = ASCII |
write format More... | |
ios_base::iostate | ioState_ |
state More... | |
int32 | lineNumber_ |
The file line. More... | |
Static Protected Attributes | |
static word | staticName_ |
Name for any generic stream - normally treat as readonly. More... | |
A base calss for input/output streams.
It is based on OpenFOAM stream, with some modifications/simplifications to be tailored to our needs
Definition at line 47 of file IOstream.hpp.
enum streamAccess : char |
Enumerator | |
---|---|
CLOSED | |
OPENED | stream is not open stream is open |
Definition at line 53 of file IOstream.hpp.
enum writeFormat : char |
Enumerator | |
---|---|
ASCII | |
BINARY |
Definition at line 59 of file IOstream.hpp.
|
inlineexplicit |
Default.
Definition at line 123 of file IOstream.hpp.
References IOstream::setBad().
|
inlineexplicit |
Construct and set write format.
Definition at line 133 of file IOstream.hpp.
References IOstream::setBad().
|
virtualdefault |
Destructor.
|
inlineprotected |
Set stream opened.
Definition at line 90 of file IOstream.hpp.
References IOstream::openClosed_, and IOstream::OPENED.
|
inlineprotected |
Set stream closed.
Definition at line 96 of file IOstream.hpp.
References IOstream::CLOSED, and IOstream::openClosed_.
|
inlineprotected |
|
inlineprotected |
Definition at line 107 of file IOstream.hpp.
References IOstream::writeFormat_.
|
inlineprotected |
|
virtual |
Return the name of the stream.
Reimplemented in iTstream, Istream, and Ostream.
Definition at line 31 of file IOstream.cpp.
References IOstream::staticName_.
Referenced by box::box(), iEntry< Key, T * >::createEntry(), cylinder::cylinder(), dataEntry::dataEntry(), dictionary::dictionary(), iBox< intType >::iBox(), pFlow::operator<<(), pFlow::operator>>(), iIstream::putBack(), timeInterval::read(), Logical::read(), line::read(), dataEntry::read(), rotatingAxis::read(), multiTriSurface::read(), pointStructure::read(), Field< uint32x3 >::read(), triSurface::read(), internalPoints::read(), multiRotatingAxisMotion::read(), dictionary::read(), pFlow::readDataAsciiBinary(), dataEntry::readDataEntry(), dictionary::readDictionary(), IOfileHeader::readHeader(), List< std::any >::readList(), pointField< pFlow::VectorSingle, pFlow::AB3History >::readPointField(), sphere::sphere(), dataEntry::write(), baseShapeNames::write(), triSurface::write(), multiRotatingAxisMotion::write(), dictionary::write(), dataIO< T >::writeData(), and pFlow::writeDataAsciiBinary().
|
virtual |
|
virtual |
Check IOstream status for given operation.
Print IOstream state or generate a FatalIOError when an error has occurred. The base implementation is a fatalCheck
Definition at line 42 of file IOstream.cpp.
Referenced by pFlow::operator<<(), pFlow::operator>>(), line::read(), rotatingAxis::read(), pFlow::readDataAsciiBinary(), timeInterval::write(), iBox< intType >::write(), sphere::write(), box::write(), Logical::write(), line::write(), vibrating::write(), cylinder::write(), rotatingAxis::write(), multiTriSurface::write(), infinitePlane::write(), Field< uint32x3 >::write(), pFlow::writeDataASCII(), pFlow::writeDataAsciiBinary(), and List< std::any >::writeList().
bool fatalCheck | ( | const char * | operation | ) | const |
Check IOstream status for given operation.
Generate a FatalIOError when an error has occurred.
Definition at line 48 of file IOstream.cpp.
References fatalErrorInFunction, and fatalExit.
Referenced by iEntry< Key, T * >::createEntry(), pFlow::readDataAscii(), dataEntry::readDataEntry(), List< std::any >::readList(), IOfileHeader::writeHeader(), and iEntry< Key, T * >::writeKeyword().
|
inline |
Return true if stream has been opened.
Definition at line 168 of file IOstream.hpp.
References IOstream::openClosed_, and IOstream::OPENED.
|
inline |
Return true if stream is closed.
Definition at line 174 of file IOstream.hpp.
References IOstream::CLOSED, and IOstream::openClosed_.
|
inline |
Return true if stream format is binray.
Definition at line 180 of file IOstream.hpp.
References IOstream::BINARY, and IOstream::writeFormat_.
Referenced by pFlow::readDataAsciiBinary(), and pFlow::writeDataAsciiBinary().
|
inline |
Return true if next operation might succeed.
Definition at line 186 of file IOstream.hpp.
References IOstream::ioState_.
Referenced by Istream::nextValid(), and dictionary::readDictionary().
|
inline |
Return true if end of input seen.
Definition at line 192 of file IOstream.hpp.
References IOstream::ioState_.
Referenced by pFlow::checkNumberToken(), pFlow::checkWordToken(), iEntry< Key, T * >::createEntry(), stlFile::read(), dictionary::readDictionary(), iEntry< Key, T * >::readKeyword(), and twoPartEntry::twoPartEntry().
|
inline |
Return true if next operation will fail.
Definition at line 198 of file IOstream.hpp.
References IOstream::ioState_.
Referenced by IOstream::operator bool(), and IOstream::operator!().
|
inline |
Return true if stream is corrupted.
Definition at line 204 of file IOstream.hpp.
References IOstream::ioState_.
Referenced by pFlow::badInput(), iEntry< Key, T * >::createEntry(), Istream::nextValid(), iIstream::putBack(), dataEntry::readDataEntry(), and iEntry< Key, T * >::readKeyword().
|
inlineexplicit |
Return true if the stream has not failed.
Definition at line 210 of file IOstream.hpp.
References IOstream::fail().
|
inline |
Return true if the stream has failed.
Definition at line 216 of file IOstream.hpp.
References IOstream::fail().
|
inline |
Const access to the current stream line number.
Definition at line 223 of file IOstream.hpp.
References IOstream::lineNumber_.
Referenced by box::box(), iEntry< Key, T * >::createEntry(), cylinder::cylinder(), dataEntry::dataEntry(), dictionary::dictionary(), iBox< intType >::iBox(), pFlow::operator<<(), pFlow::operator>>(), iIstream::putBack(), timeInterval::read(), stlFile::read(), Logical::read(), line::read(), dataEntry::read(), rotatingAxis::read(), Field< uint32x3 >::read(), triSurface::read(), multiRotatingAxisMotion::read(), dictionary::read(), dataEntry::readDataEntry(), dictionary::readDictionary(), List< std::any >::readList(), sphere::sphere(), dataEntry::write(), triSurface::write(), multiRotatingAxisMotion::write(), and dictionary::write().
|
inline |
Non-const access to the current stream line number.
Definition at line 229 of file IOstream.hpp.
References IOstream::lineNumber_.
Set the stream line number return the previous value.
Definition at line 236 of file IOstream.hpp.
References IOstream::lineNumber_.
|
pure virtual |
Return flags of stream.
Implemented in oTstream, iTstream, Istream, and Ostream.
Referenced by IOstream::setf(), and IOstream::unsetf().
|
inlinestatic |
Return the default precision.
Definition at line 247 of file IOstream.hpp.
References IOstream::precision_.
|
inlinestatic |
Reset the default precision return the previous value.
Definition at line 254 of file IOstream.hpp.
References IOstream::precision_.
|
inline |
Set stream to have reached eof.
Definition at line 262 of file IOstream.hpp.
References IOstream::ioState_.
|
inline |
Set stream to have failed.
Definition at line 268 of file IOstream.hpp.
References IOstream::ioState_.
|
inline |
Set stream to be bad.
Definition at line 274 of file IOstream.hpp.
References IOstream::ioState_.
Referenced by IOstream::IOstream(), pFlow::operator>>(), and Logical::read().
|
pure virtual |
|
inline |
Set flags of stream.
Definition at line 283 of file IOstream.hpp.
References IOstream::flags().
Referenced by pFlow::dec(), pFlow::fixed(), pFlow::hex(), pFlow::oct(), and pFlow::scientific().
|
inline |
Set flags of given field of stream.
Definition at line 290 of file IOstream.hpp.
References IOstream::flags().
|
inline |
Unset flags of stream.
Definition at line 299 of file IOstream.hpp.
References IOstream::flags().
|
static |
Default precision, only works for ASCII.
Definition at line 66 of file IOstream.hpp.
Referenced by IOstream::defaultPrecision().
|
staticprotected |
Name for any generic stream - normally treat as readonly.
Definition at line 71 of file IOstream.hpp.
Referenced by IOstream::name().
|
protected |
Is stream open or closed.
Definition at line 74 of file IOstream.hpp.
Referenced by IOstream::closed(), IOstream::opened(), IOstream::setClosed(), and IOstream::setOpened().
|
protected |
write format
Definition at line 77 of file IOstream.hpp.
Referenced by IOstream::isBinary(), and IOstream::setWriteFormat().
|
protected |
state
Definition at line 80 of file IOstream.hpp.
Referenced by IOstream::bad(), IOstream::eof(), IOstream::fail(), IOstream::good(), IOstream::setBad(), IOstream::setEof(), IOstream::setFail(), IOstream::setGood(), and IOstream::setState().
|
protected |