# PhasicFlow: src/phasicFlow/streams/TStream/oTstream.cpp Source File

oTstream.cpp
Go to the documentation of this file.
#include "oTstream.hpp"
#include "error.hpp"
pFlow::oTstream::oTstream
(
const word& nm
)
:
iOstream(),
name_(nm),
tokenList_()
{
setOpened();
setGood();
}
pFlow::oTstream::oTstream
(
const oTstream& src
)
:
iOstream(src),
name_(src.name_),
tokenList_(src.tokenList_)
{
setOpened();
setGood();
}
const pFlow::tokenList& pFlow::oTstream::tokens()const
{
return tokenList_;
}
pFlow::tokenList& pFlow::oTstream::tokens()
{
return tokenList_;
}
bool pFlow::oTstream::write(const token& tok)
{
if (tok.good())
{
append(tok);
return true;
}
return false;
}
pFlow::iOstream& pFlow::oTstream::write(const char c)
{
if (!std::isspace(c) && std::isprint(c))
{
// Should generally work, but need to verify corner cases
append(token(token::punctuationToken(c)));
}
return *this;
}
pFlow::iOstream& pFlow::oTstream::write(const char* str)
{
append(token(word(str)));
return *this;
}
pFlow::iOstream& pFlow::oTstream::write(const word& str)
{
append(token(str)); // tokenType::WORD
return *this;
}
pFlow::iOstream& pFlow::oTstream::writeQuoted
(
const word& str,
const bool quoted
)
{
append(token(str, lineNumber(),quoted)); // tokenType::STRING/WORD
return *this;
}
pFlow::iOstream& pFlow::oTstream::write(const int64 val)
{
append(token(val)); // tokenType::INT64
return *this;
}
pFlow::iOstream& pFlow::oTstream::write(const int32 val)
{
append(token(val)); // tokenType::INT64
return *this;
}
pFlow::iOstream& pFlow::oTstream::write(const label val)
{
append(token(static_cast< int64 >(val))); // tokenType::INT64
return *this;
}
pFlow::iOstream& pFlow::oTstream::write(const uint32 val)
{
append(token(static_cast< int64 >(val))); // tokenType::INT64
return *this;
}
pFlow::iOstream& pFlow::oTstream::write(const uint16 val)
{
append(token(static_cast< int64 >(val))); // tokenType::INT64
return *this;
}
pFlow::iOstream& pFlow::oTstream::write(const float val)
{
append(token(val)); // tokenType::FLOAT
return *this;
}
pFlow::iOstream& pFlow::oTstream::write(const double val)
{
append(token(val)); // tokenType::DOUBLE
return *this;
}
void pFlow::oTstream::append(const token& tok)
{
if( validTokenForStream(tok) )
tokenList_.push_back(tok);
}
void pFlow::oTstream::append(const tokenList& tLisk)
{
for(auto& e:tLisk)
{
append(e);
}
}
void pFlow::oTstream::reset()
{
this->rewind();
}
//- Rewind the output stream
void pFlow::oTstream::rewind()
{
tokenList_.clear();
setGood();
}
// ************************************************************************* //
pFlow::oTstream
Definition: oTstream.hpp:23
pFlow::List< token >
pFlow::token
Definition: token.hpp:42
pFlow::oTstream::name_
word name_
Definition: oTstream.hpp:31
pFlow::token::punctuationToken
punctuationToken
Definition: token.hpp:81
pFlow::token::good
bool good() const
Definition: tokenI.hpp:372
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:59
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::oTstream::append
virtual void append(const token &tok)
Definition: oTstream.cpp:153
oTstream.hpp
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:55
pFlow::oTstream::reset
void reset()
Definition: oTstream.cpp:168
pFlow::oTstream::tokens
const tokenList & tokens() const
Definition: oTstream.cpp:32
pFlow::validTokenForStream
bool validTokenForStream(const token tok)
pFlow::oTstream::oTstream
oTstream(const word &nm)
Definition: oTstream.cpp:6
pFlow::uint16
unsigned short int uint16
Definition: builtinTypes.hpp:57
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::oTstream::rewind
virtual void rewind()
Definition: oTstream.cpp:174
pFlow::oTstream::writeQuoted
virtual iOstream & writeQuoted(const std::string &str, const bool quoted=true)
Definition: oTstream.cpp:86
pFlow::label
std::size_t label
Definition: builtinTypes.hpp:61
pFlow::oTstream::write
virtual bool write(const token &tok)
Definition: oTstream.cpp:44
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::oTstream::tokenList_
tokenList tokenList_
Definition: oTstream.hpp:34
error.hpp