# PhasicFlow: src/phasicFlow/streams/iStream/iOstream.cpp Source File

iOstream.cpp
Go to the documentation of this file.
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
#include "iOstream.hpp"
#include "token.hpp"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void pFlow::iOstream::decrIndent()
{
if (!indentLevel_)
{
std::cerr
<< "iOstream::decrIndent() : attempt to decrement 0 indent level\n";
}
else
{
--indentLevel_;
}
}
pFlow::iOstream& pFlow::iOstream::writeWordKeyword(const word& kw)
{
indent();
writeQuoted(kw, false);
if (indentSize_ <= 1)
{
write(char(token::SPACE));
return *this;
}
int32 nSpaces = entryIndentation_ - int32(kw.size());
// Could also increment by indentSize_ ...
if (nSpaces < 1)
{
nSpaces = 1;
}
while (nSpaces--)
{
write(char(token::SPACE));
}
return *this;
}
pFlow::iOstream& pFlow::iOstream::beginBlock(const word& kw)
{
indent(); write(kw); newLine();
beginBlock();
return *this;
}
pFlow::iOstream& pFlow::iOstream::beginBlock()
{
indent(); write(char(token::BEGIN_BLOCK)); newLine();
incrIndent();
return *this;
}
pFlow::iOstream& pFlow::iOstream::endBlock()
{
decrIndent();
indent(); write(char(token::END_BLOCK)); newLine();
return *this;
}
pFlow::iOstream& pFlow::iOstream::endEntry()
{
write(char(token::END_STATEMENT)); newLine();
return *this;
}
//- Write a newLine to stream
pFlow::iOstream& pFlow::iOstream::newLine()
{
write(char(token::NL));
return *this;
}
pFlow::iOstream& pFlow::iOstream::space
(
int32 n
)
{
for(int32 i=0; i<n; i++)
{
write(char(token::SPACE));
}
return *this;
}
pFlow::iOstream& pFlow::iOstream::beginList
(
)
{
write(char(token::BEGIN_LIST));
return *this;
}
pFlow::iOstream& pFlow::iOstream::beginList
(
const word& kw
)
{
writeWordKeyword(kw); beginList();
return *this;
}
pFlow::iOstream& pFlow::iOstream::endList
(
)
{
write(char(token::END_LIST));
return *this;
}
pFlow::iOstream& pFlow::iOstream::beginSquare
(
)
{
write(char(token::BEGIN_SQR));
return *this;
}
pFlow::iOstream& pFlow::iOstream::beginSquare
(
const word& kw
)
{
writeWordKeyword(kw); beginSquare();
return *this;
}
pFlow::iOstream& pFlow::iOstream::endSquare
(
)
{
write(char(token::END_SQR));
return *this;
}
// ************************************************************************* //
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