www.cemf.ir
Istream Class Reference

Standard input stream for binary and ascii data. More...

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

Public Member Functions

 Istream (std::istream &is, const word &streamName, writeFormat wf=ASCII)
 Construct wrapper around std::istream, set stream status. More...
 
virtual ~Istream ()=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 ios_base::fmtflags flags () const
 Return flags of output stream. More...
 
Istreamget (char &c)
 Raw, low-level get character function. More...
 
int peek ()
 Raw, low-level peek function. More...
 
IstreamgetLine (word &str, char delim='\n')
 Raw, low-level getline (until delimiter) into a string. More...
 
std::streamsize getLine (std::nullptr_t, char delim='\n')
 Low-level discard until delimiter return the number of characters extracted. More...
 
Istreamputback (const char c)
 Raw, low-level putback character function. More...
 
virtual iIstreamread (token &t) override
 Return next token from stream. More...
 
virtual iIstreamread (char &c) override
 Read a character. More...
 
virtual iIstreamread (word &str) override
 Read a word. More...
 
virtual iIstreamreadString (word &str) override
 Read a string. More...
 
virtual iIstreamread (int64 &) override
 Read a int64. More...
 
virtual iIstreamread (int32 &) override
 Read a int32. More...
 
virtual iIstreamread (int8 &) override
 Read a int8. More...
 
virtual iIstreamread (uint64 &) override
 Read a uint64. More...
 
virtual iIstreamread (uint32 &) override
 Read a uint32. More...
 
virtual iIstreamread (uint8 &) override
 Read a uint8. More...
 
virtual iIstreamread (float &val) override
 Read a float. More...
 
virtual iIstreamread (double &val) override
 Read a double. More...
 
iIstreamread (char *buffer, std::streamsize count) override
 Write a block of binray data. More...
 
size_t findBinaryBlockStart () override
 It seek for a character sequence that indicates the start of a binary block char sequence is 255 255 255 0
More...
 
void rewind () override
 Rewind the stream so that it may be read again. More...
 
void seek (size_t pos) override
 
size_t tell () override
 Return current position indicator. More...
 
virtual ios_base::fmtflags flags (const ios_base::fmtflags flags)
 Set stream flags. More...
 
virtual std::istream & stdStream ()
 Access to underlying std::istream. More...
 
virtual const std::istream & stdStream () const
 Const access to underlying std::istream. More...
 
- Public Member Functions inherited from iIstream
 iIstream ()
 default More...
 
 iIstream (writeFormat wf)
 
 iIstream (const iIstream &)=default
 Copy construct. More...
 
virtual ~iIstream ()=default
 Destructor. More...
 
void putBack (const token &tok)
 Put back token Only a single put back is permitted. More...
 
bool getBack (token &tok)
 Get the put back token if there is one and return true. More...
 
bool peekBack (token &tok)
 Peek at the put back token without removing it. More...
 
void resetPutBack ()
 reset the put back token; More...
 
virtual bool findToken (const word &w)
 search for all tokesn and find the first word token tbat matchs w More...
 
virtual bool findTokenResume (const word &w)
 search for all tokesn after the current file position and find the first word token tbat matchs w More...
 
virtual bool findTokenSilent (const word &w, int32 limitLine=100)
 search for all tokesn and find the first word token that matchs More...
 
virtual bool findTokenResumeSilent (const word &w, int32 limitLine=100)
 search for all tokesn after the current file position and find the first word token tbat matchs w More...
 
virtual bool findTokenAndNext (const word &w, word &nextW, bool checkEndStatement=true)
 search for all tokens and find the first word token and also next word token chekck if it is eneded with end statement ; More...
 
virtual bool findTokenAndNextSilent (const word &w, word &nextW, int32 limitLine=100)
 
template<typename T >
bool findKeywordAndVal (const word &keyword, T &val, bool checkEndStatement=true)
 find a pair of keyword and data terminated by ; keyword data; return false if keyword does not exist or reading fails. More...
 
template<typename T >
lookupData (const word &keyword)
 lookup for keyword and data; fatalExit if fails More...
 
template<typename T >
lookupDataOrSet (const word &keyword, const T &setVal)
 lookup for keyword and data; set to setVal if lookup fails. More...
 
template<typename T >
bool nextData (const word &keyword, T &data)
 read the data next to keword keyword data; check the keyword is correct or not
More...
 
bool readBegin (const char *funcName)
 Begin read of data chunk, starts with '('. More...
 
bool readEnd (const char *funcName)
 End read of data chunk, ends with ')' return true or FatalIOError. More...
 
bool readBeginSquare (const char *funcName)
 Begin read of data chunk, starts with '('. More...
 
