www.cemf.ir
iTstream.hpp
Go to the documentation of this file.
1 
2 #ifndef __iTstream_hpp__
3 #define __iTstream_hpp__
4 
5 #include "iIstream.hpp"
6 #include "tokenList.hpp"
7 
8 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
9 
10 namespace pFlow
11 {
12 
13 //- helper functions declearation
14 inline bool validTokenForStream(const token tok);
15 
16 inline bool isBeginToken(const token& tok);
17 
18 inline bool isEndToken(const token& tok);
19 
20 
27 class iTstream
28 :
29  public iIstream
30 {
31 protected:
32 
35 
38 
41 
43  bool isLastToken();
44 
46  void setFirstToken();
47 
49  void validate();
50 
51 public:
52 
54 
56  iTstream(const word& streamName);
57 
59  iTstream(const word& streamName, const tokenList& tList);
60 
62  iTstream(const word& streamName, tokenList && tList);
63 
65  iTstream(const iTstream&) = default;
66 
68  iTstream(iTstream&&) = default;
69 
71  iTstream& operator=(const iTstream&) = default;
72 
74  iTstream& operator=(iTstream&&) = default;
75 
77  void operator=(const tokenList& tList);
78 
80  void operator=(tokenList&& tList);
81 
83  virtual ~iTstream() = default;
84 
85 
87 
89  virtual const word& name() const;
90 
92  virtual word& name();
93 
95  virtual iIstream& read(token& t)override;
96 
98  virtual iIstream& read(char& c)override;
99 
101  virtual iIstream& read(word& str)override;
102 
104  virtual iIstream& readString(word& str)override;
105 
107  virtual iIstream& read(int64&) override;
108 
110  virtual iIstream& read(int32&) override;
111 
113  virtual iIstream& read(int8&) override;
114 
116  virtual iIstream& read(uint64&) override;
117 
119  virtual iIstream& read(uint32&) override;
120 
122  virtual iIstream& read(uint8&) override;
123 
125  virtual iIstream& read(float&) override;
126 
128  virtual iIstream& read(double&) override;
129 
130  iIstream& read(char* buffer, std::streamsize count) override;
131 
133  virtual void rewind()override;
134 
135  void seek(size_t pos) override;
136 
137  size_t tell() override;
138 
140  virtual void reset();
141 
143  const tokenList& tokens()const;
144 
146  size_t size()const;
147 
149  size_t numTokens()const;
150 
152  // and rewind the stream
153  void appendTokens(const tokenList & tList);
154 
156  void appendToken(const token& t);
157 
159  ios_base::fmtflags flags() const
160  {
161  return ios_base::fmtflags(0);
162  }
163 
165  ios_base::fmtflags flags(const ios_base::fmtflags)
166  {
167  return ios_base::fmtflags(0);
168  }
169 
170 };
171 
172 #include "helperTstream.hpp"
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 } // End namespace Foam
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 
181 
182 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 
184 #endif
185 
186 // ************************************************************************* //
pFlow::iTstream::flags
ios_base::fmtflags flags() const
Return flags of output stream.
Definition: iTstream.hpp:159
pFlow::iTstream::tokens
const tokenList & tokens() const
const access to token list
Definition: iTstream.cpp:331
pFlow::List< token >
pFlow::iTstream::flags
ios_base::fmtflags flags(const ios_base::fmtflags)
Set flags of stream.
Definition: iTstream.hpp:165
pFlow::isBeginToken
bool isBeginToken(const token &tok)
Is tok a begin token?
pFlow::iTstream::isLastToken
bool isLastToken()
check if end of list is reached
Definition: iTstream.cpp:6
pFlow::token
Token class based on OpenFOAM stream, with some modifications/simplifications to be tailored to our n...
Definition: token.hpp:44
iIstream.hpp
pFlow::iTstream::tell
size_t tell() override
Return current position indicator.
Definition: iTstream.cpp:325
pFlow::isEndToken
bool isEndToken(const token &tok)
Is tok an end token?
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
helperTstream.hpp
pFlow::iTstream::reset
virtual void reset()
reset the iTstream and make the stream empty
Definition: iTstream.cpp:317
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::iTstream::size
size_t size() const
size
Definition: iTstream.cpp:336
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:52
pFlow::iTstream::setFirstToken
void setFirstToken()
rewind the stream
Definition: iTstream.cpp:11
pFlow::iTstream::operator=
iTstream & operator=(const iTstream &)=default
copy assignment
pFlow::validTokenForStream
bool validTokenForStream(const token tok)
Is tok a valid token for this stream?
pFlow
Definition: demGeometry.hpp:27
pFlow::iTstream::seek
void seek(size_t pos) override
Definition: iTstream.cpp:312
pFlow::iTstream::name_
word name_
name of the stream
Definition: iTstream.hpp:34
pFlow::iTstream::appendTokens
void appendTokens(const tokenList &tList)
append a list of tokens to the end of tokens
Definition: iTstream.cpp:347
tokenList.hpp
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::iTstream::tokenList_
tokenList tokenList_
list of tokens in this stream
Definition: iTstream.hpp:37
pFlow::iTstream::iTstream
iTstream(const word &streamName)
construct with a name
Definition: iTstream.cpp:32
pFlow::iTstream::name
virtual const word & name() const
Return the name of the stream.
Definition: iTstream.cpp:99
pFlow::iTstream::rewind
virtual void rewind() override
Rewind the stream so that it may be read again.
Definition: iTstream.cpp:305
pFlow::List< token >::iterator
typename listType::iterator iterator
Definition: List.hpp:50
pFlow::iTstream::read
virtual iIstream & read(token &t) override
Return next token from stream.
Definition: iTstream.cpp:111
pFlow::count
auto count(const Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:26
pFlow::iTstream::validate
void validate()
check for valid tokens in the tokenList
Definition: iTstream.cpp:16
pFlow::iTstream
Input token stream.
Definition: iTstream.hpp:27
pFlow::iTstream::appendToken
void appendToken(const token &t)
append token to the end of token and rewind the stream
Definition: iTstream.cpp:360
pFlow::iTstream::~iTstream
virtual ~iTstream()=default
Destructor.
pFlow::iTstream::numTokens
size_t numTokens() const
size
Definition: iTstream.cpp:341
pFlow::uint64
unsigned long long int uint64
Definition: builtinTypes.hpp:58
pFlow::iTstream::currentToken_
tokenList::iterator currentToken_
current token
Definition: iTstream.hpp:40
pFlow::int8
signed char int8
Definition: builtinTypes.hpp:48
pFlow::iTstream::readString
virtual iIstream & readString(word &str) override
Read a string.
Definition: iTstream.cpp:192
pFlow::uint8
unsigned char uint8
Definition: builtinTypes.hpp:54