www.cemf.ir
IOstream Class Referenceabstract

A base calss for input/output streams. More...

+ Inheritance diagram for IOstream:

Public Types

enum  streamAccess : char { CLOSED = 0, OPENED }
 
enum  writeFormat : char { ASCII = 0, BINARY }
 

Public Member Functions

 IOstream ()
 Default. More...
 
 IOstream (writeFormat wF)
 Construct and set write format. More...
 
 IOstream (const IOstream &)=default
 Copy. More...
 
virtual ~IOstream ()=default
 Destructor. More...
 
virtual const wordname () const
 Return the name of the stream. More...
 
virtual wordname ()
 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...
 
bool 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 isBinary () const
 Return true if stream format is binray. 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 bool () const
 Return true if the stream has not failed. More...
 
bool operator! () const
 Return true if the stream has failed. More...
 
int32 lineNumber () const
 Const access to the current stream line number. More...
 
int32lineNumber ()
 Non-const access to the current stream line number. More...
 
int32 lineNumber (const int32 num)
 Set the stream line number return the previous value. 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 f)
 Unset flags of stream. More...
 

Static Public Member Functions

static unsigned int defaultPrecision ()
 Return the default precision. More...
 
static unsigned int defaultPrecision (unsigned int prec)
 Reset the default precision return the previous value. More...
 

Static Public Attributes

static unsigned int precision_ = 6
 Default precision, only works for ASCII. 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 setWriteFormat (writeFormat wF)
 
void setGood ()
 Set stream to be good. More...
 

Protected Attributes

streamAccess openClosed_
 Is stream open or closed. More...
 
writeFormat writeFormat_ = ASCII
 write format More...
 
ios_base::iostate ioState_
 state More...
 
int32 lineNumber_
 The file line. More...
 

Static Protected Attributes

static word staticName_
 Name for any generic stream - normally treat as readonly. More...
 

Detailed Description

A base calss for input/output streams.

It is based on OpenFOAM stream, with some modifications/simplifications to be tailored to our needs

Definition at line 47 of file IOstream.hpp.

Member Enumeration Documentation

◆ streamAccess

enum streamAccess : char
Enumerator
CLOSED 
OPENED 

stream is not open

stream is open

Definition at line 53 of file IOstream.hpp.

◆ writeFormat

enum writeFormat : char
Enumerator
ASCII 
BINARY 

Definition at line 59 of file IOstream.hpp.

Constructor & Destructor Documentation

◆ IOstream() [1/3]

IOstream ( )
inlineexplicit

Default.

Definition at line 123 of file IOstream.hpp.

References IOstream::setBad().

+ Here is the call graph for this function:

◆ IOstream() [2/3]

IOstream ( writeFormat  wF)
inlineexplicit

Construct and set write format.

Definition at line 133 of file IOstream.hpp.

References IOstream::setBad().

+ Here is the call graph for this function:

◆ IOstream() [3/3]

IOstream ( const IOstream )
default

Copy.

◆ ~IOstream()

virtual ~IOstream ( )
virtualdefault

Destructor.

Member Function Documentation

◆ setOpened()

void setOpened ( )
inlineprotected

Set stream opened.

Definition at line 90 of file IOstream.hpp.

References IOstream::openClosed_, and IOstream::OPENED.

◆ setClosed()

void setClosed ( )
inlineprotected

Set stream closed.

Definition at line 96 of file IOstream.hpp.

References IOstream::CLOSED, and IOstream::openClosed_.

◆ setState()

void setState ( ios_base::iostate  state)
inlineprotected

Set stream state.

Definition at line 102 of file IOstream.hpp.

References IOstream::ioState_.

◆ setWriteFormat()

void setWriteFormat ( writeFormat  wF)
inlineprotected

Definition at line 107 of file IOstream.hpp.

References IOstream::writeFormat_.

◆ setGood()

void setGood ( )
inlineprotected

Set stream to be good.

Definition at line 113 of file IOstream.hpp.

References IOstream::ioState_.

◆ name() [1/2]

◆ name() [2/2]

virtual word& name ( )
virtual

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

Reimplemented in iTstream, Istream, and Ostream.

◆ check()

bool check ( const char *  operation) const
virtual

◆ fatalCheck()

bool fatalCheck ( const char *  operation) const

Check IOstream status for given operation.

Generate a FatalIOError when an error has occurred.

Definition at line 48 of file IOstream.cpp.

References fatalErrorInFunction, and fatalExit.

Referenced by iEntry< Key, T * >::createEntry(), pFlow::readDataAscii(), dataEntry::readDataEntry(), List< std::any >::readList(), IOfileHeader::writeHeader(), and iEntry< Key, T * >::writeKeyword().

+ Here is the caller graph for this function:

◆ opened()

bool opened ( ) const
inline

Return true if stream has been opened.

Definition at line 168 of file IOstream.hpp.

References IOstream::openClosed_, and IOstream::OPENED.

◆ closed()

bool closed ( ) const
inline

Return true if stream is closed.

Definition at line 174 of file IOstream.hpp.

References IOstream::CLOSED, and IOstream::openClosed_.

◆ isBinary()

bool isBinary ( ) const
inline

