# PhasicFlow: Ostream Class Reference
PhasicFlow is an open-source parallel DEM (discrete element method) package for simulating granular flow. It is developed in C++ and can be exectued on both GPU (like CUDA) and CPU.

Ostream Class Reference

Standard output stream for BINARY and ASCII formats. More...

Inheritance diagram for Ostream:
[legend]
Collaboration diagram for Ostream:
[legend]

## Public Member Functions

| Ostream (std::ostream &os, const word &streamName, writeFormat wf=ASCII)
| Construct from components. More...
| Ostream (const Ostream &)=delete
| No copy construct. More...
void | operator= (const Ostream &)=delete
| No copy assignment. More...
virtual const word & | name () const
| Return the name of the stream. More...
virtual word & | name ()
| Return non-const access to the name of the stream. More...
virtual ios_base::fmtflags | flags () const
| Return flags of output stream. More...
bool | write (const token &tok) override
| Write token to stream or otherwise handle it. More...
iOstream & | write (const char c) override
| Write character. More...
iOstream & | write (const char *str) override
| Write character string. More...
iOstream & | write (const word &str) override
| Write word. More...
iOstream & | writeQuoted (const word &str, const bool quoted=true) override
| Write std::string surrounded by quotes. More...
iOstream & | write (const int64 val) override
| Write int64. More...
iOstream & | write (const int32 val) override
| Write int32. More...
iOstream & | write (const int8 val) override
| Write int32. More...
iOstream & | write (const uint64 val) override
| Write uint64. More...
iOstream & | write (const uint32 val) override
| Write uint32. More...
iOstream & | write (const uint8 val) override
| Write uint8. More...
iOstream & | write (const float val) override
| Write float. More...
iOstream & | write (const double val) override
| Write double. More...
iOstream & | write (const size_t val) override
| Write size_t. More...
iOstream & | write (const char *binaryData, std::streamsize count) override
| Write a block of binray data. More...
iOstream & | writeBinaryBlockFlag () override
| Write the flag to indicate the start of a binary block. More...
void | seek (size_t pos) override
void | indent () override
| Add indentation characters. More...
ios_base::fmtflags | flags (const ios_base::fmtflags f) override
| Set stream flags. More...
void | startOfBinaryStreaming () override
| Add a new line and flush stream. More...
void | endOfBinaryStreaming () override
| Reach end of file add a new line and flush stream. More...
void | flush () override
| Flush stream. More...
void | endl () override
| Add newline and flush stream. More...
char | fill () const override
| Get the current padding character. More...
char | fill (const char fillch) override
| Set padding character for formatted field up to field width. More...
int | width () const override
| Get width of output field. More...
int | width (const int w) override
| Set width of output field. More...
int | precision () const override
| Get precision of output field. More...
int | precision (const int p) override
| Set precision of output field return old precision. More...
virtual std::ostream & | stdStream ()
| Access to underlying std::ostream. More...
virtual const std::ostream & | stdStream () const
| Const access to underlying std::ostream. More...
Public Member Functions inherited from iOstream
| iOstream ()
| Default. More...
| iOstream (writeFormat wF)
| Construct from writeFormat. More...
| iOstream (const iOstream &)=default
| Copy construct. More...
virtual | ~iOstream ()=default
| Destructor. More...
unsigned short | indentSize () const
| Return indent level. More...
unsigned short & | indentSize ()
| Access to indent size. More...
unsigned short | indentLevel () const
| Return indent level. More...
unsigned short & | indentLevel ()
| Access to indent level. More...
void | incrIndent ()
| Increment the indent level. More...
void | decrIndent ()
| Decrement the indent level. More...
virtual iOstream & | beginBlock (const word &kw)
| Write begin block group with a name Increments indentation, adds newline. More...
virtual iOstream & | beginBlock ()
| Write begin block group without a name Increments indentation, adds newline. More...
virtual iOstream & | endBlock ()
| Write end block group Decrements indentation, adds newline. More...
virtual iOstream & | beginList ()
| Write begin list "(". More...
virtual iOstream & | beginList (const word &kw)
| Write begin list with keyword "kw (". More...
virtual iOstream & | endList ()
| Write end list ")". More...
virtual iOstream & | beginSquare ()
| Write begin list "[". More...
virtual iOstream & | beginSquare (const word &kw)
| Write begin list with keyword "kw [". More...
virtual iOstream & | endSquare ()
| Write end list "]". More...
virtual iOstream & | endEntry ()
| Write end entry (';') followed by newline. More...
virtual iOstream & | newLine ()
| Write a newLine to stream. More...
virtual iOstream & | space (int32 n=1)
| Write space to stream. More...
virtual iOstream & | writeWordKeyword (const word &kw)
| Write the keyword followed by an appropriate indentation. More...
template<class T >
iOstream & | writeWordEntry (const word &key, const T &value)
| Write a keyword/value entry. More...
iOstream & | operator() () const
| Return a non-const reference to const iOstream Needed for write functions where the stream argument is temporary: e.g. More...
Public Member Functions inherited from IOstream
| IOstream ()
| Default. More...
| IOstream (writeFormat wF)
| Construct and set write format. More...
| IOstream (const IOstream &)=default
| Copy. More...
virtual | ~IOstream ()=default
| Destructor. More...
virtual bool | check (const char *operation) const
| Check IOstream status for given operation. More...
bool | fatalCheck (const char *operation) const
| Check IOstream status for given operation. More...
bool | opened () const
| Return true if stream has been opened. More...
bool | closed () const
| Return true if stream is closed. More...
bool | isBinary () const
| Return true if stream format is binray. More...
bool | good () const
| Return true if next operation might succeed. More...
bool | eof () const
| Return true if end of input seen. More...
bool | fail () const
| Return true if next operation will fail. More...
bool | bad () const
| Return true if stream is corrupted. More...
| operator bool () const
| Return true if the stream has not failed. More...
bool | operator! () const
| Return true if the stream has failed. More...
int32 | lineNumber () const
| Const access to the current stream line number. More...
int32 & | lineNumber ()
| Non-const access to the current stream line number. More...
int32 | lineNumber (const int32 num)
| Set the stream line number return the previous value. More...
void | setEof ()
| Set stream to have reached eof. More...
void | setFail ()
| Set stream to have failed. More...
void | setBad ()
| Set stream to be bad. More...
ios_base::fmtflags | setf (const ios_base::fmtflags f)
| Set flags of stream. More...
ios_base::fmtflags | setf (const ios_base::fmtflags f, const ios_base::fmtflags mask)
| Set flags of given field of stream. More...
void | unsetf (const ios_base::fmtflags f)
| Unset flags of stream. More...

