IOstream Class Referenceabstract

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:

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. More...
 
virtual ~IOstream ()
 Destructor. More...
 
virtual const fileNamename () const
 Return the name of the stream. More...
 
virtual fileNamename ()
 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...
 
void 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 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 void * () const
 Return non-zero if the stream has not failed. More...
 
bool operator! () const
 Return true if the stream has failed. More...
 
streamFormat format () const
 Return current stream format. More...
 
streamFormat format (const streamFormat fmt)
 Set the stream format. More...
 
streamFormat format (const word &fmt)
 Set the stream format from word. More...
 
versionNumber version () const
 Return the stream version. More...
 
versionNumber version (const versionNumber ver)
 Set the stream version. More...
 
compressionType compression () const
 Return the stream compression. More...
 
compressionType compression (const compressionType cmp)
 Set the stream compression. More...
 
compressionType compression (const word &cmp)
 Set the stream compression from word. More...
 
label lineNumber () const
 Return current stream line number. More...
 
labellineNumber ()
 Return current stream line number. More...
 
label lineNumber (const label ln)
 Set the stream line number. 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 uf)
 Unset flags of stream. More...
 
virtual void print (Ostream &) const
 Print description of IOstream to Ostream. More...
 
void print (Ostream &, const int streamState) const
 Check given stream state bits. More...
 
InfoProxy< IOstreaminfo () const
 Return info proxy. More...
 

Static Public Member Functions

static streamFormat formatEnum (const word &)
 Return stream format of given format name. More...
 
static compressionType compressionEnum (const word &)
 Return compression of given compression name. More...
 
static unsigned int defaultPrecision ()
 Return the default precision. More...
 
static unsigned int defaultPrecision (unsigned int p)
 Reset the default precision (and return old precision) More...
 

Static Public Attributes

static const versionNumber currentVersion
 Current version number. More...
 
static unsigned int precision_
 Default precision. 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 setGood ()
 Set stream to be good. More...
 

Protected Attributes

label lineNumber_
 

Friends

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

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

◆ streamAccess

Enumeration for whether the stream open or closed.

Enumerator
OPENED 
CLOSED 

Definition at line 79 of file IOstream.H.

◆ streamFormat

Enumeration for the format of data in the stream.

Enumerator
ASCII 
BINARY 

Definition at line 86 of file IOstream.H.

◆ compressionType

Enumeration for the format of data in the stream.

Enumerator
UNCOMPRESSED 
COMPRESSED 

Definition at line 193 of file IOstream.H.

Constructor & Destructor Documentation

◆ IOstream()

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

Construct setting format and version.

Definition at line 266 of file IOstream.H.

References IOstream::setBad().

Referenced by IOstream::setGood().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ~IOstream()

virtual ~IOstream ( )
inlinevirtual

Destructor.

Definition at line 284 of file IOstream.H.

References IOstream::check(), IOstream::fatalCheck(), and IOstream::name().

Here is the call graph for this function:

Member Function Documentation

◆ setOpened()

void setOpened ( )
inlineprotected

Set stream opened.

Definition at line 236 of file IOstream.H.

References IOstream::OPENED.

Referenced by IFstream::IFstream(), ITstream::ITstream(), OFstream::OFstream(), ITstream::operator=(), and UOPstream::UOPstream().

Here is the caller graph for this function:

◆ setClosed()

void setClosed ( )
inlineprotected

Set stream closed.

Definition at line 242 of file IOstream.H.

References IOstream::CLOSED.

Referenced by IFstream::IFstream(), and OFstream::OFstream().

Here is the caller graph for this function:

◆ setState()

void setState ( ios_base::iostate  state)
inlineprotected

Set stream state.

Definition at line 248 of file IOstream.H.

Referenced by ISstream::get(), ISstream::getLine(), IFstream::IFstream(), OFstream::OFstream(), ISstream::putback(), ISstream::read(), OSstream::write(), and OSstream::writeQuoted().

Here is the caller graph for this function:

◆ setGood()

void setGood ( )
inlineprotected

Set stream to be good.

Definition at line 254 of file IOstream.H.

References IOstream::IOstream().

Referenced by ITstream::ITstream(), ITstream::operator=(), ITstream::rewind(), and UOPstream::UOPstream().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ name() [1/2]

◆ name() [2/2]

virtual fileName& name ( )
inlinevirtual

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

Useful to alter the stream name

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

Definition at line 301 of file IOstream.H.

◆ check()

bool check ( const char *  operation) const
virtual

Check IOstream status for given operation.

print IOstream state if error has occurred

Definition at line 92 of file IOstream.C.

References IOstream::bad(), Foam::exit(), Foam::FatalIOError, FatalIOErrorInFunction, and IOstream::name().

Referenced by Foam::checkMethod(), CollidingParcel< ParcelType >::CollidingParcel(), CollisionRecordList< vector, vector >::CollisionRecordList(), Keyed< T >::createList(), DSMCParcel< ParcelType >::DSMCParcel(), fieldAverageItem::fieldAverageItem(), findCellParticle::findCellParticle(), ignitionSite::ignitionSite(), tetrahedron< Point, PointRef >::inside(), molecule::molecule(), MomentumParcel< ParcelType >::MomentumParcel(), momentumParcelInjectionData::momentumParcelInjectionData(), MPPICParcel< ParcelType >::MPPICParcel(), line< Point, PointRef >::nearestDist(), objectMap::objectMap(), Foam::operator!=(), WallSiteData< Type >::operator!=(), IFstream::operator()(), Istream::operator()(), Foam::RBD::operator<<(), Foam::operator<<(), Foam::operator>>(), Foam::RBD::operator>>(), PairCollisionRecord< Type >::PairCollisionRecord(), particle< Type >::particle(), phaseProperties::phaseProperties(), polyBoundaryMesh::polyBoundaryMesh(), pyramid< Point, PointRef, polygonRef >::pyramid(), ReactingMultiphaseParcel< ParcelType >::ReactingMultiphaseParcel(), reactingMultiphaseParcelInjectionData::reactingMultiphaseParcelInjectionData(), ReactingParcel< ParcelType >::ReactingParcel(), reactingParcelInjectionData::reactingParcelInjectionData(), dimensioned< vector >::read(), dimensionSet::read(), IOPosition< CloudType >::readData(), ensightPart::reconstruct(), PackedList< 2 >::setPair(), solidParticle::solidParticle(), LduMatrix< Type, DType, LUType >::source(), SprayParcel< ParcelType >::SprayParcel(), streamlinesParticle::streamlinesParticle(), surfacePatchIOList::surfacePatchIOList(), surfZoneIOList::surfZoneIOList(), ThermoParcel< ParcelType >::ThermoParcel(), thermoParcelInjectionData::thermoParcelInjectionData(), trackedParticle::trackedParticle(), VectorSpace< Vector< vector >, vector, 3 >::VectorSpace(), WallCollisionRecord< Type >::WallCollisionRecord(), wordAndDictionary::wordAndDictionary(), dictionaryListEntry::write(), edgeMeshFormat::write(), SHA1Digest::write(), OFSsurfaceFormat< Face >::write(), dimensionSet::write(), triSurface::write(), ensightParts::writeData(), polyBoundaryMesh::writeData(), DimensionedField< Type, Foam::pointMesh >::writeData(), GeometricField< Type, PatchField, GeoMesh >::Boundary::writeEntry(), Foam::writeEntry(), Cloud< passiveParticle >::writeObject(), particle< Type >::writePosition(), and IOstream::~IOstream().

Here is the call graph for this function:

◆ fatalCheck()

◆ opened()

bool opened ( ) const
inline

Return true if stream has been opened.

Definition at line 318 of file IOstream.H.

References IOstream::OPENED.

Referenced by IOstream::print().

Here is the caller graph for this function:

◆ closed()

bool closed ( ) const
inline

Return true if stream is closed.

Definition at line 324 of file IOstream.H.

References IOstream::CLOSED.

Referenced by IOstream::print().

Here is the caller graph for this function:

◆ good()

bool good ( ) const
inline

Return true if next operation might succeed.

Definition at line 330 of file IOstream.H.

Referenced by collatedFileOperation::appendObject(), topoSetSource::checkIs(), Foam::debug::controlDict(), dynamicCode::copyAndFilter(), dynamicCode::copyOrCreateFiles(), AC3DsurfaceFormatCore::cueTo(), error::error(), edgeMeshFormatsCore::getLineNoComment(), surfaceFormatsCore::getLineNoComment(), IFstream::IFstream(), dictionary::includedDictionary::includedDictionary(), meanVelocityForce::meanVelocityForce(), noiseFFT::noiseFFT(), decomposedBlockData::numBlocks(), OFstream::OFstream(), error::operator()(), IFstream::operator()(), Istream::operator()(), Foam::operator>>(), argList::parse(), Foam::parseNASCoord(), IOstream::print(), TableFileReader< Type >::read(), extendedEdgeMeshFormat::read(), NASedgeFormat::read(), extendedFeatureEdgeMeshFormat::read(), OBJsurfaceFormat< Face >::read(), GTSsurfaceFormat< Face >::read(), NASsurfaceFormat< Face >::read(), OFFsurfaceFormat< Face >::read(), AC3DsurfaceFormat< Face >::read(), edgeMeshFormat::read(), OBJedgeFormat::read(), VTKedgeFormat::read(), VTKsurfaceFormat< Face >::read(), STARCDsurfaceFormat< Face >::read(), OFSsurfaceFormat< Face >::read(), STARCDedgeFormat::read(), dictionary::read(), masterUncollatedFileOperation::readAndSend(), decomposedBlockData::readBlocks(), STARCD::readBoundary(), Foam::readCmd(), AC3DsurfaceFormatCore::readCmd(), GlobalIOField< Foam::Vector >::readData(), GlobalIOList< thermoParcelInjectionData >::readData(), externalCoupledMixedFvPatchField< scalar >::readData(), STARCDCore::readHeader(), STARCD::readHeader(), IOobject::readHeader(), masterUncollatedFileOperation::readHeader(), STARCDsurfaceFormatCore::readInpCellTable(), STARCDCore::readPoints(), Foam::readUpto(), scalarRanges::scalarRanges(), specieCoeffs::setLRhs(), triSurface::triSurfInstance(), memInfo::update(), vtkUnstructuredReader::vtkUnstructuredReader(), X3DsurfaceFormat< Face >::write(), WRLsurfaceFormat< Face >::write(), SMESHsurfaceFormat< Face >::write(), GTSsurfaceFormat< Face >::write(), OBJsurfaceFormat< Face >::write(), AC3DsurfaceFormat< Face >::write(), VTKsurfaceFormat< Face >::write(), OFFsurfaceFormat< Face >::write(), OBJedgeFormat::write(), VTKedgeFormat::write(), TRIsurfaceFormat< Face >::write(), edgeMeshFormat::write(), OFSsurfaceFormat< Face >::write(), graph::write(), dynamicIndexedOctree< Foam::dynamicTreeDataPoint >::write(), dictionary::write(), indexedOctree< Foam::treeDataFace >::write(), STLsurfaceFormat< Face >::writeAscii(), correlationFunction< Type >::writeAveraged(), decomposedBlockData::writeBlocks(), fieldDictionary::writeData(), AverageField< Type >::writeData(), featureEdgeMesh::writeData(), surfacePatchIOList::writeData(), surfZoneIOList::writeData(), IOPosition< CloudType >::writeData(), constant::writeData(), porosityModelList::writeData(), UniformDimensionedField< vector >::writeData(), IOdictionary::writeData(), decomposedBlockData::writeData(), temperatureDependent::writeData(), extendedFeatureEdgeMesh::writeData(), polyTopoChanger::writeData(), surfaceTensionModel::writeData(), cellModel::writeData(), fvConstraints::writeData(), AveragingMethod< Foam::Vector >::writeData(), MeshZones< cellZone, polyMesh >::writeData(), MRFZoneList::writeData(), polyBoundaryMesh::writeData(), fvModels::writeData(), DimensionedField< Type, Foam::pointMesh >::writeData(), refinementHistory::writeData(), GeometricField< vector, pointPatchField, pointMesh >::writeData(), pairPotential::writeEnergyAndForceTables(), IOobject::writeHeader(), collatedFileOperation::writeObject(), fileOperation::writeObject(), masterUncollatedFileOperation::writeObject(), jobInfo::~jobInfo(), and TRIsurfaceFormatCore::~TRIsurfaceFormatCore().

◆ eof()

◆ fail()

bool fail ( ) const
inline

Return true if next operation will fail.

Definition at line 342 of file IOstream.H.

Referenced by IOstream::operator void *(), IOstream::operator!(), and IOstream::print().

Here is the caller graph for this function:

◆ bad()

◆ operator void *()

operator void * ( ) const
inline

Return non-zero if the stream has not failed.

Definition at line 354 of file IOstream.H.

References IOstream::fail().

Here is the call graph for this function:

◆ operator!()

bool operator! ( ) const
inline

Return true if the stream has failed.

Definition at line 362 of file IOstream.H.

References IOstream::fail(), and IOstream::formatEnum().

Here is the call graph for this function:

◆ formatEnum()

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

Return stream format of given format name.

Definition at line 39 of file IOstream.C.

References IOstream::ASCII, IOstream::BINARY, Foam::endl(), and WarningInFunction.

Referenced by IOstream::format(), surfaceWriter::New(), IOstream::operator!(), Time::readDict(), surfaceWriter::surfaceWriter(), and decomposedBlockData::writeData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ format() [1/3]

◆ format() [2/3]

streamFormat format ( const streamFormat  fmt)
inline

Set the stream format.

Definition at line 380 of file IOstream.H.

◆ format() [3/3]

streamFormat format ( const word fmt)
inline

Set the stream format from word.

Definition at line 388 of file IOstream.H.

References IOstream::formatEnum().

Here is the call graph for this function:

◆ version() [1/2]

◆ version() [2/2]

versionNumber version ( const versionNumber  ver)
inline

Set the stream version.

Definition at line 402 of file IOstream.H.

References IOstream::compressionEnum().

Here is the call graph for this function:

◆ compressionEnum()

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

Return compression of given compression name.

Definition at line 61 of file IOstream.C.

References IOstream::COMPRESSED, Foam::endl(), IOstream::UNCOMPRESSED, Switch::valid(), and WarningInFunction.

Referenced by IOstream::compression(), rawSurfaceWriter::rawSurfaceWriter(), Time::readDict(), and IOstream::version().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compression() [1/3]

compressionType compression ( ) const
inline

Return the stream compression.

Definition at line 413 of file IOstream.H.

Referenced by Foam::setcompression().

Here is the caller graph for this function:

◆ compression() [2/3]

compressionType compression ( const compressionType  cmp)
inline

Set the stream compression.

Definition at line 419 of file IOstream.H.

◆ compression() [3/3]

compressionType compression ( const word cmp)
inline

Set the stream compression from word.

Definition at line 427 of file IOstream.H.

References IOstream::compressionEnum().

Here is the call graph for this function:

◆ lineNumber() [1/3]

◆ lineNumber() [2/3]

label& lineNumber ( )
inline

Return current stream line number.

Definition at line 441 of file IOstream.H.

References IOstream::lineNumber_.

◆ lineNumber() [3/3]

