OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

IOstream Class Reference

An IOstream is an abstract base class for all input/output systems; be they streams, files, token lists etc. More...

Inheritance diagram for IOstream:
Collaboration diagram for IOstream:

List of all members.


Classes

class  versionNumber
 Version number type. More...

Public Types

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

Public Member Functions

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

Static Public Member Functions

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

static const versionNumber originalVersion
 Original version number.
static const versionNumber currentVersion
 Current version number.
static unsigned int precision_
 Default precision.

Protected Member Functions

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

label lineNumber_

Friends

Ostreamoperator<< (Ostream &os, const streamFormat &sf)
 Ostream operator.

Detailed Description

An IOstream is an abstract base class for all input/output systems; be they 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 71 of file IOstream.H.


Member Enumeration Documentation

Enumeration for whether the stream open or closed.

Enumerator:
OPENED 
CLOSED 

Definition at line 79 of file IOstream.H.

Enumeration for the format of data in the stream.

Enumerator:
ASCII 
BINARY 

Definition at line 86 of file IOstream.H.

Enumeration for the format of data in the stream.

Enumerator:
UNCOMPRESSED 
COMPRESSED 

Definition at line 193 of file IOstream.H.


Constructor & Destructor Documentation

IOstream ( streamFormat  format,
versionNumber  version,
compressionType  compression = UNCOMPRESSED 
) [inline]

Construct setting format and version.

Definition at line 269 of file IOstream.H.

virtual ~IOstream (  )  [inline, virtual]

Definition at line 288 of file IOstream.H.


Member Function Documentation

void setOpened (  )  [inline, protected]

Set stream opened.

Definition at line 239 of file IOstream.H.

Referenced by ISstream::ISstream(), and OSstream::OSstream().

Here is the caller graph for this function:

void setClosed (  )  [inline, protected]

Set stream closed.

Definition at line 245 of file IOstream.H.

References IOstream::OPENED.

void setState ( ios::iostate  state  )  [inline, protected]

Set stream state.

Definition at line 251 of file IOstream.H.

References IOstream::CLOSED.

Referenced by ISstream::get(), OSstream::OSstream(), ISstream::putback(), ISstream::read(), and OSstream::write().

Here is the caller graph for this function:

void setGood (  )  [inline, protected]

Set stream to be good.

Definition at line 257 of file IOstream.H.

Referenced by ISstream::ISstream(), and OSstream::OSstream().

Here is the caller graph for this function:

virtual const fileName& name (  )  const [inline, virtual]

Return the name of the stream.

Useful for Fstream to return the filename

Reimplemented in primitiveEntry, IFstream, OFstream, ISstream, OSstream, and ITstream.

Definition at line 300 of file IOstream.H.

Referenced by IOobject::readHeader().

Here is the caller graph for this function:

virtual fileName& name (  )  [inline, virtual]

Return non-const access to the name of the stream.

Useful to alter the stream name

Reimplemented in primitiveEntry, IFstream, OFstream, ISstream, OSstream, and ITstream.

Definition at line 309 of file IOstream.H.

void fatalCheck ( const char *  operation  )  const

Check IOstream status for given operation.

print IOstream state if error has occured and exit

Definition at line 94 of file IOstream.C.

Referenced by dictionaryEntry::dictionaryEntry(), and PtrList< T >::read().

Here is the caller graph for this function:

bool opened (  )  const [inline]

Return true if stream has been opened.

Definition at line 330 of file IOstream.H.

bool closed (  )  const [inline]

Return true if stream is closed.

Definition at line 336 of file IOstream.H.

bool fail (  )  const [inline]

Return true if next operation will fail.

Definition at line 354 of file IOstream.H.

bool bad (  )  const [inline]

Return true if stream is corrupted.

Definition at line 360 of file IOstream.H.

Referenced by Istream::getBack(), dictionary::read(), IOdictionary::writeData(), featureEdgeMesh::writeData(), and refinementHistory::writeData().

Here is the caller graph for this function:

operator void * (  )  const [inline]

Return non-zero if the stream has not failed.

Definition at line 366 of file IOstream.H.

bool operator! (  )  const [inline]

Return true if the stream has failed.

Definition at line 374 of file IOstream.H.

Foam::IOstream::streamFormat formatEnum ( const word format  )  [static]

Return stream format of given format name.

Definition at line 33 of file IOstream.C.

Referenced by Time::readDict().

Here is the caller graph for this function:

streamFormat format ( const streamFormat  fmt  )  [inline]

Set the stream format.

Definition at line 392 of file IOstream.H.

streamFormat format ( const word fmt  )  [inline]

Set the stream format from word.