## Private Attributes

word | name_
| Stream name. More...
std::ostream & | os_
| Output stream. More...

## Additional Inherited Members

Public Types inherited from IOstream
enum | streamAccess : char { CLOSED = 0, OPENED }
enum | writeFormat : char { ASCII = 0, BINARY }
Static Public Member Functions inherited from IOstream
static unsigned int | defaultPrecision ()
| Return the default precision. More...
static unsigned int | defaultPrecision (unsigned int prec)
| Reset the default precision return the previous value. More...
Static Public Attributes inherited from IOstream
static unsigned int | precision_ = 6
| Default precision, only works for ASCII. More...
Protected Member Functions inherited from IOstream
void | setOpened ()
| Set stream opened. More...
void | setClosed ()
| Set stream closed. More...
void | setState (ios_base::iostate state)
| Set stream state. More...
void | setWriteFormat (writeFormat wF)
void | setGood ()
| Set stream to be good. More...
Protected Attributes inherited from iOstream
unsigned short | indentSize_ = 4
| Number of spaces per indent level. More...
unsigned short | indentLevel_ = 0
| Current indent level. More...
Protected Attributes inherited from IOstream
streamAccess | openClosed_
| Is stream open or closed. More...
writeFormat | writeFormat_ = ASCII
| write format More...
ios_base::iostate | ioState_
| state More...
int32 | lineNumber_
| The file line. More...
Static Protected Attributes inherited from iOstream
static constexpr const unsigned short | entryIndentation_ = 16
| Indentation of the entry from the start of the keyword. More...
Static Protected Attributes inherited from IOstream
static word | staticName_
| Name for any generic stream - normally treat as readonly. More...

## Detailed Description

Standard output stream for BINARY and ASCII formats.

It is based on OpenFOAM stream, with some modifications/simplifications to be tailored to our needs

Definition at line 39 of file Ostream.hpp.

## Constructor & Destructor Documentation

## Ostream() [1/2]

Ostream | ( | std::ostream & | os,
|  | const word & | streamName,
|  | writeFormat | wf = `ASCII`
| ) |  |

Construct from components.

- Constructors

Definition at line 27 of file Ostream.cpp.

## Ostream() [2/2]

Ostream | ( | const Ostream & |  | ) |

