An Istream is an abstract base class for all input systems (streams, files, token lists etc). The basic operations are construct, close, read token, read primitive and read binary block. More...
#include <OpenFOAM/Istream.H>
An Istream is an abstract base class for all input systems (streams, files, token lists etc). The basic operations are construct, close, read token, read primitive and read binary block.
In addition, version control and line number counting is incorporated. Usually one would use the read primitive member functions, but if one were reading a stream on unknown data sequence one can read token by token, and then analyse.
Public Member Functions | |
Istream (streamFormat format=ASCII, versionNumber version=currentVersion, compressionType compression=UNCOMPRESSED) | |
Set stream status. | |
virtual | ~Istream () |
void | putBack (const token &) |
Put back token. | |
bool | getBack (token &) |
Get the put back token. | |
virtual Istream & | read (token &)=0 |
Return next token from stream. | |
virtual Istream & | read (char &)=0 |
Read a character. | |
virtual Istream & | read (word &)=0 |
Read a word. | |
virtual Istream & | read (string &)=0 |
virtual Istream & | read (label &)=0 |
Read a label. | |
virtual Istream & | read (floatScalar &)=0 |
Read a floatScalar. | |
virtual Istream & | read (doubleScalar &)=0 |
Read a doubleScalar. | |
virtual Istream & | read (char *, std::streamsize)=0 |
Read binary block. | |
virtual Istream & | rewind ()=0 |
Rewind and return the stream so that it may be read again. | |
Istream & | readBegin (const char *funcName) |
Istream & | readEnd (const char *funcName) |
Istream & | readEndBegin (const char *funcName) |
char | readBeginList (const char *funcName) |
char | readEndList (const char *funcName) |
Istream & | operator() () const |
Return a non-const reference to const Istream. | |
![]() | |
IOstream (streamFormat format, versionNumber version, compressionType compression=UNCOMPRESSED) | |
Construct setting format and version. | |
virtual | ~IOstream () |
virtual const fileName & | name () const |
Return the name of the stream. | |
virtual fileName & | name () |
Return non-const access to the name of the stream. | |
virtual bool | check (const char *operation) const |
Check IOstream status for given operation. | |
void | fatalCheck (const char *operation) const |
Check IOstream status for given operation. | |
bool | opened () const |
Return true if stream has been opened. | |
bool | closed () const |
Return true if stream is closed. | |
bool | good () const |
Return true if next operation might succeed. | |
bool | eof () const |
Return true if end of input seen. | |
bool | fail () const |
Return true if next operation will fail. | |
bool | bad () const |
Return true if stream is corrupted. | |
operator void * () const | |
Return non-zero if the stream has not failed. | |
bool | operator! () const |
Return true if the stream has failed. | |
streamFormat | format () const |
Return current stream format. | |
streamFormat | format (const streamFormat fmt) |
Set the stream format. | |
streamFormat | format (const word &fmt) |
Set the stream format from word. | |
versionNumber | version () const |
Return the stream version. | |
versionNumber | version (const versionNumber ver) |
Set the stream version. | |
compressionType | compression () const |
Return the stream compression. | |
compressionType | compression (const compressionType cmp) |
Set the stream compression. | |
compressionType | compression (const word &cmp) |
Set the stream compression from word. | |
label | lineNumber () const |
Return current stream line number. | |
label & | lineNumber () |
Return current stream line number. | |
label | lineNumber (const label ln) |
Set the stream line number. | |
virtual ios::fmtflags | flags () const =0 |
Return flags of stream. | |
void | setEof () |
Set stream to have reached eof. | |
void | setFail () |
Set stream to have failed. | |
void | setBad () |
Set stream to be bad. | |
virtual ios::fmtflags | flags (const ios::fmtflags f)=0 |
Set flags of stream. | |
ios::fmtflags | setf (const ios::fmtflags f) |
Set flags of stream. | |
ios::fmtflags | setf (const ios::fmtflags f, const ios::fmtflags mask) |
Set flags of given field of stream. | |
void | unsetf (const ios::fmtflags uf) |
Unset flags of stream. | |
virtual void | print (Ostream &) const |
Print description of IOstream to Ostream. | |
void | print (Ostream &, const int streamState) const |
Check given stream state bits. | |
InfoProxy< IOstream > | info () const |
Return info proxy. |
Additional Inherited Members | |
![]() | |
enum | streamAccess { OPENED, CLOSED } |
Enumeration for whether the stream open or closed. More... | |
enum | streamFormat { ASCII, BINARY } |
Enumeration for the format of data in the stream. More... | |
enum | compressionType { UNCOMPRESSED, COMPRESSED } |
Enumeration for the format of data in the stream. More... | |
![]() | |
static streamFormat | formatEnum (const word &) |
Return stream format of given format name. | |
static compressionType | compressionEnum (const word &) |
Return compression of given compression name. | |
static unsigned int | defaultPrecision () |
Return the default precision. | |
static unsigned int | defaultPrecision (unsigned int p) |
Reset the default precision (and return old precision) | |
![]() | |
static const versionNumber | originalVersion |
Original version number. | |
static const versionNumber | currentVersion |
Current version number. | |
static unsigned int | precision_ |
Default precision. | |
![]() | |
void | setOpened () |
Set stream opened. | |
void | setClosed () |
Set stream closed. | |
void | setState (ios::iostate state) |
Set stream state. | |
void | setGood () |
Set stream to be good. | |
![]() | |
label | lineNumber_ |
|
inline |
void putBack | ( | const token & | t | ) |
Put back token.
Definition at line 56 of file Istream.C.
References Foam::exit(), Foam::FatalIOError, and FatalIOErrorIn.
Referenced by Field< Type >::Field(), genericFvPatchField< Type >::genericFvPatchField(), entry::New(), Foam::operator>>(), PtrList< T >::read(), dictionary::read(), IOPosition< ParticleType >::readData(), and Foam::readList().
bool getBack | ( | token & | t | ) |
Get the put back token.
Definition at line 34 of file Istream.C.
References IOstream::bad(), Foam::exit(), Foam::FatalIOError, and FatalIOErrorIn.
Referenced by ISstream::read(), IPstream::read(), and ITstream::read().
Return next token from stream.
Implemented in ITstream, IPstream, and ISstream.
Referenced by Foam::operator>>(), Particle< ParticleType >::Particle(), primitiveEntry::read(), Foam::readChar(), Foam::readLongLong(), and token::token().
|
pure virtual |
|
pure virtual |
|
pure virtual |
|
pure virtual |
|
pure virtual |
|
pure virtual |
Foam::Istream & readBegin | ( | const char * | funcName | ) |
Definition at line 80 of file Istream.C.
References token::BEGIN_LIST, Foam::exit(), Foam::FatalIOError, FatalIOErrorIn, and token::info().
Referenced by LangmuirHinshelwoodReactionRate::LangmuirHinshelwoodReactionRate(), line< Point, PointRef >::line(), objectMap::objectMap(), Foam::operator>>(), tetrahedron< Point, PointRef >::tetrahedron(), triangle< Point, PointRef >::triangle(), Tuple< Type1, Type2 >::Tuple(), and VectorSpace< Form, Cmpt, nCmpt >::VectorSpace().
Foam::Istream & readEnd | ( | const char * | funcName | ) |
Definition at line 97 of file Istream.C.
References token::END_LIST, Foam::exit(), Foam::FatalIOError, FatalIOErrorIn, and token::info().
Referenced by ArrheniusReactionRate::ArrheniusReactionRate(), ChemicallyActivatedReactionRate< ReactionRate, ChemicallyActivationFunction >::ChemicallyActivatedReactionRate(), FallOffReactionRate< ReactionRate, FallOffFunction >::FallOffReactionRate(), JanevReactionRate::JanevReactionRate(), LandauTellerReactionRate::LandauTellerReactionRate(), LangmuirHinshelwoodReactionRate::LangmuirHinshelwoodReactionRate(), line< Point, PointRef >::line(), objectMap::objectMap(), Foam::operator>>(), powerSeriesReactionRate::powerSeriesReactionRate(), SRIFallOffFunction::SRIFallOffFunction(), tetrahedron< Point, PointRef >::tetrahedron(), thirdBodyArrheniusReactionRate::thirdBodyArrheniusReactionRate(), triangle< Point, PointRef >::triangle(), TroeFallOffFunction::TroeFallOffFunction(), Tuple< Type1, Type2 >::Tuple(), and VectorSpace< Form, Cmpt, nCmpt >::VectorSpace().
Foam::Istream & readEndBegin | ( | const char * | funcName | ) |
char readBeginList | ( | const char * | funcName | ) |
Definition at line 123 of file Istream.C.
References token::BEGIN_BLOCK, token::BEGIN_LIST, Foam::exit(), Foam::FatalIOError, FatalIOErrorIn, token::info(), and token::pToken().
Referenced by Foam::operator>>(), PtrList< T >::read(), IOPosition< ParticleType >::readData(), and thirdBodyEfficiencies::thirdBodyEfficiencies().
char readEndList | ( | const char * | funcName | ) |
Definition at line 144 of file Istream.C.
References token::END_BLOCK, token::END_LIST, Foam::exit(), Foam::FatalIOError, FatalIOErrorIn, token::info(), and token::pToken().
Referenced by Foam::operator>>(), PtrList< T >::read(), and IOPosition< ParticleType >::readData().
Foam::Istream & operator() | ( | ) | const |
Return a non-const reference to const Istream.
Needed for read-constructors where the stream argument is temporary: e.g. thing thisThing(IFstream("thingFileName")());
Reimplemented in IFstream, and IStringStream.
Definition at line 165 of file Istream.C.
References IOerror::exit(), and Foam::FatalIOError.