iTstream.hpp
Go to the documentation of this file.
1 
2 #ifndef __iTstream_hpp__
3 #define __iTstream_hpp__
4 
5 #include "iIstream.hpp"
6 #include "tokenList.hpp"
7 
8 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
9 
10 namespace pFlow
11 {
12 
13 // helper functions declearation
14 inline bool validTokenForStream(const token tok);
15 
16 inline bool isBeginToken(const token& tok);
17 
18 inline bool isEndToken(const token& tok);
19 
20 
21 class iTstream
22 :
23  public iIstream
24 {
25 protected:
26 
27  // - name of the stream
29 
30  // - list of tokens in this stream
32 
33  // - current token
35 
36  // - check if end of list is reached
37  bool isLastToken();
38 
39  // - rewind the stream
40  void setFirstToken();
41 
42  // - check for valid tokens in the tokenList
43  void validate();
44 
45 public:
46 
48 
49  //- construct with a name
50  iTstream(const word& streamName);
51 
52  // - construct with name and copy
53  iTstream(const word& streamName, const tokenList& tList);
54 
55  // - construct with name and move
56  iTstream(const word& streamName, tokenList && tList);
57 
58  // - copy construct
59  iTstream(const iTstream&) = default;
60  // - move construct
61  iTstream(iTstream&&) = default;
62 
63  // - copy assignment
64  iTstream& operator=(const iTstream&) = default;
65 
66  // - move assignment
67  iTstream& operator=(iTstream&&) = default;
68 
69  // copy assignment from tokenList
70  void operator=(const tokenList& tList);
71 
72  // move assignment from tokenList
73  void operator=(tokenList&& tList);
74 
75  //- Destructor
76  virtual ~iTstream() = default;
77 
78 
80 
81  //- Return the name of the stream
82  virtual const word& name() const;
83 
84  //- Return non-const access to the name of the stream
85  virtual word& name();
86 
87  //- Return next token from stream
88  virtual iIstream& read(token& t)override;
89 
90  //- Read a character
91  virtual iIstream& read(char& c)override;
92 
93  //- Read a word
94  virtual iIstream& read(word& str)override;
95 
96  //- Read a string
97  virtual iIstream& readString(word& str)override;
98 
99  //- Read a int64
100  virtual iIstream& read(int64&) override;
101 
102  //- Read a int32
103  virtual iIstream& read(int32&) override;
104 
105  //- Read a int16
106  virtual iIstream& read(int16&) override;
107 
108  //- Read a int8
109  virtual iIstream& read(int8&) override;
110 
111  //- Read a label
112  virtual iIstream& read(label&) override;
113 
114  //- Read a uint32
115  virtual iIstream& read(uint32&) override;
116 
117  //- Read a uint16
118  virtual iIstream& read(uint16&) override;
119 
120  //- Read a floatScalar
121  virtual iIstream& read(float&) override;
122 
123  //- Read a doubleScalar
124  virtual iIstream& read(double&) override;
125 
126  // - Rewind the stream so that it may be read again
127  virtual void rewind();
128 
129  // - reset the iTstream and make the stream empty
130  virtual void reset();
131 
132  // - const access to token list
133  const tokenList& tokens()const;
134 
135  // - size
136  size_t size()const;
137 
138  // - size
139  size_t numTokens()const;
140 
141  // - append a list of tokens to the end of tokens
142  // and rewind the stream
143  void appendTokens(const tokenList & tList);
144 
145  // - append token to the end of token and rewind the stream
146  void appendToken(const token& t);
147 
148  //- Return flags of output stream
149  ios_base::fmtflags flags() const
150  {
151  return ios_base::fmtflags(0);
152  }
153 
154  //- Set flags of stream
155  ios_base::fmtflags flags(const ios_base::fmtflags)
156  {
157  return ios_base::fmtflags(0);
158  }
159 
160 };
161 
162 #include "helperTstream.hpp"
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 } // End namespace Foam
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 
171 
172 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
173 
174 #endif
175 
176 // ************************************************************************* //
pFlow::iTstream::flags
ios_base::fmtflags flags() const
Definition: iTstream.hpp:149
pFlow::iTstream::tokens
const tokenList & tokens() const
Definition: iTstream.cpp:323
pFlow::List< token >
pFlow::iTstream::flags
ios_base::fmtflags flags(const ios_base::fmtflags)
Definition: iTstream.hpp:155
pFlow::isBeginToken
bool isBeginToken(const token &tok)
pFlow::iTstream::isLastToken
bool isLastToken()
Definition: iTstream.cpp:6
pFlow::token
Definition: token.hpp:42
iIstream.hpp
pFlow::isEndToken
bool isEndToken(const token &tok)
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:59
helperTstream.hpp
pFlow::iTstream::reset
virtual void reset()
Definition: iTstream.cpp:315
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::iTstream::size
size_t size() const
Definition: iTstream.cpp:328
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:55
pFlow::iTstream::rewind
virtual void rewind()
Definition: iTstream.cpp:307
pFlow::iTstream::setFirstToken
void setFirstToken()
Definition: iTstream.cpp:11
pFlow::iTstream::operator=
iTstream & operator=(const iTstream &)=default
pFlow::validTokenForStream
bool validTokenForStream(const token tok)
pFlow
Definition: demComponent.hpp:28
pFlow::iTstream::name_
word name_
Definition: iTstream.hpp:28
pFlow::iTstream::appendTokens
void appendTokens(const tokenList &tList)
Definition: iTstream.cpp:339
tokenList.hpp
pFlow::int16
short int int16
Definition: builtinTypes.hpp:51
pFlow::uint16
unsigned short int uint16
Definition: builtinTypes.hpp:57
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::iTstream::tokenList_
tokenList tokenList_
Definition: iTstream.hpp:31
pFlow::iTstream::iTstream
iTstream(const word &streamName)
Definition: iTstream.cpp:32
pFlow::iTstream::name
virtual const word & name() const
Definition: iTstream.cpp:99
pFlow::List< token >::iterator
typename listType::iterator iterator
Definition: List.hpp:50
pFlow::iTstream::read
virtual iIstream & read(token &t) override
Definition: iTstream.cpp:111
pFlow::iTstream::validate
void validate()
Definition: iTstream.cpp:16
pFlow::iTstream
Definition: iTstream.hpp:21
pFlow::iTstream::appendToken
void appendToken(const token &t)
Definition: iTstream.cpp:352
pFlow::iTstream::~iTstream
virtual ~iTstream()=default
pFlow::iTstream::numTokens
size_t numTokens() const
Definition: iTstream.cpp:333
pFlow::iTstream::currentToken_
tokenList::iterator currentToken_
Definition: iTstream.hpp:34
pFlow::label
std::size_t label
Definition: builtinTypes.hpp:61
pFlow::int8
signed char int8
Definition: builtinTypes.hpp:49
pFlow::iTstream::readString
virtual iIstream & readString(word &str) override
Definition: iTstream.cpp:192