www.cemf.ir
oTstream.hpp
Go to the documentation of this file.
1 
2 #ifndef __oTstream_hpp__
3 #define __oTstream_hpp__
4 
5 #include "tokenList.hpp"
6 #include "iOstream.hpp"
7 
8 
9 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
10 
11 namespace pFlow
12 {
13 
14 
15 // helper functions declearation
16 inline bool validTokenForStream(const token tok);
17 
18 inline bool isBeginToken(const token& tok);
19 
20 inline bool isEndToken(const token& tok);
21 
22 
23 class oTstream
24 :
25  public iOstream
26 {
27 
28 protected:
29 
30  // - name of stream
32 
33  // - tokenList
35 
36 public:
37 
39 
40  // - emtpy stream with a name
41  oTstream(const word& nm);
42 
43  // - copy construcotr
44  oTstream(const oTstream& src);
45 
46  // - move construct
47  oTstream(oTstream&&) = default;
48 
49  // - destructor
50  virtual ~oTstream() = default;
51 
52 
54 
55  // give const access
56  const tokenList& tokens()const;
57 
58  // give access
59  tokenList& tokens();
60 
61 
63 
64  //- Write token to stream or otherwise handle it.
65  // return false if the token type was not handled by this method
66  virtual bool write(const token& tok);
67 
68  //- Write single character. Whitespace is suppressed.
69  virtual iOstream& write(const char c);
70 
71  //- Write the word-characters of a character string.
72  // Sends as a single char, or as word.
73  virtual iOstream& write(const char* str);
74 
75  //- Write word
76  virtual iOstream& write(const word& str);
77 
78 
79  //- Write std::string surrounded by quotes.
80  // Optional write without quotes.
81  virtual iOstream& writeQuoted(const std::string& str, const bool quoted=true );
82 
83  //- Write int64
84  virtual iOstream& write(const int64 val) override;
85 
86  //- Write int32
87  virtual iOstream& write(const int32 val) override;
88 
89 
90  //- Write label
91  virtual iOstream& write(const label val) override;
92 
93  //- Write uint32
94  virtual iOstream& write(const uint32 val) override;
95 
96  //- Write uint16
97  virtual iOstream& write(const uint16 val) override;
98 
99  //- Write float
100  virtual iOstream& write(const float val) override;
101 
102  //- Write double
103  virtual iOstream& write(const double val) override;
104 
106  iOstream& write(
107  const char* binaryData,
108  std::streamsize count) override;
109 
110  // - append token to the stream
111  virtual void append(const token& tok);
112 
113  // - append a list of tokens to the stream
114  virtual void append(const tokenList& tLisk);
115 
116 
117 
119 
120  //- Reset the output buffer and rewind the stream
121  void reset();
122 
123  //- Rewind the output stream
124  virtual void rewind();
125 
126  //- Add indentation characters
127  virtual void indent()
128  {}
129 
130  //- Flush stream
131  virtual void flush()
132  {}
133 
134  //- Add newline and flush stream
135  virtual void endl()
136  {}
137 
138  //- Get the current padding character
139  // \return previous padding character
140  virtual char fill() const
141  {
142  return 0;
143  }
144 
145  //- Set padding character for formatted field up to field width
146  virtual char fill(const char)
147  {
148  return 0;
149  }
150 
151  //- Get width of output field
152  virtual int width() const
153  {
154  return 0;
155  }
156 
157  //- Set width of output field
158  // \return previous width
159  virtual int width(const int)
160  {
161  return 0;
162  }
163 
164  //- Get precision of output field
165  virtual int precision() const
166  {
167  return 0;
168  }
169 
170  //- Set precision of output field
171  // \return old precision
172  virtual int precision(const int)
173  {
174  return 0;
175  }
176 
177  //- Return flags of output stream
178  virtual ios_base::fmtflags flags() const
179  {
180  return ios_base::fmtflags(0);
181  }
182 
183  //- Set flags of stream
184  ios_base::fmtflags flags(const ios_base::fmtflags)
185  {
186  return ios_base::fmtflags(0);
187  }
188 
189 };
190 
191 #include "helperTstream.hpp"
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 } // End namespace pFlow
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 #endif
200 
201 // ************************************************************************* //
pFlow::oTstream::flags
ios_base::fmtflags flags(const ios_base::fmtflags)
Set flags of stream.
Definition: oTstream.hpp:184
pFlow::oTstream
Definition: oTstream.hpp:23
pFlow::List< token >
pFlow::isBeginToken
bool isBeginToken(const token &tok)
pFlow::token
Definition: token.hpp:42
pFlow::oTstream::name_
word name_
Definition: oTstream.hpp:31
pFlow::oTstream::endl
virtual void endl()
Add newline and flush stream.
Definition: oTstream.hpp:135
pFlow::isEndToken
bool isEndToken(const token &tok)
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:59
helperTstream.hpp
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::oTstream::append
virtual void append(const token &tok)
Definition: oTstream.cpp:162
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:55
pFlow::oTstream::width
virtual int width(const int)
Set width of output field (and return old width)
Definition: oTstream.hpp:159
pFlow::oTstream::indent
virtual void indent()
Add indentation characters.
Definition: oTstream.hpp:127
pFlow::oTstream::precision
virtual int precision() const
Get precision of output field.
Definition: oTstream.hpp:165
pFlow::oTstream::flush
virtual void flush()
Flush stream.
Definition: oTstream.hpp:131
pFlow::oTstream::reset
void reset()
Definition: oTstream.cpp:177
pFlow::oTstream::fill
virtual char fill(const char)
Set padding character for formatted field up to field width.
Definition: oTstream.hpp:146
pFlow::oTstream::fill
virtual char fill() const
Get padding character.
Definition: oTstream.hpp:140
pFlow::oTstream::tokens
const tokenList & tokens() const
Definition: oTstream.cpp:32
pFlow::validTokenForStream
bool validTokenForStream(const token tok)
pFlow
Definition: demComponent.hpp:28
pFlow::oTstream::oTstream
oTstream(const word &nm)
Definition: oTstream.cpp:6
tokenList.hpp
pFlow::uint16
unsigned short int uint16
Definition: builtinTypes.hpp:57
pFlow::oTstream::flags
virtual ios_base::fmtflags flags() const
Return flags of stream.
Definition: oTstream.hpp:178
pFlow::oTstream::width
virtual int width() const
Get width of output field.
Definition: oTstream.hpp:152
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::count
auto count(const Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:26
pFlow::oTstream::rewind
virtual void rewind()
Definition: oTstream.cpp:183
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 (and return old precision)
Definition: oTstream.hpp:172
pFlow::label
std::size_t label
Definition: builtinTypes.hpp:61
pFlow::oTstream::write
virtual bool write(const token &tok)
Write Functions.
Definition: oTstream.cpp:44
pFlow::oTstream::~oTstream
virtual ~oTstream()=default
iOstream.hpp
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::oTstream::tokenList_
tokenList tokenList_
Definition: oTstream.hpp:34