www.cemf.ir
oTstream.cpp
Go to the documentation of this file.
1 
2 #include "oTstream.hpp"
3 #include "error.hpp"
4 
6 (
7  const word& nm
8 )
9 :
10  iOstream(),
11  name_(nm),
12  tokenList_()
13 {
14  setOpened();
15  setGood();
16 }
17 
19 (
20  const oTstream& src
21 )
22 :
23  iOstream(src),
24  name_(src.name_),
25  tokenList_(src.tokenList_)
26 {
27  setOpened();
28  setGood();
29 }
30 
31 
33 {
34  return tokenList_;
35 }
36 
37 
39 {
40  return tokenList_;
41 }
42 
43 
44 bool pFlow::oTstream::write(const token& tok)
45 {
46  if (tok.good())
47  {
48  append(tok);
49  return true;
50  }
51 
52  return false;
53 }
54 
55 
57 {
58  if (!std::isspace(c) && std::isprint(c))
59  {
60  // Should generally work, but need to verify corner cases
61  append(token(token::punctuationToken(c)));
62  }
63 
64  return *this;
65 }
66 
67 
69 {
70 
71  append(token(word(str)));
72 
73  return *this;
74 }
75 
76 
78 {
79  append(token(str)); // tokenType::WORD
80 
81  return *this;
82 }
83 
84 
86 (
87  const word& str,
88  const bool quoted
89 )
90 {
91 
92  append(token(str, lineNumber(),quoted)); // tokenType::STRING/WORD
93 
94  return *this;
95 }
96 
98 {
99  append(token(val)); // tokenType::INT64
100 
101  return *this;
102 }
103 
105 {
106  append(token(val)); // tokenType::INT64
107 
108  return *this;
109 }
110 
112 {
113  append(token(val)); // tokenType::INT64
114 
115  return *this;
116 }
117 
118 
119 
120 
122 {
123  append(token(static_cast<int64>(val))); // tokenType::INT64
124 
125  return *this;
126 }
127 
129 {
130  append(token(static_cast<int64>(val))); // tokenType::INT64
131 
132  return *this;
133 }
134 
136 {
137  append(token(static_cast<int64>(val))); // tokenType::INT64
138 
139  return *this;
140 }
141 
142 
144 {
145  append(token(val)); // tokenType::FLOAT
146 
147  return *this;
148 }
149 
150 
152 {
153  append(token(val)); // tokenType::DOUBLE
154 
155  return *this;
156 }
157 
159 {
160  append(token(static_cast<int64>(val))); // tokenType::INT64
161 
162  return *this;
163 }
164 
165 
167 (
168  const char* binaryData,
169  std::streamsize count
170 )
171 {
173  return *this;
174 }
175 
176 void pFlow::oTstream::seek(size_t pos)
177 {
179 }
180 
182 {
183 
184  if( validTokenForStream(tok) )
185  tokenList_.push_back(tok);
186 }
187 
189 {
190  for(auto& e:tLisk)
191  {
192  append(e);
193  }
194 }
195 
197 {
198  this->rewind();
199 }
200 
201 //- Rewind the output stream
203 {
204  tokenList_.clear();
205  setGood();
206 }
207 // ************************************************************************* //
pFlow::oTstream
Output token stream.
Definition: oTstream.hpp:48
notImplementedFunction
#define notImplementedFunction
Report that a function is yet not implemented.
Definition: error.hpp:84
pFlow::List< 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::token::punctuationToken
punctuationToken
Standard punctuation tokens (a character)
Definition: token.hpp:83
pFlow::token::good
bool good() const
True if token is not UNDEFINED or ERROR.
Definition: tokenI.hpp:390
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
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
oTstream.hpp
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:52
pFlow::oTstream::seek
void seek(size_t pos) override
Definition: oTstream.cpp:176
pFlow::oTstream::reset
void reset()
Reset the output buffer and rewind the stream.
Definition: oTstream.cpp:196
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::oTstream::oTstream
oTstream(const word &nm)
emtpy stream with a name
Definition: oTstream.cpp:6
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::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::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
error.hpp