www.cemf.ir
processorOstream.cpp
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 
21 #include <cstring>
22 
23 #include "processorOstream.hpp"
24 #include "token.hpp"
25 
26 
28 (
29  std::ostream& os,
30  const word& streamName
31 )
32 :
33  Ostream(os, streamName, writeFormat::ASCII)
34 {}
35 
36 
38 {
40  Ostream::write(c);
41 
42  if (c == token::NL)
43  {
44  printPrefix_ = true;
45  }
46 
47  return *this;
48 
49 }
50 
51 
53 {
54  checkForPrefix();
55  Ostream::write(str);
56 
57  size_t len = std::strlen(str);
58  if (len && str[len-1] == token::NL)
59  {
60  printPrefix_ = true;
61  }
62 
63  return *this;
64 }
65 
66 
68 {
69  checkForPrefix();
70  return Ostream::write(str);
71 }
72 
73 
75 (
76  const word& str,
77  const bool quoted
78 )
79 {
80  checkForPrefix();
81  return Ostream::writeQuoted(str, quoted);
82 }
83 
84 
85 
87 {
88  checkForPrefix();
89  return Ostream::write(val);
90 }
91 
92 
94 {
95  checkForPrefix();
96  return Ostream::write(val);
97 }
98 
99 
101 {
102  checkForPrefix();
103  return Ostream::write(val);
104 }
105 
107 {
108  checkForPrefix();
109  return Ostream::write(val);
110 }
111 
113 {
114  checkForPrefix();
115  return Ostream::write(val);
116 }
117 
119 {
120  checkForPrefix();
121  return Ostream::write(val);
122 }
123 
125 {
126  checkForPrefix();
127  return Ostream::write(val);
128 }
129 
130 
132 {
133  checkForPrefix();
134  return Ostream::write(val);
135 }
136 
138 {
139  checkForPrefix();
140  return Ostream::write(val);
141 }
142 
144 (
145  const char* binaryData,
146  std::streamsize count
147 )
148 {
149  checkForPrefix();
150  return Ostream::write(binaryData, count);
151 }
152 
153 
155 {
156  checkForPrefix();
157  Ostream::indent();
158 }
159 
161 {
162  Ostream::write(colorCode);
163  return *this;
164 }
pFlow::Ostream::writeQuoted
iOstream & writeQuoted(const word &str, const bool quoted=true) override
Write std::string surrounded by quotes.
Definition: Ostream.cpp:108
pFlow::processorOstream::write
bool write(const token &tok)
Write token to stream or otherwise handle it.
Definition: processorOstream.hpp:90
pFlow::processorOstream::setColor
processorOstream & setColor(const char *colorCode)
Definition: processorOstream.cpp:160
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
token.hpp
pFlow::processorOstream
Output stream for MPI parallel run, when we need to know which the processor number in the output lin...
Definition: processorOstream.hpp:36
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::Ostream::indent
void indent() override
Add indentation characters.
Definition: Ostream.cpp:266
pFlow::token::NL
@ NL
Tab [isspace].
Definition: token.hpp:88
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:52
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::processorOstream::checkForPrefix
void checkForPrefix()
Output the prefix if required.
Definition: processorOstream.hpp:50
pFlow::processorOstream::processorOstream
processorOstream(std::ostream &os, const word &streamName)
From components.
Definition: processorOstream.cpp:28
pFlow::count
auto count(const Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:26
pFlow::processorOstream::indent
void indent() override
Add indentation characters.
Definition: processorOstream.cpp:154
pFlow::processorOstream::writeQuoted
iOstream & writeQuoted(const word &str, const bool quoted=true) override
Write std::string surrounded by quotes.
Definition: processorOstream.cpp:75
pFlow::processorOstream::printPrefix_
bool printPrefix_
Print prefix?
Definition: processorOstream.hpp:43
pFlow::uint64
unsigned long long int uint64
Definition: builtinTypes.hpp:58
pFlow::int8
signed char int8
Definition: builtinTypes.hpp:48
pFlow::Ostream::write
bool write(const token &tok) override
Write token to stream or otherwise handle it.
Definition: Ostream.cpp:51
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
processorOstream.hpp