delete

No copy construct.

## Member Function Documentation

## operator=()

void operator= | ( | const Ostream & |  | ) |

delete

No copy assignment.

## name() [1/2]

virtual const word& name | ( |  | ) | const

inlinevirtual

Return the name of the stream.

Reimplemented from IOstream.

Definition at line 71 of file Ostream.hpp.

References Ostream::name_.

Referenced by fileSeries::writeOneBaseName().

Here is the caller graph for this function:

## name() [2/2]

virtual word& name | ( |  | ) |

inlinevirtual

Return non-const access to the name of the stream.

Reimplemented from IOstream.

Definition at line 77 of file Ostream.hpp.

References Ostream::name_.

## flags() [1/2]

std::ios_base::fmtflags flags | ( |  | ) | const

virtual

Return flags of output stream.

Implements IOstream.

Definition at line 298 of file Ostream.cpp.

## write() [1/14]

bool write | ( | const token & | tok | ) |

overridevirtual

Write token to stream or otherwise handle it.

return false if the token type was not handled by this method

Implements iOstream.

Definition at line 51 of file Ostream.cpp.

References token::type(), token::wordToken(), and Ostream::writeQuoted().

Referenced by processorOstream::checkForPrefix(), processorOstream::setColor(), masterOstream::write(), and processorOstream::write().

Here is the call graph for this function:
Here is the caller graph for this function:

## write() [2/14]

pFlow::iOstream & write | ( | const char | c | ) |

overridevirtual

Write character.

Implements iOstream.

Definition at line 78 of file Ostream.cpp.

References token::NL.

## write() [3/14]

pFlow::iOstream & write | ( | const char * | str | ) |

overridevirtual

Write character string.

Implements iOstream.

Definition at line 90 of file Ostream.cpp.

References pFlow::countChar(), and token::NL.

Here is the call graph for this function:

## write() [4/14]

pFlow::iOstream & write | ( | const word & | str | ) |

overridevirtual

Write word.

Implements iOstream.

Definition at line 99 of file Ostream.cpp.

## writeQuoted()

pFlow::iOstream & writeQuoted | ( | const word & | str,
|  | const bool | quoted = `true`
| ) |  |

overridevirtual

Write std::string surrounded by quotes.

Optional write without quotes.

Implements iOstream.

Definition at line 108 of file Ostream.cpp.

References token::BEGIN_STRING, pFlow::countChar(), token::END_STRING, and token::NL.

Referenced by Ostream::write(), masterOstream::writeQuoted(), and processorOstream::writeQuoted().

Here is the call graph for this function:
Here is the caller graph for this function:

## write() [5/14]

pFlow::iOstream & write | ( | const int64 | val | ) |

overridevirtual

Write int64.

Implements iOstream.

Definition at line 167 of file Ostream.cpp.

## write() [6/14]

pFlow::iOstream & write | ( | const int32 | val | ) |

overridevirtual

Write int32.

Implements iOstream.

Definition at line 175 of file Ostream.cpp.

## write() [7/14]

pFlow::iOstream & write | ( | const int8 | val | ) |

overridevirtual

Write int32.

Implements iOstream.

Definition at line 182 of file Ostream.cpp.

## write() [8/14]

pFlow::iOstream & write | ( | const uint64 | val | ) |

overridevirtual

Write uint64.

Implements iOstream.

Definition at line 189 of file Ostream.cpp.

## write() [9/14]

pFlow::iOstream & write | ( | const uint32 | val | ) |

overridevirtual

Write uint32.

Implements iOstream.

Definition at line 196 of file Ostream.cpp.

## write() [10/14]

pFlow::iOstream & write | ( | const uint8 | val | ) |

overridevirtual

Write uint8.

Implements iOstream.

Definition at line 203 of file Ostream.cpp.

## write() [11/14]

pFlow::iOstream & write | ( | const float | val | ) |

overridevirtual

Write float.

Implements iOstream.

Definition at line 210 of file Ostream.cpp.

## write() [12/14]

pFlow::iOstream & write | ( | const double | val | ) |

overridevirtual

Write double.

Implements iOstream.

Definition at line 218 of file Ostream.cpp.

## write() [13/14]

pFlow::iOstream & write | ( | const size_t | val | ) |

overridevirtual

Write size_t.

Implements iOstream.

Definition at line 225 of file Ostream.cpp.

## write() [14/14]

pFlow::iOstream & write | ( | const char * | binaryData,
|  | std::streamsize | count
| ) |  |