Definition at line 400 of file IOstream.H.

versionNumber version (  )  const [inline]

Return the stream version.

Definition at line 408 of file IOstream.H.

Referenced by IOobject::readHeader(), Foam::setcompression(), and IOobject::writeHeader().

Here is the caller graph for this function:

versionNumber version ( const versionNumber  ver  )  [inline]

Set the stream version.

Definition at line 414 of file IOstream.H.

Foam::IOstream::compressionType compressionEnum ( const word compression  )  [static]

Return compression of given compression name.

Definition at line 55 of file IOstream.C.

Referenced by Time::readDict().

Here is the caller graph for this function:

compressionType compression (  )  const [inline]

Return the stream compression.

Definition at line 425 of file IOstream.H.

Referenced by Foam::setw().

Here is the caller graph for this function:

compressionType compression ( const compressionType  cmp  )  [inline]

Set the stream compression.

Definition at line 431 of file IOstream.H.

compressionType compression ( const word cmp  )  [inline]

Set the stream compression from word.

Definition at line 439 of file IOstream.H.

label lineNumber (  )  const [inline]

Return current stream line number.

Definition at line 447 of file IOstream.H.

Referenced by Foam::parseNASCoord(), ITstream::print(), ITstream::read(), and IOobject::readHeader().

Here is the caller graph for this function:

label& lineNumber (  )  [inline]

Return current stream line number.

Definition at line 453 of file IOstream.H.

label lineNumber ( const label  ln  )  [inline]

Set the stream line number.

Definition at line 459 of file IOstream.H.

virtual ios ::fmtflags flags (  )  const [pure virtual]

Return flags of stream.

Implemented in IPstream, OPstream, ISstream, OSstream, and ITstream.

Referenced by IOstream::setf().

Here is the caller graph for this function:

static unsigned int defaultPrecision (  )  [inline, static]

Return the default precision.

Definition at line 470 of file IOstream.H.

Referenced by Time::readDict().

Here is the caller graph for this function:

static unsigned int defaultPrecision ( unsigned int  p  )  [inline, static]

Reset the default precision (and return old precision).

Definition at line 476 of file IOstream.H.

void setEof (  )  [inline]

Set stream to have reached eof.

Definition at line 484 of file IOstream.H.

void setFail (  )  [inline]

Set stream to have failed.

Definition at line 490 of file IOstream.H.

void setBad (  )  [inline]

Set stream to be bad.

Definition at line 496 of file IOstream.H.

Referenced by OPstream::write().

Here is the caller graph for this function:

virtual ios ::fmtflags flags ( const ios::fmtflags  f  )  [pure virtual]

Set flags of stream.

ios ::fmtflags setf ( const ios::fmtflags  f  )  [inline]

Set flags of stream.

Definition at line 505 of file IOstream.H.

Referenced by ensightFile::ensightFile(), Foam::operator<<(), and Foam::setformat().

Here is the caller graph for this function:

ios ::fmtflags setf ( const ios::fmtflags  f,
const ios::fmtflags  mask 
) [inline]

Set flags of given field of stream.

Definition at line 512 of file IOstream.H.

References IOstream::flags().

Here is the call graph for this function:

void unsetf ( const ios::fmtflags  uf  )  [inline]

Unset flags of stream.

Definition at line 521 of file IOstream.H.

void print ( Ostream os  )  const [virtual]

Print description of IOstream to Ostream.

Reimplemented in IFstream, OFstream, IPstream, OPstream, ISstream, OSstream, prefixOSstream, IStringStream, OStringStream, and ITstream.

Definition at line 117 of file IOstream.C.

void print ( Ostream os,
const int  streamState 
) const

Check given stream state bits.

Definition at line 168 of file IOstream.C.

InfoProxy<IOstream> info (  )  const [inline]

Return info proxy.

Used to print IOstream information to a stream

Reimplemented in primitiveEntry.

Definition at line 542 of file IOstream.H.

Referenced by IOobject::writeHeader().

Here is the caller graph for this function:


Friends And Related Function Documentation

Ostream& operator<< ( Ostream os,
const streamFormat sf 
) [friend]

Ostream operator.


Member Data Documentation

Original version number.

Definition at line 203 of file IOstream.H.

Current version number.

Definition at line 206 of file IOstream.H.

unsigned int precision_ [static]

Default precision.

Definition at line 209 of file IOstream.H.

Referenced by OSstream::OSstream().

label lineNumber_ [protected]

Definition at line 231 of file IOstream.H.

Referenced by ISstream::getLine(), ISstream::putback(), and OSstream::write().


The documentation for this class was generated from the following files:
Copyright © 2000-2009 OpenCFD Ltd