# PhasicFlow: src/phasicFlow/streams/iStream/iIstream.hpp Source File
PhasicFlow is an open-source parallel DEM (discrete element method) package for simulating granular flow. It is developed in C++ and can be exectued on both GPU (like CUDA) and CPU.

iIstream.hpp
Go to the documentation of this file.
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
#ifndef __iIstream_hpp__
#define __iIstream_hpp__
#include "IOstream.hpp"
#include "token.hpp"
#include "error.hpp"
#include "iOstream.hpp"
namespace pFlow
{
class iIstream
:
public IOstream
{
//- Private Data
bool putBack_;
token putBackToken_;
public:
iIstream():
IOstream(),
putBack_(false)
{}
iIstream(writeFormat wf):
IOstream(wf),
putBack_(false)
{}
iIstream(const iIstream&) = default;
virtual ~iIstream() = default;
void putBack(const token& tok);
bool getBack(token& tok);
bool peekBack(token& tok);
void resetPutBack()
{
putBackToken_.reset();
putBack_ = false;
}
virtual iIstream& read(token&) = 0;
virtual iIstream& read(char&) = 0;
virtual iIstream& read(word&) = 0;
virtual iIstream& readString(word&) = 0;
virtual iIstream& read(int64&) = 0;
virtual iIstream& read(int32&) = 0;
virtual iIstream& read(int8&) = 0;
virtual iIstream& read(uint64&) = 0;
virtual iIstream& read(uint32&) = 0;
virtual iIstream& read(uint8&) = 0;
virtual iIstream& read(float&) = 0;
virtual iIstream& read(double&) = 0;
virtual iIstream& read(char* buffer, std::streamsize count) =0;
virtual void rewind() = 0;
virtual void seek(size_t pos) = 0;
virtual size_t tell() = 0;
virtual size_t findBinaryBlockStart();
virtual bool findToken( const word & w );
virtual bool findTokenResume(const word& w);
virtual bool findTokenSilent( const word & w, int32 limitLine = 100 );
virtual bool findTokenResumeSilent( const word & w, int32 limitLine = 100 );
virtual bool findTokenAndNext( const word& w, word& nextW, bool checkEndStatement = true);
virtual bool findTokenAndNextSilent( const word& w, word& nextW, int32 limitLine = 100);
template<typename T>
bool findKeywordAndVal(const word& keyword, T& val, bool checkEndStatement = true);
template<typename T>
T lookupData(const word& keyword);
template<typename T>
T lookupDataOrSet(const word& keyword, const T& setVal);
template<typename T>
bool nextData(const word& keyword, T& data);
bool readBegin(const char* funcName);
bool readEnd(const char* funcName);
bool readBeginSquare(const char* funcName);
bool readEndSquare(const char* funcName);
char readBeginList(const char* funcName);
char readEndList(const char* funcName);
char readEndStatement(const char* funcName);
iIstream& operator()() const;
};
typedef iIstream& (*iIstreamManip)(iIstream&);
inline iIstream& operator>>(iIstream& is, iIstreamManip f)
{
return f(is);
}
inline iIstream& operator>>(iIstream& is, IOstreamManip f)
{
f(is);
return is;
}
// read operation for basic types it gets from the token stream
inline iIstream& operator>>( iIstream& is, word & w);
inline iIstream& operator>>( iIstream& is, int64& val);
inline iIstream& operator>>( iIstream& is, int32& val);
inline iIstream& operator>>( iIstream& is, int8& val);
inline iIstream& operator>>( iIstream& is, uint64& val);
inline iIstream& operator>>( iIstream& is, uint32& val);
inline iIstream& operator>>( iIstream& is, uint8& val);
inline iIstream& operator>>( iIstream& is, float& val);
inline iIstream& operator>>( iIstream& is, double& val);
inline iIstream& operator>>( iIstream& is, size_t& val);
} // pFlow
#include "iIstreamI.hpp"
#endif //__iIstream_hpp__
pFlow::iIstream::readBegin
bool readBegin(const char *funcName)
Begin read of data chunk, starts with '('.
Definition: iIstream.cpp:238
pFlow::iIstream::seek
virtual void seek(size_t pos)=0
pFlow::iIstream::findTokenAndNextSilent
virtual bool findTokenAndNextSilent(const word &w, word &nextW, int32 limitLine=100)
Definition: iIstream.cpp:203
pFlow::iIstream::lookupDataOrSet
T lookupDataOrSet(const word &keyword, const T &setVal)
lookup for keyword and data; set to setVal if lookup fails.
Definition: iIstreamI.hpp:68
pFlow::iIstream::read
virtual iIstream & read(token &)=0
Return next token from stream.
pFlow::token
Token class based on OpenFOAM stream, with some modifications/simplifications to be tailored to our n...
Definition: token.hpp:44
pFlow::iIstream::readString
virtual iIstream & readString(word &)=0
Read a string.
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
token.hpp
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::iIstream::readEnd
bool readEnd(const char *funcName)
End read of data chunk, ends with ')' return true or FatalIOError.
Definition: iIstream.cpp:258
pFlow::iIstream::readEndStatement
char readEndStatement(const char *funcName)
End statement character ;.
Definition: iIstream.cpp:359
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:52
pFlow::iIstream::iIstream
iIstream(writeFormat wf)
Definition: iIstream.hpp:60
pFlow::iIstream::findKeywordAndVal
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 ...
Definition: iIstreamI.hpp:24
pFlow::iIstream::findTokenSilent
virtual bool findTokenSilent(const word &w, int32 limitLine=100)
search for all tokesn and find the first word token that matchs
Definition: iIstream.cpp:123
pFlow
Definition: demGeometry.hpp:27
pFlow::IOstreamManip
IOstream &(* IOstreamManip)(IOstream &)
An IOstream manipulator.
Definition: IOstream.hpp:308
pFlow::iIstream::findTokenResume
virtual bool findTokenResume(const word &w)
search for all tokesn after the current file position and find the first word token tbat matchs w
Definition: iIstream.cpp:90
pFlow::token::reset
void reset()
Reset token to UNDEFINED and clear any allocated storage.
Definition: tokenI.hpp:263
pFlow::iIstream::rewind
virtual void rewind()=0
Rewind the stream so that it may be read again.
pFlow::iIstream::findTokenResumeSilent
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
Definition: iIstream.cpp:129
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::iIstreamManip
iIstream &(* iIstreamManip)(iIstream &)
Definition: iIstream.hpp:228
pFlow::iIstream::getBack
bool getBack(token &tok)
Get the put back token if there is one and return true.
Definition: iIstream.cpp:45
pFlow::iIstream::iIstream
iIstream()
default
Definition: iIstream.hpp:55
pFlow::iIstream::nextData
bool nextData(const word &keyword, T &data)
read the data next to keword keyword data; check the keyword is correct or not
Definition: iIstreamI.hpp:81
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::iIstream::readBeginList
char readBeginList(const char *funcName)
Begin read of list data, starts with '(' or '{' return starting delimiter or FatalIOError.
Definition: iIstream.cpp:315
pFlow::iIstream::putBack_
bool putBack_
Has a token been put back on the stream?
Definition: iIstream.hpp:45
pFlow::iIstream::putBack
void putBack(const token &tok)
Put back token Only a single put back is permitted.
Definition: iIstream.cpp:23
pFlow::operator>>
INLINE_FUNCTION iIstream & operator>>(iIstream &str, AB3History &ab3)
Definition: AdamsBashforth3.hpp:41
pFlow::iIstream::findTokenAndNext
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 w...
Definition: iIstream.cpp:157
pFlow::count
auto count(const Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:26
pFlow::iIstream::operator()
iIstream & operator()() const
Definition: iIstream.cpp:377
pFlow::iIstream::resetPutBack
void resetPutBack()
reset the put back token;
Definition: iIstream.hpp:89
pFlow::iIstream::tell
virtual size_t tell()=0
Return current position indicator.
pFlow::iIstream::lookupData
T lookupData(const word &keyword)
lookup for keyword and data; fatalExit if fails
Definition: iIstreamI.hpp:52
pFlow::iIstream::readBeginSquare
bool readBeginSquare(const char *funcName)
Begin read of data chunk, starts with '('.
Definition: iIstream.cpp:277
IOstream.hpp
iIstreamI.hpp
pFlow::iIstream::putBackToken_
token putBackToken_
The last token put back on the stream.
Definition: iIstream.hpp:48
pFlow::iIstream::readEndList
char readEndList(const char *funcName)
End read of list data, ends with ')' or '}' return closing delimiter or FatalIOError.
Definition: iIstream.cpp:336
pFlow::iIstream::findBinaryBlockStart
virtual size_t findBinaryBlockStart()
It seek for a character sequence that indicates the start of a binary block char sequence is 255 255 ...
Definition: iIstream.cpp:78
pFlow::uint64
unsigned long long int uint64
Definition: builtinTypes.hpp:58
pFlow::int8
signed char int8
Definition: builtinTypes.hpp:48
iOstream.hpp
pFlow::IOstream::writeFormat
writeFormat
Definition: IOstream.hpp:59
pFlow::iIstream::findToken
virtual bool findToken(const word &w)
search for all tokesn and find the first word token tbat matchs w
Definition: iIstream.cpp:84
pFlow::uint8
unsigned char uint8
Definition: builtinTypes.hpp:54
pFlow::IOstream
A base calss for input/output streams.
Definition: IOstream.hpp:47
pFlow::iIstream::~iIstream
virtual ~iIstream()=default
Destructor.
pFlow::iIstream::readEndSquare
bool readEndSquare(const char *funcName)
Begin read of data chunk, starts with '('.
Definition: iIstream.cpp:296
error.hpp
pFlow::iIstream::peekBack
bool peekBack(token &tok)
Peek at the put back token without removing it.
Definition: iIstream.cpp:64