Return true if stream format is binray.

Definition at line 180 of file IOstream.hpp.

References IOstream::BINARY, and IOstream::writeFormat_.

Referenced by pFlow::readDataAsciiBinary(), and pFlow::writeDataAsciiBinary().

+ Here is the caller graph for this function:

◆ good()

bool good ( ) const
inline

Return true if next operation might succeed.

Definition at line 186 of file IOstream.hpp.

References IOstream::ioState_.

Referenced by Istream::nextValid(), and dictionary::readDictionary().

+ Here is the caller graph for this function:

◆ eof()

bool eof ( ) const
inline

Return true if end of input seen.

Definition at line 192 of file IOstream.hpp.

References IOstream::ioState_.

Referenced by pFlow::checkNumberToken(), pFlow::checkWordToken(), iEntry< Key, T * >::createEntry(), stlFile::read(), dictionary::readDictionary(), iEntry< Key, T * >::readKeyword(), and twoPartEntry::twoPartEntry().

+ Here is the caller graph for this function:

◆ fail()

bool fail ( ) const
inline

Return true if next operation will fail.

Definition at line 198 of file IOstream.hpp.

References IOstream::ioState_.

Referenced by IOstream::operator bool(), and IOstream::operator!().

+ Here is the caller graph for this function:

◆ bad()

bool bad ( ) const
inline

Return true if stream is corrupted.

Definition at line 204 of file IOstream.hpp.

References IOstream::ioState_.

Referenced by pFlow::badInput(), iEntry< Key, T * >::createEntry(), Istream::nextValid(), iIstream::putBack(), dataEntry::readDataEntry(), and iEntry< Key, T * >::readKeyword().

+ Here is the caller graph for this function:

◆ operator bool()

operator bool ( ) const
inlineexplicit

Return true if the stream has not failed.

Definition at line 210 of file IOstream.hpp.

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 216 of file IOstream.hpp.

References IOstream::fail().

+ Here is the call graph for this function:

◆ lineNumber() [1/3]

◆ lineNumber() [2/3]

int32& lineNumber ( )
inline

Non-const access to the current stream line number.

Definition at line 229 of file IOstream.hpp.

References IOstream::lineNumber_.

◆ lineNumber() [3/3]

int32 lineNumber ( const int32  num)
inline

Set the stream line number return the previous value.

Definition at line 236 of file IOstream.hpp.

References IOstream::lineNumber_.

◆ flags() [1/2]

virtual ios_base::fmtflags flags ( ) const
pure virtual

Return flags of stream.

Implemented in oTstream, iTstream, Istream, and Ostream.

Referenced by 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 247 of file IOstream.hpp.

References IOstream::precision_.

◆ defaultPrecision() [2/2]

static unsigned int defaultPrecision ( unsigned int  prec)
inlinestatic

Reset the default precision return the previous value.

Definition at line 254 of file IOstream.hpp.

References IOstream::precision_.

◆ setEof()

void setEof ( )
inline

Set stream to have reached eof.

Definition at line 262 of file IOstream.hpp.

References IOstream::ioState_.

◆ setFail()

void setFail ( )
inline

Set stream to have failed.

Definition at line 268 of file IOstream.hpp.

References IOstream::ioState_.

◆ setBad()

void setBad ( )
inline

Set stream to be bad.

Definition at line 274 of file IOstream.hpp.

References IOstream::ioState_.

Referenced by IOstream::IOstream(), pFlow::operator>>(), and Logical::read().

+ 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 oTstream, iTstream, Istream, and Ostream.

◆ setf() [1/2]

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

Set flags of stream.

Definition at line 283 of file IOstream.hpp.

References IOstream::flags().

Referenced by pFlow::dec(), pFlow::fixed(), pFlow::hex(), pFlow::oct(), and pFlow::scientific().

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

◆ 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 290 of file IOstream.hpp.

References IOstream::flags().

+ Here is the call graph for this function:

◆ unsetf()

void unsetf ( const ios_base::fmtflags  f)
inline

Unset flags of stream.

Definition at line 299 of file IOstream.hpp.

References IOstream::flags().

+ Here is the call graph for this function:

Member Data Documentation

◆ precision_

unsigned int precision_ = 6
static

Default precision, only works for ASCII.

Definition at line 66 of file IOstream.hpp.

Referenced by IOstream::defaultPrecision().

◆ staticName_

pFlow::word staticName_
staticprotected

Name for any generic stream - normally treat as readonly.

Definition at line 71 of file IOstream.hpp.

Referenced by IOstream::name().

◆ openClosed_

streamAccess openClosed_
protected

Is stream open or closed.

Definition at line 74 of file IOstream.hpp.

Referenced by IOstream::closed(), IOstream::opened(), IOstream::setClosed(), and IOstream::setOpened().

◆ writeFormat_

writeFormat writeFormat_ = ASCII
protected

write format

Definition at line 77 of file IOstream.hpp.

Referenced by IOstream::isBinary(), and IOstream::setWriteFormat().

◆ ioState_

◆ lineNumber_

int32 lineNumber_
protected

The file line.

Definition at line 84 of file IOstream.hpp.

Referenced by IOstream::lineNumber().


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