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 
105  // - append token to the stream
106  virtual void append(const token& tok);
107 
108  // - append a list of tokens to the stream
109  virtual void append(const tokenList& tLisk);
110 
111 
112 
114 
115  //- Reset the output buffer and rewind the stream
116  void reset();
117 
118  //- Rewind the output stream
119  virtual void rewind();
120 
121  //- Add indentation characters
122  virtual void indent()
123  {}
124 
125  //- Flush stream
126  virtual void flush()
127  {}
128 
129  //- Add newline and flush stream
130  virtual void endl()
131  {}
132 
133  //- Get the current padding character
134  // \return previous padding character
135  virtual char fill() const
136  {
137  return 0;
138  }
139 
140  //- Set padding character for formatted field up to field width
141  virtual char fill(const char)
142  {
143  return 0;
144  }
145 
146  //- Get width of output field
147  virtual int width() const
148  {
149  return 0;
150  }
151 
152  //- Set width of output field
153  // \return previous width
154  virtual int width(const int)
155  {
156  return 0;
157  }
158 
159  //- Get precision of output field
160  virtual int precision() const
161  {
162  return 0;
163  }
164 
165  //- Set precision of output field
166  // \return old precision
167  virtual int precision(const int)
168  {
169  return 0;
170  }
171 
172  //- Return flags of output stream
173  virtual ios_base::fmtflags flags() const
174  {
175  return ios_base::fmtflags(0);
176  }
177 
178  //- Set flags of stream
179  ios_base::fmtflags flags(const ios_base::fmtflags)
180  {
181  return ios_base::fmtflags(0);
182  }
183 
184 };
185 
186 #include "helperTstream.hpp"
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
190 } // End namespace pFlow
191 
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 
194 #endif
195 
196 // ************************************************************************* //
pFlow::oTstream::flags
ios_base::fmtflags flags(const ios_base::fmtflags)
Definition: oTstream.hpp:179
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()
Definition: oTstream.hpp:130
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:153
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:55
pFlow::oTstream::width
virtual int width(const int)
Definition: oTstream.hpp:154
pFlow::oTstream::indent
virtual void indent()
Definition: oTstream.hpp:122
pFlow::oTstream::precision
virtual int precision() const
Definition: oTstream.hpp:160
pFlow::oTstream::flush
virtual void flush()
Definition: oTstream.hpp:126
pFlow::oTstream::reset
void reset()
Definition: oTstream.cpp:168
pFlow::oTstream::fill
virtual char fill(const char)
Definition: oTstream.hpp:141
pFlow::oTstream::fill
virtual char fill() const
Definition: oTstream.hpp:135
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
Definition: oTstream.hpp:173
pFlow::oTstream::width
virtual int width() const
Definition: oTstream.hpp:147
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::oTstream::rewind
virtual void rewind()
Definition: oTstream.cpp:174
pFlow::oTstream::writeQuoted
virtual iOstream & writeQuoted(const std::string &str, const bool quoted=true)
Definition: oTstream.cpp:86
pFlow::oTstream::precision
virtual int precision(const int)
Definition: oTstream.hpp:167
pFlow::label
std::size_t label
Definition: builtinTypes.hpp:61
pFlow::oTstream::write
virtual bool write(const token &tok)
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