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 
111 
112 
113 
115 {
116  append(token(static_cast<int64>(val))); // tokenType::INT64
117 
118  return *this;
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 
135 
137 {
138  append(token(val)); // tokenType::FLOAT
139 
140  return *this;
141 }
142 
143 
145 {
146  append(token(val)); // tokenType::DOUBLE
147 
148  return *this;
149 }
150 
151 
152 
154 {
155 
156  if( validTokenForStream(tok) )
157  tokenList_.push_back(tok);
158 }
159 
161 {
162  for(auto& e:tLisk)
163  {
164  append(e);
165  }
166 }
167 
169 {
170  this->rewind();
171 }
172 
173 //- Rewind the output stream
175 {
176  tokenList_.clear();
177  setGood();
178 }
179 // ************************************************************************* //
pFlow::oTstream
Definition: oTstream.hpp:23
pFlow::List< token >
pFlow::token
Definition: token.hpp:42
pFlow::oTstream::name_
word name_
Definition: oTstream.hpp:31
pFlow::token::punctuationToken
punctuationToken
Definition: token.hpp:81
pFlow::token::good
bool good() const
Definition: tokenI.hpp:372
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:59
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::oTstream::append
virtual void append(const token &tok)
Definition: oTstream.cpp:153
oTstream.hpp
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:55
pFlow::oTstream::reset
void reset()
Definition: oTstream.cpp:168
pFlow::oTstream::tokens
const tokenList & tokens() const
Definition: oTstream.cpp:32
pFlow::validTokenForStream
bool validTokenForStream(const token tok)
pFlow::oTstream::oTstream
oTstream(const word &nm)
Definition: oTstream.cpp:6
pFlow::uint16
unsigned short int uint16
Definition: builtinTypes.hpp:57
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::label
std::size_t label
Definition: builtinTypes.hpp:61
pFlow::oTstream::write
virtual bool write(const token &tok)
Definition: oTstream.cpp:44
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::oTstream::tokenList_
tokenList tokenList_
Definition: oTstream.hpp:34
error.hpp