FreeFOAM The Cross-Platform CFD Toolkit
Istream Class Reference

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>


Detailed Description

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.

Source files

Definition at line 58 of file Istream.H.

+ Inheritance diagram for Istream:
+ Collaboration diagram for Istream:

List of all members.

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 Istreamread (token &)=0
 Return next token from stream.
virtual Istreamread (char &)=0
 Read a character.
virtual Istreamread (word &)=0
 Read a word.
virtual Istreamread (string &)=0
virtual Istreamread (label &)=0
 Read a label.
virtual Istreamread (floatScalar &)=0
 Read a floatScalar.
virtual Istreamread (doubleScalar &)=0
 Read a doubleScalar.
virtual Istreamread (char *, std::streamsize)=0
 Read binary block.
virtual Istreamrewind ()=0
 Rewind and return the stream so that it may be read again.
IstreamreadBegin (const char *funcName)
IstreamreadEnd (const char *funcName)
IstreamreadEndBegin (const char *funcName)
char readBeginList (const char *funcName)
char readEndList (const char *funcName)
Istreamoperator() () const
 Return a non-const reference to const Istream.
- Public Member Functions inherited from IOstream
 IOstream (streamFormat format, versionNumber version, compressionType compression=UNCOMPRESSED)
 Construct setting format and version.
virtual ~IOstream ()
virtual const fileNamename () const
 Return the name of the stream.
virtual fileNamename ()
 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< IOstreaminfo () const
 Return info proxy.

Additional Inherited Members

- Public Types inherited from IOstream
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 Public Member Functions inherited from IOstream
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 Public Attributes inherited from IOstream
static const versionNumber originalVersion
 Original version number.
static const versionNumber currentVersion
 Current version number.
static unsigned int precision_
 Default precision.
- Protected Member Functions inherited from IOstream
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.
- Protected Attributes inherited from IOstream
label lineNumber_

Constructor & Destructor Documentation

Istream ( streamFormat  format = ASCII,
versionNumber  version = currentVersion,
compressionType  compression = UNCOMPRESSED 
)
inline

Set stream status.

Definition at line 77 of file Istream.H.

virtual ~Istream ( )
inlinevirtual

Definition at line 90 of file Istream.H.


Member Function Documentation

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().

virtual Istream& read ( token )
pure virtual
virtual Istream& read ( char &  )
pure virtual

Read a character.

Implemented in ITstream, IPstream, and ISstream.

virtual Istream& read ( word )
pure virtual

Read a word.

Implemented in ITstream, IPstream, and ISstream.

virtual Istream& read ( string )
pure virtual

Implemented in ITstream, IPstream, and ISstream.

virtual Istream& read ( label &  )
pure virtual

Read a label.

Implemented in ITstream, IPstream, and ISstream.

virtual Istream& read ( floatScalar )
pure virtual

Read a floatScalar.

Implemented in ITstream, IPstream, and ISstream.

virtual Istream& read ( doubleScalar )
pure virtual

Read a doubleScalar.

Implemented in ITstream, IPstream, and ISstream.

virtual Istream& read ( char *  ,
std::streamsize   
)
pure virtual

Read binary block.

Implemented in ITstream, IPstream, and ISstream.

virtual Istream& rewind ( )
pure virtual

Rewind and return the stream so that it may be read again.

Implemented in ITstream, IPstream, and ISstream.

Foam::Istream & readEndBegin ( const char *  funcName)

Definition at line 114 of file Istream.C.

char readEndList ( const char *  funcName)
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.


The documentation for this class was generated from the following files: