An IOstream is an abstract base class for all input/output systems; be they streams, files, token lists etc. More...
#include <OpenFOAM/IOstream.H>
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.
Definition at line 76 of file IOstream.H.
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 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.
| |
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 | |
Ostream & | operator<< (Ostream &os, const streamFormat &sf) |
Ostream operator.
|
enum streamAccess |
Enumeration for whether the stream open or closed.
Definition at line 84 of file IOstream.H.
enum streamFormat |
Enumeration for the format of data in the stream.
Definition at line 91 of file IOstream.H.
enum compressionType |
Enumeration for the format of data in the stream.
Definition at line 198 of file IOstream.H.
IOstream | ( | streamFormat | format, |
versionNumber | version, | ||
compressionType | compression = UNCOMPRESSED
|
||
) | [inline]
|
Construct setting format and version.
Definition at line 274 of file IOstream.H.
References IOstream::setBad().
virtual ~IOstream | ( | ) | [inline, virtual]
|
Definition at line 293 of file IOstream.H.
void setOpened | ( | ) | [inline, protected]
|
Set stream opened.
Definition at line 244 of file IOstream.H.
References IOstream::OPENED.
Referenced by ITstream::ITstream().
void setClosed | ( | ) | [inline, protected]
|
void setState | ( | ios::iostate | state ) | [inline, protected]
|
void setGood | ( | ) | [inline, protected]
|
Set stream to be good.
Definition at line 262 of file IOstream.H.
Referenced by ITstream::ITstream().
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 303 of file IOstream.H.
Referenced by hexRef8::checkMesh(), functionEntry::execute(), includeEntry::includeFileName(), Foam::operator>>(), IOobject::readHeader(), triSurface::triSurfInstance(), xmgrGraph::write(), gnuplotGraph::write(), STARCDsurfaceFormatCore::writeCase(), engineValve::writeDict(), and GeometricField< Type, PatchField, GeoMesh >::GeometricBoundaryField::writeEntry().
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 310 of file IOstream.H.
bool check | ( | const char * | operation ) | const [virtual]
|
Check IOstream status for given operation.
print IOstream state if error has occured
Definition at line 86 of file IOstream.C.
References Foam::exit(), Foam::FatalIOError, FatalIOErrorIn, and Foam::name().
Referenced by constTransport< thermo >::constTransport(), eConstThermo< equationOfState >::eConstThermo(), edgeMesh::edgeMesh(), fieldAverageItem::fieldAverageItem(), hConstThermo< equationOfState >::hConstThermo(), ignitionSite::ignitionSite(), incompressible::incompressible(), injector::injector(), janafThermo< equationOfState >::janafThermo(), kinematicParcelInjectionData::kinematicParcelInjectionData(), line< Point, PointRef >::line(), objectMap::objectMap(), Foam::operator<<(), Foam::operator>>(), Particle< ParticleType >::Particle(), perfectGas::perfectGas(), phaseProperties::phaseProperties(), polyBoundaryMesh::polyBoundaryMesh(), pyramid< Point, PointRef, polygonRef >::pyramid(), reactingMultiphaseParcelInjectionData::reactingMultiphaseParcelInjectionData(), reactingParcelInjectionData::reactingParcelInjectionData(), IOPosition< ParticleType >::readData(), ensightPart::reconstruct(), specie::specie(), speciesTransport::speciesTransport(), specieThermo< thermo >::specieThermo(), surfacePatchIOList::surfacePatchIOList(), surfZoneIOList::surfZoneIOList(), sutherlandTransport< thermo >::sutherlandTransport(), tetrahedron< Point, PointRef >::tetrahedron(), thermoParcelInjectionData::thermoParcelInjectionData(), triangle< Point, PointRef >::triangle(), Tuple< Type1, Type2 >::Tuple(), VectorSpace< Form, Cmpt, nCmpt >::VectorSpace(), triSurface::write(), OFSsurfaceFormat< Face >::write(), Particle< ParticleType >::write(), polyBoundaryMesh::writeData(), DimensionedField< Type, GeoMesh >::writeData(), ensightParts::writeData(), GeometricField< Type, PatchField, GeoMesh >::GeometricBoundaryField::writeEntry(), and ZoneMesh< ZoneType, MeshType >::ZoneMesh().
void fatalCheck | ( | const char * | operation ) | const |
Check IOstream status for given operation.
print IOstream state if error has occured and exit
Definition at line 101 of file IOstream.C.
References Foam::exit(), Foam::FatalIOError, FatalIOErrorIn, and Foam::name().
Referenced by dictionaryEntry::dictionaryEntry(), functionEntry::execute(), entry::New(), Foam::operator>>(), primitiveEntry::read(), and PtrList< T >::read().
bool opened | ( | ) | const [inline]
|
Return true if stream has been opened.
Definition at line 327 of file IOstream.H.
References IOstream::OPENED.
bool closed | ( | ) | const [inline]
|
Return true if stream is closed.
Definition at line 333 of file IOstream.H.
References IOstream::CLOSED.
bool good | ( | ) | const [inline]
|
Return true if next operation might succeed.
Definition at line 339 of file IOstream.H.
Referenced by argList::argList(), topoSetSource::checkIs(), AC3DsurfaceFormatCore::cueTo(), argList::displayDoc(), edgeMesh::edgeMesh(), error::error(), surfaceFormatsCore::getLineNoComment(), noiseFFT::noiseFFT(), IOobject::objectStream(), csvTableReader< Type >::operator()(), Foam::operator<<(), Foam::operator>>(), pressureGradientExplicitSource::pressureGradientExplicitSource(), STARCDsurfaceFormat< Face >::read(), OFSsurfaceFormat< Face >::read(), OFFsurfaceFormat< Face >::read(), OBJsurfaceFormat< Face >::read(), NASsurfaceFormat< Face >::read(), GTSsurfaceFormat< Face >::read(), FTRsurfaceFormat< Face >::read(), AC3DsurfaceFormat< Face >::read(), dictionary::read(), SKA::read(), STARCD::readBoundary(), Foam::readCmd(), AC3DsurfaceFormatCore::readCmd(), porousZones::readData(), TimeActivatedExplicitSourceList< Type >::readData(), STARCDsurfaceFormatCore::readHeader(), IOobject::readHeader(), STARCD::readHeader(), STARCDsurfaceFormatCore::readPoints(), Foam::readUpto(), scalarRanges::scalarRanges(), X3DsurfaceFormat< Face >::write(), WRLsurfaceFormat< Face >::write(), VTKsurfaceFormat< Face >::write(), TRIsurfaceFormat< Face >::write(), SMESHsurfaceFormat< Face >::write(), OFSsurfaceFormat< Face >::write(), OFFsurfaceFormat< Face >::write(), OBJsurfaceFormat< Face >::write(), GTSsurfaceFormat< Face >::write(), AC3DsurfaceFormat< Face >::write(), graph::write(), dictionary::write(), indexedOctree< Type >::write(), STLsurfaceFormat< Face >::writeAscii(), correlationFunction< Type >::writeAveraged(), surfacePatchIOList::writeData(), surfZoneIOList::writeData(), ZoneMesh< ZoneType, MeshType >::writeData(), polyBoundaryMesh::writeData(), cellModel::writeData(), UniformDimensionedField< Type >::writeData(), GeometricField< Type, PatchField, GeoMesh >::writeData(), DimensionedField< Type, GeoMesh >::writeData(), IOdictionary::writeData(), coordinateSystems::writeData(), IOPosition< ParticleType >::writeData(), AverageIOField< Type >::writeData(), porousZones::writeData(), TimeActivatedExplicitSourceList< Type >::writeData(), basicSourceList::writeData(), featureEdgeMesh::writeData(), polyTopoChanger::writeData(), refinementHistory::writeData(), fieldDictionary::writeData(), pairPotential::writeEnergyAndForceTables(), IOobject::writeHeader(), and regIOobject::writeObject().
bool eof | ( | ) | const [inline]
|
Return true if end of input seen.
Definition at line 345 of file IOstream.H.
Referenced by topoSetSource::checkIs(), Time::findTimes(), gaussGrad< Type >::gaussGrad(), Reaction< ReactionThermo >::New(), surfaceInterpolationScheme< Type >::New(), limitedSurfaceInterpolationScheme< Type >::New(), snGradScheme< Type >::New(), laplacianScheme< Type, GType >::New(), gradScheme< Type >::New(), divScheme< Type >::New(), ddtScheme< Type >::New(), d2dt2Scheme< Type >::New(), convectionScheme< Type >::New(), noiseFFT::noiseFFT(), dictionary::read(), and solution::upgradeSolverDict().
bool fail | ( | ) | const [inline]
|
Return true if next operation will fail.
Definition at line 351 of file IOstream.H.
Referenced by IOstream::operator void *(), and IOstream::operator!().
bool bad | ( | ) | const [inline]
|
Return true if stream is corrupted.
Definition at line 357 of file IOstream.H.
Referenced by Istream::getBack(), GTSsurfaceFormat< Face >::read(), primitiveEntry::read(), dictionary::read(), IOdictionary::readData(), featureEdgeMesh::readData(), and refinementHistory::readData().
operator void * | ( | ) | const [inline]
|
Return non-zero if the stream has not failed.
Definition at line 363 of file IOstream.H.
References IOstream::fail().
bool operator! | ( | ) | const [inline]
|
Return true if the stream has failed.
Definition at line 371 of file IOstream.H.
References IOstream::fail().
Foam::IOstream::streamFormat formatEnum | ( | const word & | format ) | [static]
|
Return stream format of given format name.
Definition at line 40 of file IOstream.C.
References IOstream::ASCII, IOstream::BINARY, Foam::endl(), and WarningIn.
Referenced by IOstream::format(), and Time::readDict().
streamFormat format | ( | ) | const [inline]
|
Return current stream format.
Definition at line 383 of file IOstream.H.
Referenced by fanFvPatchField< Type >::fanFvPatchField(), Foam::operator<<(), Foam::operator>>(), Particle< ParticleType >::Particle(), IOobject::readHeader(), Foam::setformat(), Particle< ParticleType >::write(), fanFvPatchField< Type >::write(), and IOobject::writeHeader().
streamFormat format | ( | const streamFormat | fmt ) | [inline]
|
Set the stream format.
Definition at line 389 of file IOstream.H.
streamFormat format | ( | const word & | fmt ) | [inline]
|
Set the stream format from word.
Definition at line 397 of file IOstream.H.
References IOstream::formatEnum().
versionNumber version | ( | ) | const [inline]
|
Return the stream version.
Definition at line 405 of file IOstream.H.
Referenced by Field< Type >::Field(), Foam::operator>>(), IOobject::readHeader(), Foam::setversion(), and IOobject::writeHeader().
versionNumber version | ( | const versionNumber | ver ) | [inline]
|
Set the stream version.
Definition at line 411 of file IOstream.H.
Foam::IOstream::compressionType compressionEnum | ( | const word & | compression ) | [static]
|
Return compression of given compression name.
Definition at line 62 of file IOstream.C.
References IOstream::COMPRESSED, Foam::endl(), IOstream::UNCOMPRESSED, and WarningIn.
Referenced by IOstream::compression(), and Time::readDict().
compressionType compression | ( | ) | const [inline]
|
Return the stream compression.
Definition at line 422 of file IOstream.H.
Referenced by Foam::setcompression().
compressionType compression | ( | const compressionType | cmp ) | [inline]
|
Set the stream compression.
Definition at line 428 of file IOstream.H.
compressionType compression | ( | const word & | cmp ) | [inline]
|
Set the stream compression from word.
Definition at line 436 of file IOstream.H.
References IOstream::compressionEnum().
label lineNumber | ( | ) | const [inline]
|
Return current stream line number.
Definition at line 444 of file IOstream.H.
References IOstream::lineNumber_.
Referenced by functionEntry::execute(), ITstream::print(), NASsurfaceFormat< Face >::read(), fvSchemes::read(), IOobject::readHeader(), and ITstream::rewind().
label& lineNumber | ( | ) | [inline]
|
Return current stream line number.
Definition at line 450 of file IOstream.H.
References IOstream::lineNumber_.
label lineNumber | ( | const label | ln ) | [inline]
|
Set the stream line number.
Definition at line 456 of file IOstream.H.
References IOstream::lineNumber_, and Foam::ln().
virtual ios ::fmtflags flags | ( | ) | const [pure virtual]
|
Return flags of stream.
Implemented in IPstream, OPstream, ISstream, OSstream, and ITstream.
Referenced by IOstream::setf(), and IOstream::unsetf().
static unsigned int defaultPrecision | ( | ) | [inline, static]
|
Return the default precision.
Definition at line 467 of file IOstream.H.
References IOstream::precision_.
Referenced by probes::checkFieldTypes(), and Time::readDict().
static unsigned int defaultPrecision | ( | unsigned int | p ) | [inline, static]
|
Reset the default precision (and return old precision)
Definition at line 473 of file IOstream.H.
References p, and IOstream::precision_.
void setEof | ( | ) | [inline]
|
Set stream to have reached eof.
Definition at line 481 of file IOstream.H.
void setFail | ( | ) | [inline]
|
Set stream to have failed.
Definition at line 487 of file IOstream.H.
void setBad | ( | ) | [inline]
|
Set stream to be bad.
Definition at line 493 of file IOstream.H.
Referenced by IOstream::IOstream(), and Foam::operator>>().
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 502 of file IOstream.H.
References IOstream::flags().
Referenced by Foam::dec(), Foam::fixed(), Foam::hex(), Foam::oct(), Foam::scientific(), Foam::setf(), STARCDsurfaceFormatCore::writePoints(), and STARCD::writeSurface().
ios ::fmtflags setf | ( | const ios::fmtflags | f, |
const ios::fmtflags | mask | ||
) | [inline]
|
Set flags of given field of stream.
Definition at line 509 of file IOstream.H.
References IOstream::flags().
void unsetf | ( | const ios::fmtflags | uf ) | [inline]
|
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 124 of file IOstream.C.
References Foam::endl().
Referenced by Foam::operator<<(), and OSstream::print().
void print | ( | Ostream & | os, |
const int | streamState | ||
) | const |
Return info proxy.
Used to print IOstream information to a stream
Reimplemented in primitiveEntry.
Definition at line 537 of file IOstream.H.
Referenced by Foam::operator>>(), and IOobject::writeHeader().
Ostream& operator<< | ( | Ostream & | os, |
const streamFormat & | sf | ||
) | [friend]
|
Ostream operator.
const IOstream::versionNumber originalVersion [static]
|
Original version number.
Definition at line 208 of file IOstream.H.
Referenced by Foam::operator>>().
const IOstream::versionNumber currentVersion [static]
|
Current version number.
Definition at line 211 of file IOstream.H.
Referenced by globalMeshData::write(), regIOobject::write(), and meshReader::writeMesh().
unsigned int precision_ [static]
|
Default precision.
Definition at line 214 of file IOstream.H.
Referenced by IOstream::defaultPrecision().
label lineNumber_ [protected]
|
Definition at line 236 of file IOstream.H.
Referenced by ISstream::get(), and IOstream::lineNumber().