label lineNumber ( const label  ln)
inline

Set the stream line number.

Definition at line 447 of file IOstream.H.

References IOstream::flags(), IOstream::lineNumber_, and Foam::ln().

Here is the call graph for this function:

◆ flags() [1/2]

virtual ios_base::fmtflags flags ( ) const
pure virtual

Return flags of stream.

Implemented in ITstream, dummyIstream, dummyISstream, ISstream, UIPstream, UOPstream, and OSstream.

Referenced by IOstream::lineNumber(), IOstream::setBad(), IOstream::setf(), and IOstream::unsetf().

Here is the caller graph for this function:

◆ defaultPrecision() [1/2]

static unsigned int defaultPrecision ( )
inlinestatic

Return the default precision.

Definition at line 458 of file IOstream.H.

References IOstream::precision_.

Referenced by writeFile::charWidth(), isNotEqOp< T >::operator()(), probes::prepare(), Time::readDict(), and writeFile::valueWidth().

Here is the caller graph for this function:

◆ defaultPrecision() [2/2]

static unsigned int defaultPrecision ( unsigned int  p)
inlinestatic

Reset the default precision (and return old precision)

Definition at line 464 of file IOstream.H.

References p, and IOstream::precision_.

◆ setEof()

void setEof ( )
inline

Set stream to have reached eof.

Definition at line 472 of file IOstream.H.

Referenced by ITstream::read().

Here is the caller graph for this function:

◆ setFail()

void setFail ( )
inline

Set stream to have failed.

Definition at line 478 of file IOstream.H.

◆ setBad()

void setBad ( )
inline

Set stream to be bad.

Definition at line 484 of file IOstream.H.

References f(), and IOstream::flags().

Referenced by IFstream::IFstream(), IOstream::IOstream(), OFstream::OFstream(), Foam::operator>>(), ISstream::putback(), UIPstream::read(), ITstream::read(), Istream::readBegin(), Istream::readBeginList(), Istream::readEnd(), and Istream::readEndList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ flags() [2/2]

virtual ios_base::fmtflags flags ( const ios_base::fmtflags  f)
pure virtual

Set flags of stream.

Implemented in UOPstream, ITstream, ISstream, UIPstream, dummyIstream, dummyISstream, and OSstream.

◆ setf() [1/2]

ios_base::fmtflags setf ( const ios_base::fmtflags  f)
inline

◆ setf() [2/2]

ios_base::fmtflags setf ( const ios_base::fmtflags  f,
const ios_base::fmtflags  mask 
)
inline

Set flags of given field of stream.

Definition at line 500 of file IOstream.H.

References IOstream::flags().

Here is the call graph for this function:

◆ unsetf()

void unsetf ( const ios_base::fmtflags  uf)
inline

Unset flags of stream.

Definition at line 509 of file IOstream.H.

References IOstream::flags(), IOstream::info(), IOstream::versionNumber::operator<<, IOstream::print(), and sf().

Referenced by NamedEnum< compressibleField, 8 >::names().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print() [1/2]

void print ( Ostream os) const
virtual

◆ print() [2/2]

void print ( Ostream os,
const int  streamState 
) const

Check given stream state bits.

Definition at line 177 of file IOstream.C.

References Foam::endl().

Here is the call graph for this function:

◆ info()

InfoProxy<IOstream> info ( ) const
inline

Return info proxy.

Used to print IOstream information to a stream

Definition at line 528 of file IOstream.H.

Referenced by IFstream::IFstream(), OFstream::OFstream(), dimensionSet::read(), IOstream::unsetf(), and IOobject::writeHeader().

Here is the caller graph for this function:

Friends And Related Function Documentation

◆ operator<<

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

Ostream operator.

Member Data Documentation

◆ currentVersion

◆ precision_

unsigned int precision_
static

Default precision.

Definition at line 206 of file IOstream.H.

Referenced by IOstream::defaultPrecision().

◆ lineNumber_


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