iOstream.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 
22 #include "iOstream.hpp"
23 #include "token.hpp"
24 
25 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
26 
28 {
29  if (!indentLevel_)
30  {
31  std::cerr
32  << "iOstream::decrIndent() : attempt to decrement 0 indent level\n";
33  }
34  else
35  {
36  --indentLevel_;
37  }
38 }
39 
40 
42 {
43 
44  indent();
45  writeQuoted(kw, false);
46 
47  if (indentSize_ <= 1)
48  {
49  write(char(token::SPACE));
50  return *this;
51  }
52 
53  int32 nSpaces = entryIndentation_ - int32(kw.size());
54 
55  // Could also increment by indentSize_ ...
56  if (nSpaces < 1)
57  {
58  nSpaces = 1;
59  }
60 
61  while (nSpaces--)
62  {
63  write(char(token::SPACE));
64  }
65 
66  return *this;
67 }
68 
69 
71 {
72  indent(); write(kw); newLine();
73  beginBlock();
74 
75  return *this;
76 }
77 
78 
80 {
81  indent(); write(char(token::BEGIN_BLOCK)); newLine();
82  incrIndent();
83 
84  return *this;
85 }
86 
87 
89 {
90  decrIndent();
91  indent(); write(char(token::END_BLOCK)); newLine();
92 
93  return *this;
94 }
95 
96 
98 {
99  write(char(token::END_STATEMENT)); newLine();
100 
101  return *this;
102 }
103 
104 //- Write a newLine to stream
106 {
107  write(char(token::NL));
108  return *this;
109 }
110 
112 (
113  int32 n
114 )
115 {
116  for(int32 i=0; i<n; i++)
117  {
118  write(char(token::SPACE));
119  }
120  return *this;
121 }
122 
123 
125 (
126 )
127 {
128  write(char(token::BEGIN_LIST));
129  return *this;
130 }
131 
132 
134 (
135  const word& kw
136 )
137 {
138  writeWordKeyword(kw); beginList();
139  return *this;
140 }
141 
142 
144 (
145 )
146 {
147  write(char(token::END_LIST));
148  return *this;
149 }
150 
151 
153 (
154 )
155 {
156  write(char(token::BEGIN_SQR));
157  return *this;
158 }
159 
160 
162 (
163  const word& kw
164 )
165 {
166  writeWordKeyword(kw); beginSquare();
167  return *this;
168 }
169 
170 
172 (
173 )
174 {
175  write(char(token::END_SQR));
176  return *this;
177 }
178 
179 
180 // ************************************************************************* //
pFlow::iOstream::endBlock
virtual iOstream & endBlock()
Definition: iOstream.cpp:88
pFlow::iOstream::newLine
virtual iOstream & newLine()
Definition: iOstream.cpp:105
pFlow::token::END_BLOCK
@ END_BLOCK
End block [isseparator].
Definition: token.hpp:94
token.hpp
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::token::NL
@ NL
Newline [isspace].
Definition: token.hpp:86
pFlow::decrIndent
iOstream & decrIndent(iOstream &os)
Definition: iOstream.hpp:296
pFlow::token::BEGIN_BLOCK
@ BEGIN_BLOCK
Begin block [isseparator].
Definition: token.hpp:93
pFlow::token::SPACE
@ SPACE
Space [isspace].
Definition: token.hpp:84
pFlow::indent
iOstream & indent(iOstream &os)
Definition: iOstream.hpp:282
n
int32 n
Definition: NBSCrossLoop.hpp:24
pFlow::iOstream::decrIndent
void decrIndent()
Definition: iOstream.cpp:27
pFlow::incrIndent
iOstream & incrIndent(iOstream &os)
Definition: iOstream.hpp:289
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::iOstream::beginSquare
virtual iOstream & beginSquare()
Definition: iOstream.cpp:153
pFlow::iOstream::endEntry
virtual iOstream & endEntry()
Definition: iOstream.cpp:97
pFlow::token::END_LIST
@ END_LIST
End list [isseparator].
Definition: token.hpp:90
pFlow::token::END_STATEMENT
@ END_STATEMENT
End entry [isseparator].
Definition: token.hpp:88
pFlow::token::BEGIN_LIST
@ BEGIN_LIST
Begin list [isseparator].
Definition: token.hpp:89
pFlow::iOstream::endSquare
virtual iOstream & endSquare()
Definition: iOstream.cpp:172
pFlow::token::BEGIN_SQR
@ BEGIN_SQR
Begin dimensions [isseparator].
Definition: token.hpp:91
pFlow::iOstream::endList
virtual iOstream & endList()
Definition: iOstream.cpp:144
pFlow::beginBlock
iOstream & beginBlock(iOstream &os)
Definition: iOstream.hpp:321
pFlow::iOstream::beginList
virtual iOstream & beginList()
Definition: iOstream.cpp:125
iOstream.hpp
pFlow::iOstream::space
virtual iOstream & space(int32 n=1)
Definition: iOstream.cpp:112
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::token::END_SQR
@ END_SQR
End dimensions [isseparator].
Definition: token.hpp:92
pFlow::iOstream::writeWordKeyword
virtual iOstream & writeWordKeyword(const word &kw)
Definition: iOstream.cpp:41
pFlow::iOstream::beginBlock
virtual iOstream & beginBlock()
Definition: iOstream.cpp:79
pFlow::iOstream::indentLevel_
unsigned short indentLevel_
Definition: iOstream.hpp:68