bool readEndSquare (const char *funcName)
 Begin read of data chunk, starts with '('. More...
 
char readBeginList (const char *funcName)
 Begin read of list data, starts with '(' or '{' return starting delimiter or FatalIOError. More...
 
char readEndList (const char *funcName)
 End read of list data, ends with ')' or '}' return closing delimiter or FatalIOError. More...
 
char readEndStatement (const char *funcName)
 End statement character ;. More...
 
iIstreamoperator() () const
 
- Public Member Functions inherited from IOstream
 IOstream ()
 Default. More...
 
 IOstream (writeFormat wF)
 Construct and set write format. More...
 
 IOstream (const IOstream &)=default
 Copy. More...
 
virtual ~IOstream ()=default
 Destructor. 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...
 
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...
 
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...
 

Private Member Functions

char nextValid ()
 Get the next valid character. More...
 
void readWordToken (token &t)
 Read a word token. More...
 
IstreamreadVariable (word &str)
 Read a variable name starting with '$'. More...
 
void operator= (const Istream &)=delete
 No copy assignment. More...
 

Private Attributes

word name_
 Stream name. More...
 
std::istream & is_
 Input stream. More...
 

Additional Inherited Members

- Public Types inherited from IOstream
enum  streamAccess : char { CLOSED = 0, OPENED }
 
enum  writeFormat : char { ASCII = 0, BINARY }
 
- Static Public Member Functions inherited from IOstream
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 inherited from IOstream
static unsigned int precision_ = 6
 Default precision, only works for ASCII. More...
 
- Protected Member Functions inherited from IOstream
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 inherited from IOstream
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 inherited from IOstream
static word staticName_
 Name for any generic stream - normally treat as readonly. More...
 

Detailed Description

Standard input stream for binary and ascii data.

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

Definition at line 39 of file Istream.hpp.

Constructor & Destructor Documentation

◆ Istream()

Istream ( std::istream &  is,
const word streamName,
writeFormat  wf = ASCII 
)

Construct wrapper around std::istream, set stream status.

Definition at line 304 of file Istream.cpp.

◆ ~Istream()

virtual ~Istream ( )
virtualdefault

Destructor.

Member Function Documentation

◆ nextValid()

char nextValid ( )
private

Get the next valid character.

Definition at line 49 of file Istream.cpp.

References IOstream::bad(), Istream::get(), IOstream::good(), and Istream::putback().

+ Here is the call graph for this function:

◆ readWordToken()

void readWordToken ( token t)
private

Read a word token.

Definition at line 127 of file Istream.cpp.

References token::setBad().

+ Here is the call graph for this function:

◆ readVariable()

pFlow::Istream & readVariable ( word str)
private

Read a variable name starting with '$'.

Definition at line 141 of file Istream.cpp.

References token::BEGIN_BLOCK, token::BEGIN_LIST, token::DOLLAR, token::END_BLOCK, token::END_LIST, pFlow::endl(), errLen, fatalExit, ioErrorInFile, pFlow::nl, and warningInFunction.

+ Here is the call graph for this function:

◆ operator=()

void operator= ( const Istream )
privatedelete

No copy assignment.

◆ name() [1/2]

virtual const word& name ( ) const
inlinevirtual

Return the name of the stream.

Reimplemented from IOstream.

Definition at line 81 of file Istream.hpp.

References Istream::name_.

Referenced by dictionary::dictionary(), and stlFile::read().

+ Here is the caller graph for this function:

◆ name() [2/2]

virtual word& name ( )
inlinevirtual

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

Reimplemented from IOstream.

Definition at line 87 of file Istream.hpp.

References Istream::name_.

◆ flags() [1/2]

std::ios_base::fmtflags flags ( ) const
virtual

Return flags of output stream.

Implements IOstream.

Definition at line 927 of file Istream.cpp.

◆ get()

pFlow::Istream & get ( char &  c)

Raw, low-level get character function.

Definition at line 325 of file Istream.cpp.

References Istream::get().

Referenced by Istream::get(), and Istream::nextValid().

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

◆ peek()

int peek ( )

Raw, low-level peek function.

Does not remove the character from the stream. Returns the next character in the stream or EOF if the end of file is read.

Definition at line 339 of file Istream.cpp.

◆ getLine() [1/2]

pFlow::Istream & getLine ( word str,
char  delim = '\n' 
)

Raw, low-level getline (until delimiter) into a string.

Definition at line 345 of file Istream.cpp.

◆ getLine() [2/2]

std::streamsize getLine ( std::nullptr_t  ,
char  delim = '\n' 
)

Low-level discard until delimiter return the number of characters extracted.

Definition at line 359 of file Istream.cpp.

References pFlow::count(), and pFlow::algorithms::KOKKOS::max().