overridevirtual

Write a block of binray data.

Implements iOstream.

Definition at line 233 of file Ostream.cpp.

References token::BEGIN_LIST, pFlow::count(), token::END_LIST, fatalErrorInFunction, and fatalExit.

Here is the call graph for this function:

## writeBinaryBlockFlag()

pFlow::iOstream & writeBinaryBlockFlag | ( |  | ) |

overridevirtual

Write the flag to indicate the start of a binary block.

Reimplemented from iOstream.

Definition at line 252 of file Ostream.cpp.

## seek()

void seek | ( | size_t | pos | ) |

overridevirtual

Implements iOstream.

Definition at line 261 of file Ostream.cpp.

## indent()

void indent | ( |  | ) |

overridevirtual

Add indentation characters.

Implements iOstream.

Definition at line 266 of file Ostream.cpp.

Referenced by masterOstream::indent(), and processorOstream::indent().

Here is the caller graph for this function:

## flags() [2/2]

std::ios_base::fmtflags flags | ( | const ios_base::fmtflags | f | ) |

overridevirtual

Set stream flags.

Implements IOstream.

Definition at line 304 of file Ostream.cpp.

## startOfBinaryStreaming()

void startOfBinaryStreaming | ( |  | ) |

overridevirtual

Add a new line and flush stream.

Implements iOstream.

Definition at line 274 of file Ostream.cpp.

References pFlow::endl(), and pFlow::flush().

Here is the call graph for this function:

## endOfBinaryStreaming()

void endOfBinaryStreaming | ( |  | ) |

overridevirtual

Reach end of file add a new line and flush stream.

Implements iOstream.

Definition at line 280 of file Ostream.cpp.

References pFlow::endl(), and pFlow::flush().

Here is the call graph for this function:

## flush()

void flush | ( |  | ) |

overridevirtual

Flush stream.

Implements iOstream.

Definition at line 287 of file Ostream.cpp.

## endl()

void endl | ( |  | ) |

overridevirtual

Add newline and flush stream.

Implements iOstream.

Definition at line 292 of file Ostream.cpp.

## fill() [1/2]

char fill | ( |  | ) | const

overridevirtual

Get the current padding character.

Implements iOstream.

Definition at line 312 of file Ostream.cpp.

## fill() [2/2]

char fill | ( | const char | fillch | ) |

overridevirtual

Set padding character for formatted field up to field width.

Returns
  previous padding character

Implements iOstream.

Definition at line 318 of file Ostream.cpp.

## width() [1/2]

int width | ( |  | ) | const

overridevirtual

Get width of output field.

Implements iOstream.

Definition at line 324 of file Ostream.cpp.

## width() [2/2]

int width | ( | const int | w | ) |

overridevirtual

Set width of output field.

Returns
  previous width

Implements iOstream.

Definition at line 330 of file Ostream.cpp.

## precision() [1/2]

int precision | ( |  | ) | const

overridevirtual

Get precision of output field.

Implements iOstream.

Definition at line 336 of file Ostream.cpp.

Referenced by stlFile::write().

Here is the caller graph for this function:

## precision() [2/2]

int precision | ( | const int | p | ) |

overridevirtual

Set precision of output field return old precision.

Implements iOstream.

Definition at line 342 of file Ostream.cpp.

## stdStream() [1/2]

virtual std::ostream& stdStream | ( |  | ) |

inlinevirtual

Access to underlying std::ostream.

Definition at line 177 of file Ostream.hpp.

References Ostream::os_.

Referenced by pFlow::PFtoVTK::addIntPointField(), pFlow::PFtoVTK::addRealPointField(), pFlow::PFtoVTK::addRealx3PointField(), and pFlow::PFtoVTK::addUndstrcuturedGridField().

Here is the caller graph for this function:

## stdStream() [2/2]

virtual const std::ostream& stdStream | ( |  | ) | const

inlinevirtual

Const access to underlying std::ostream.

Definition at line 183 of file Ostream.hpp.

References Ostream::os_.

## Member Data Documentation

## name_

word name_

private

Stream name.

Definition at line 48 of file Ostream.hpp.

Referenced by Ostream::name().

## os_

std::ostream& os_

private

Output stream.

Definition at line 51 of file Ostream.hpp.

Referenced by Ostream::stdStream().

The documentation for this class was generated from the following files:

- src/phasicFlow/streams/Stream/Ostream.hpp
- src/phasicFlow/streams/Stream/Ostream.cpp