www.cemf.ir
Istream.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 #ifndef __Istream_hpp__
21 #define __Istream_hpp__
22 
23 #include <limits>
24 #include <iostream>
25 
26 #include "iIstream.hpp"
27 
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
29 
30 namespace pFlow
31 {
32 
39 class Istream
40 :
41  public iIstream
42 {
43  //- Private Data
44 
47 
49  std::istream& is_;
50 
51 
53  char nextValid();
54 
56  void readWordToken(token& t);
57 
58 
60  // Handles "$var" and "${var}" forms, permits '/' scoping character.
61  Istream& readVariable(word& str);
62 
64  void operator=(const Istream&) = delete;
65 
66 
67 public:
68 
70 
72  Istream( std::istream& is, const word& streamName, writeFormat wf = ASCII);
73 
75  virtual ~Istream() = default;
76 
77 
79 
81  virtual const word& name() const
82  {
83  return name_;
84  }
85 
87  virtual word& name()
88  {
89  return name_;
90  }
91 
93  virtual ios_base::fmtflags flags() const;
94 
95 
97 
99  Istream& get(char& c);
100 
105  int peek();
106 
108  Istream& getLine(word& str, char delim = '\n');
109 
112  std::streamsize getLine(std::nullptr_t, char delim = '\n');
113 
115  Istream& putback(const char c);
116 
118  virtual iIstream& read(token& t) override;
119 
121  virtual iIstream& read(char& c) override;
122 
124  virtual iIstream& read(word& str) override;
125 
127  virtual iIstream& readString(word& str) override;
128 
130  virtual iIstream& read(int64&) override;
131 
133  virtual iIstream& read(int32&) override;
134 
136  virtual iIstream& read(int8&) override;
137 
139  virtual iIstream& read(uint64&) override;
140 
142  virtual iIstream& read(uint32&) override;
143 
145  virtual iIstream& read(uint8&) override;
146 
148  virtual iIstream& read(float& val) override;
149 
151  virtual iIstream& read(double& val) override;
152 
153  iIstream& read(char* buffer, std::streamsize count) override;
154 
155 
156  size_t findBinaryBlockStart()override;
157 
159  void rewind() override;
160 
161  void seek(size_t pos) override;
162 
164  size_t tell() override;
165 
166 
168  virtual ios_base::fmtflags flags(const ios_base::fmtflags flags);
169 
170 
171 
173  virtual std::istream& stdStream()
174  {
175  return is_;
176  }
177 
179  virtual const std::istream& stdStream() const
180  {
181  return is_;
182  }
183 
184 
185 };
186 
187 
188 }
189 
190 
191 #endif
192 
pFlow::Istream::operator=
void operator=(const Istream &)=delete
No copy assignment.
pFlow::Istream::stdStream
virtual std::istream & stdStream()
Access to underlying std::istream.
Definition: Istream.hpp:173
pFlow::token
Token class based on OpenFOAM stream, with some modifications/simplifications to be tailored to our n...
Definition: token.hpp:44
pFlow::Istream::nextValid
char nextValid()
Get the next valid character.
Definition: Istream.cpp:49
iIstream.hpp
pFlow::Istream::readWordToken
void readWordToken(token &t)
Read a word token.
Definition: Istream.cpp:127
pFlow::Istream::findBinaryBlockStart
size_t findBinaryBlockStart() override
It seek for a character sequence that indicates the start of a binary block char sequence is 255 255 ...
Definition: Istream.cpp:861
pFlow::Istream::tell
size_t tell() override
Return current position indicator.
Definition: Istream.cpp:911
pFlow::Istream::Istream
Istream(std::istream &is, const word &streamName, writeFormat wf=ASCII)
Construct wrapper around std::istream, set stream status.
Definition: Istream.cpp:304
pFlow::IOstream::ASCII
@ ASCII
Definition: IOstream.hpp:61
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::Istream::name
virtual word & name()
Return non-const access to the name of the stream.
Definition: Istream.hpp:87
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:52
pFlow::Istream::name
virtual const word & name() const
Return the name of the stream.
Definition: Istream.hpp:81
pFlow
Definition: demGeometry.hpp:27
pFlow::Istream::seek
void seek(size_t pos) override
Definition: Istream.cpp:902
pFlow::Istream::readString
virtual iIstream & readString(word &str) override
Read a string.
Definition: Istream.cpp:680
pFlow::Istream
Standard input stream for binary and ascii data.
Definition: Istream.hpp:39
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::Istream::readVariable
Istream & readVariable(word &str)
Read a variable name starting with '$'.
Definition: Istream.cpp:141
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::Istream::read
virtual iIstream & read(token &t) override
Return next token from stream.
Definition: Istream.cpp:392
pFlow::Istream::~Istream
virtual ~Istream()=default
Destructor.
pFlow::count
auto count(const Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:26
pFlow::Istream::get
Istream & get(char &c)
Raw, low-level get character function.
Definition: Istream.cpp:325
pFlow::Istream::rewind
void rewind() override
Rewind the stream so that it may be read again.
Definition: Istream.cpp:891
pFlow::Istream::name_
word name_
Stream name.
Definition: Istream.hpp:46
pFlow::uint64
unsigned long long int uint64
Definition: builtinTypes.hpp:58
pFlow::int8
signed char int8
Definition: builtinTypes.hpp:48
pFlow::Istream::peek
int peek()
Raw, low-level peek function.
Definition: Istream.cpp:339
pFlow::IOstream::writeFormat
writeFormat
Definition: IOstream.hpp:59
pFlow::Istream::flags
virtual ios_base::fmtflags flags() const
Return flags of output stream.
Definition: Istream.cpp:927
pFlow::Istream::stdStream
virtual const std::istream & stdStream() const
Const access to underlying std::istream.
Definition: Istream.hpp:179
pFlow::Istream::putback
Istream & putback(const char c)
Raw, low-level putback character function.
Definition: Istream.cpp:375
pFlow::Istream::getLine
Istream & getLine(word &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
Definition: Istream.cpp:345
pFlow::uint8
unsigned char uint8
Definition: builtinTypes.hpp:54
pFlow::Istream::is_
std::istream & is_
Input stream.
Definition: Istream.hpp:49