+ Here is the call graph for this function:

◆ putback()

pFlow::Istream & putback ( const char  c)

Raw, low-level putback character function.

Definition at line 375 of file Istream.cpp.

Referenced by Istream::nextValid().

+ Here is the caller graph for this function:

◆ read() [1/12]

◆ read() [2/12]

pFlow::iIstream & read ( char &  c)
overridevirtual

Read a character.

Implements iIstream.

Definition at line 591 of file Istream.cpp.

◆ read() [3/12]

pFlow::iIstream & read ( word str)
overridevirtual

Read a word.

Implements iIstream.

Definition at line 598 of file Istream.cpp.

References token::BEGIN_LIST, token::END_LIST, pFlow::endl(), errLen, fatalExit, ioErrorInFile, pFlow::nl, pFlow::validWord(), and warningInFunction.

+ Here is the call graph for this function:

◆ readString()

pFlow::iIstream & readString ( word str)
overridevirtual

Read a string.

Implements iIstream.

Definition at line 680 of file Istream.cpp.

References token::BEGIN_STRING, token::END_STRING, errLen, fatalExit, ioErrorInFile, and token::NL.

◆ read() [4/12]

pFlow::iIstream & read ( int64 val)
overridevirtual

Read a int64.

Implements iIstream.

Definition at line 782 of file Istream.cpp.

◆ read() [5/12]

pFlow::iIstream & read ( int32 val)
overridevirtual

Read a int32.

Implements iIstream.

Definition at line 789 of file Istream.cpp.

◆ read() [6/12]

pFlow::iIstream & read ( int8 val)
overridevirtual

Read a int8.

Implements iIstream.

Definition at line 797 of file Istream.cpp.

◆ read() [7/12]

pFlow::iIstream & read ( uint64 val)
overridevirtual

Read a uint64.

Implements iIstream.

Definition at line 804 of file Istream.cpp.

◆ read() [8/12]

pFlow::iIstream & read ( uint32 val)
overridevirtual

Read a uint32.

Implements iIstream.

Definition at line 811 of file Istream.cpp.

◆ read() [9/12]

pFlow::iIstream & read ( uint8 val)
overridevirtual

Read a uint8.

Implements iIstream.

Definition at line 818 of file Istream.cpp.

◆ read() [10/12]

pFlow::iIstream & read ( float &  val)
overridevirtual

Read a float.

Implements iIstream.

Definition at line 825 of file Istream.cpp.

◆ read() [11/12]

pFlow::iIstream & read ( double &  val)
overridevirtual

Read a double.

Implements iIstream.

Definition at line 833 of file Istream.cpp.

◆ read() [12/12]

pFlow::iIstream & read ( char *  buffer,
std::streamsize  count 
)
overridevirtual

Write a block of binray data.

Implements iIstream.

Definition at line 841 of file Istream.cpp.

References pFlow::count(), fatalErrorInFunction, and fatalExit.

+ Here is the call graph for this function:

◆ findBinaryBlockStart()

size_t findBinaryBlockStart ( )
overridevirtual

It seek for a character sequence that indicates the start of a binary block char sequence is 255 255 255 0

Reimplemented from iIstream.

Definition at line 861 of file Istream.cpp.

◆ rewind()

void rewind ( )
overridevirtual

Rewind the stream so that it may be read again.

Implements iIstream.

Definition at line 891 of file Istream.cpp.

◆ seek()

void seek ( size_t  pos)
overridevirtual

Implements iIstream.

Definition at line 902 of file Istream.cpp.

◆ tell()

size_t tell ( )
overridevirtual

Return current position indicator.

Implements iIstream.

Definition at line 911 of file Istream.cpp.

References pFlow::endl(), fatalErrorInFunction, and fatalExit.

+ Here is the call graph for this function:

◆ flags() [2/2]

std::ios_base::fmtflags flags ( const ios_base::fmtflags  flags)
virtual

Set stream flags.

Implements IOstream.

Definition at line 933 of file Istream.cpp.

◆ stdStream() [1/2]

virtual std::istream& stdStream ( )
inlinevirtual

Access to underlying std::istream.

Definition at line 173 of file Istream.hpp.

References Istream::is_.

◆ stdStream() [2/2]

virtual const std::istream& stdStream ( ) const
inlinevirtual

Const access to underlying std::istream.

Definition at line 179 of file Istream.hpp.

References Istream::is_.

Member Data Documentation

◆ name_

word name_
private

Stream name.

Definition at line 46 of file Istream.hpp.

Referenced by Istream::name().

◆ is_

std::istream& is_
private

Input stream.

Definition at line 49 of file Istream.hpp.

Referenced by Istream::stdStream().


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