www.cemf.ir
oTstream.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 #ifndef __oTstream_hpp__
21 #define __oTstream_hpp__
22 
23 #include "tokenList.hpp"
24 #include "iOstream.hpp"
25 
26 
27 namespace pFlow
28 {
29 
30 
31 //- Helper functions declearation
32 
34 inline bool validTokenForStream(const token tok);
35 
37 inline bool isBeginToken(const token& tok);
38 
40 inline bool isEndToken(const token& tok);
41 
48 class oTstream
49 :
50  public iOstream
51 {
52 
53 protected:
54 
57 
60 
61 public:
62 
64 
66  oTstream(const word& nm);
67 
69  oTstream(const oTstream& src);
70 
72  oTstream(oTstream&&) = default;
73 
75  virtual ~oTstream() = default;
76 
77 
79 
80  // Give const access
81  const tokenList& tokens()const;
82 
83  // Give access
84  tokenList& tokens();
85 
86 
88 
91  virtual bool write(const token& tok);
92 
94  virtual iOstream& write(const char c);
95 
98  virtual iOstream& write(const char* str);
99 
101  virtual iOstream& write(const word& str);
102 
103 
106  virtual iOstream& writeQuoted(const std::string& str, const bool quoted=true );
107 
109  virtual iOstream& write(const int64 val) override;
110 
112  virtual iOstream& write(const int32 val) override;
113 
115  virtual iOstream& write(const int8 val) override;
116 
118  virtual iOstream& write(const uint64 val) override;
119 
121  virtual iOstream& write(const uint32 val) override;
122 
124  virtual iOstream& write(const uint8 val) override;
125 
127  virtual iOstream& write(const float val) override;
128 
130  virtual iOstream& write(const double val) override;
131 
133  virtual iOstream& write(const size_t val) override;
134 
135  void seek(size_t pos) override;
136 
138  iOstream& write(
139  const char* binaryData,
140  std::streamsize count) override;
141 
143  virtual void append(const token& tok);
144 
146  virtual void append(const tokenList& tLisk);
147 
148 
149 
151 
153  void reset();
154 
156  virtual void rewind();
157 
159  virtual void indent()
160  {}
161 
163  virtual void startOfBinaryStreaming()
164  {}
165 
167  virtual void endOfBinaryStreaming()
168  {}
169 
171  virtual void flush()
172  {}
173 
175  virtual void endl()
176  {}
177 
180  virtual char fill() const
181  {
182  return 0;
183  }
184 
186  virtual char fill(const char)
187  {
188  return 0;
189  }
190 
192  virtual int width() const
193  {
194  return 0;
195  }
196 
199  virtual int width(const int)
200  {
201  return 0;
202  }
203 
205  virtual int precision() const
206  {
207  return 0;
208  }
209 
212  virtual int precision(const int)
213  {
214  return 0;
215  }
216 
218  virtual ios_base::fmtflags flags() const
219  {
220  return ios_base::fmtflags(0);
221  }
222 
224  ios_base::fmtflags flags(const ios_base::fmtflags)
225  {
226  return ios_base::fmtflags(0);
227  }
228 
229 };
230 
231 #include "helperTstream.hpp"
232 
233 
234 } // End namespace pFlow
235 
236 
237 #endif
238 
pFlow::oTstream::flags
ios_base::fmtflags flags(const ios_base::fmtflags)
Set flags of stream.
Definition: oTstream.hpp:224
pFlow::oTstream
Output token stream.
Definition: oTstream.hpp:48
pFlow::List< token >
pFlow::isBeginToken
bool isBeginToken(const token &tok)
Is tok a begin token?
pFlow::token
Token class based on OpenFOAM stream, with some modifications/simplifications to be tailored to our n...
Definition: token.hpp:44
pFlow::oTstream::name_
word name_
name of stream
Definition: oTstream.hpp:56
pFlow::oTstream::endl
virtual void endl()
Add newline and flush stream.
Definition: oTstream.hpp:175
pFlow::oTstream::startOfBinaryStreaming
virtual void startOfBinaryStreaming()
Add a new line and flush stream.
Definition: oTstream.hpp:163
pFlow::oTstream::endOfBinaryStreaming
virtual void endOfBinaryStreaming()
Reach end of file add a new line and flush stream.
Definition: oTstream.hpp:167
pFlow::isEndToken
bool isEndToken(const token &tok)
Is tok an end token?
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
helperTstream.hpp
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::oTstream::append
virtual void append(const token &tok)
append token to the stream
Definition: oTstream.cpp:181
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:52
pFlow::oTstream::width
virtual int width(const int)
Set width of output field.
Definition: oTstream.hpp:199
pFlow::oTstream::indent
virtual void indent()
Add indentation characters.
Definition: oTstream.hpp:159
pFlow::oTstream::precision
virtual int precision() const
Get precision of output field.
Definition: oTstream.hpp:205
pFlow::oTstream::seek
void seek(size_t pos) override
Definition: oTstream.cpp:176
pFlow::oTstream::flush
virtual void flush()
Flush stream.
Definition: oTstream.hpp:171
pFlow::oTstream::reset
void reset()
Reset the output buffer and rewind the stream.
Definition: oTstream.cpp:196
pFlow::oTstream::fill
virtual char fill(const char)
Set padding character for formatted field up to field width.
Definition: oTstream.hpp:186
pFlow::oTstream::fill
virtual char fill() const
Get the current padding character.
Definition: oTstream.hpp:180
pFlow::oTstream::tokens
const tokenList & tokens() const
Definition: oTstream.cpp:32
pFlow::validTokenForStream
bool validTokenForStream(const token tok)
Is tok a valid token for this stream?
pFlow
Definition: demGeometry.hpp:27
pFlow::oTstream::oTstream
oTstream(const word &nm)
emtpy stream with a name
Definition: oTstream.cpp:6
tokenList.hpp
pFlow::oTstream::flags
virtual ios_base::fmtflags flags() const
Return flags of output stream.
Definition: oTstream.hpp:218
pFlow::oTstream::width
virtual int width() const
Get width of output field.
Definition: oTstream.hpp:192
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::count
auto count(const Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:26
pFlow::oTstream::rewind
virtual void rewind()
Rewind the output stream.
Definition: oTstream.cpp:202
pFlow::oTstream::writeQuoted
virtual iOstream & writeQuoted(const std::string &str, const bool quoted=true)
Write std::string surrounded by quotes.
Definition: oTstream.cpp:86
pFlow::oTstream::precision
virtual int precision(const int)
Set precision of output field.
Definition: oTstream.hpp:212
pFlow::uint64
unsigned long long int uint64
Definition: builtinTypes.hpp:58
pFlow::int8
signed char int8
Definition: builtinTypes.hpp:48
pFlow::oTstream::write
virtual bool write(const token &tok)
Write token to stream or otherwise handle it.
Definition: oTstream.cpp:44
pFlow::oTstream::~oTstream
virtual ~oTstream()=default
destructor
iOstream.hpp
pFlow::uint8
unsigned char uint8
Definition: builtinTypes.hpp:54
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::oTstream::tokenList_
tokenList tokenList_
tokenList
Definition: oTstream.hpp:59