www.cemf.ir
Ostream.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 // based on OpenFOAM stream, with some modifications/simplifications
21 // to be tailored to our needs
22 
23 #ifndef __Ostream_hpp__
24 #define __Ostream_hpp__
25 
26 #include "iOstream.hpp"
27 #include <iostream>
28 
29 
30 namespace pFlow
31 {
32 
39 class Ostream
40 :
41  public iOstream
42 {
43 private:
44 
45  // - private data members
46 
49 
51  std::ostream& os_;
52 
53 
54 public:
55 
57 
59  Ostream ( std::ostream& os, const word& streamName, writeFormat wf = ASCII);
60 
62  Ostream(const Ostream&) = delete;
63 
65  void operator=(const Ostream&) = delete;
66 
67 
69 
71  virtual const word& name() const
72  {
73  return name_;
74  }
75 
77  virtual word& name()
78  {
79  return name_;
80  }
81 
83  virtual ios_base::fmtflags flags() const;
84 
85 
88  bool write(const token& tok)override;
89 
91  iOstream& write(const char c)override;
92 
94  iOstream& write(const char* str)override;
95 
97  iOstream& write(const word& str)override;
98 
101  iOstream& writeQuoted ( const word& str, const bool quoted=true ) override;
102 
104  iOstream& write(const int64 val) override;
105 
107  iOstream& write(const int32 val) override;
108 
110  iOstream& write(const int8 val) override;
111 
113  iOstream& write(const uint64 val) override;
114 
116  iOstream& write(const uint32 val) override;
117 
119  iOstream& write(const uint8 val) override;
120 
122  iOstream& write(const float val) override;
123 
125  iOstream& write(const double val) override;
126 
128  iOstream& write(const size_t val) override;
129 
131  iOstream& write(const char* binaryData, std::streamsize count) override;
132 
133  iOstream& writeBinaryBlockFlag() override;
134 
135  void seek(size_t pos) override;
136 
138  void indent() override;
139 
141  ios_base::fmtflags flags(const ios_base::fmtflags f) override;
142 
144  void startOfBinaryStreaming() override;
145 
147  void endOfBinaryStreaming() override ;
148 
150  void flush() override;
151 
153  void endl() override;
154 
156  char fill() const override;
157 
160  char fill(const char fillch) override;
161 
163  int width() const override;
164 
167  int width(const int w) override;
168 
170  int precision() const override;
171 
174  int precision(const int p) override;
175 
177  virtual std::ostream& stdStream()
178  {
179  return os_;
180  }
181 
183  virtual const std::ostream& stdStream() const
184  {
185  return os_;
186  }
187 
188 };
189 
190 
191 } // pFlow
192 
193 
194 #endif //__Ostream_hpp__
195 
196 
pFlow::Ostream::writeQuoted
iOstream & writeQuoted(const word &str, const bool quoted=true) override
Write std::string surrounded by quotes.
Definition: Ostream.cpp:108
pFlow::Ostream::flags
virtual ios_base::fmtflags flags() const
Return flags of output stream.
Definition: Ostream.cpp:298
pFlow::Ostream::flush
void flush() override
Flush stream.
Definition: Ostream.cpp:287
pFlow::Ostream::operator=
void operator=(const Ostream &)=delete
No copy assignment.
pFlow::token
Token class based on OpenFOAM stream, with some modifications/simplifications to be tailored to our n...
Definition: token.hpp:44
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::Ostream::indent
void indent() override
Add indentation characters.
Definition: Ostream.cpp:266
pFlow::Ostream::width
int width() const override
Get width of output field.
Definition: Ostream.cpp:324
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:52
pFlow::Ostream::endOfBinaryStreaming
void endOfBinaryStreaming() override
Reach end of file add a new line and flush stream.
Definition: Ostream.cpp:280
pFlow::Ostream::name_
word name_
Stream name.
Definition: Ostream.hpp:48
pFlow::Ostream::fill
char fill() const override
Get the current padding character.
Definition: Ostream.cpp:312
pFlow::Ostream::precision
int precision() const override
Get precision of output field.
Definition: Ostream.cpp:336
pFlow::Ostream::endl
void endl() override
Add newline and flush stream.
Definition: Ostream.cpp:292
pFlow
Definition: demGeometry.hpp:27
pFlow::Ostream::name
virtual word & name()
Return non-const access to the name of the stream.
Definition: Ostream.hpp:77
pFlow::Ostream::name
virtual const word & name() const
Return the name of the stream.
Definition: Ostream.hpp:71
pFlow::Ostream::startOfBinaryStreaming
void startOfBinaryStreaming() override
Add a new line and flush stream.
Definition: Ostream.cpp:274
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::Ostream::writeBinaryBlockFlag
iOstream & writeBinaryBlockFlag() override
Write the flag to indicate the start of a binary block.
Definition: Ostream.cpp:252
pFlow::Ostream::seek
void seek(size_t pos) override
Definition: Ostream.cpp:261
pFlow::count
auto count(const Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:26
pFlow::Ostream::Ostream
Ostream(std::ostream &os, const word &streamName, writeFormat wf=ASCII)
Construct from components.
Definition: Ostream.cpp:27
pFlow::Ostream::stdStream
virtual std::ostream & stdStream()
Access to underlying std::ostream.
Definition: Ostream.hpp:177
pFlow::Ostream::os_
std::ostream & os_
Output stream.
Definition: Ostream.hpp:51
pFlow::uint64
unsigned long long int uint64
Definition: builtinTypes.hpp:58
pFlow::int8
signed char int8
Definition: builtinTypes.hpp:48
iOstream.hpp
pFlow::IOstream::writeFormat
writeFormat
Definition: IOstream.hpp:59
pFlow::Ostream::write
bool write(const token &tok) override
Write token to stream or otherwise handle it.
Definition: Ostream.cpp:51
pFlow::Ostream::stdStream
virtual const std::ostream & stdStream() const
Const access to underlying std::ostream.
Definition: Ostream.hpp:183
pFlow::Ostream
Standard output stream for BINARY and ASCII formats.
Definition: Ostream.hpp:39
pFlow::uint8
unsigned char uint8
Definition: builtinTypes.hpp:54
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59