WSF
wsf::coverage::TextOutputWriter Class Reference

#include <WsfCoverageTextOutputWriter.hpp>

Public Member Functions

 TextOutputWriter ()=default
 TextOutputWriter (const TextOutputWriter &aOther)
virtual ~TextOutputWriter ()=default
virtual TextOutputWriterClone () const
virtual bool OpenStream (const std::string &aFileName)
 Open the file stream to write to the given aFileName.
virtual void CloseStream ()
 Close the file stream.
virtual std::ostream & GetStream ()
 Return the underlying stream object.
virtual bool CreateContainingFolder (const std::string &aPath) const
bool OpenFile (const std::string &aOutputDir, const std::string &aFileName)
int GetPrecision () const
 Get the field precision.
int GetWidth () const
 Get the field width.
bool IsRightJustified () const
 Return if output should be right justified.
bool IsFixedFormat () const
 Return if output should be in fixed format.
void SetPrecision (int aPrecision)
 Set the field precision.
void SetWidth (int aWidth)
 Set the field width.
void SetRightJustified (bool aRightJustify)
void SetFixedFormat (bool aFixedFormat)
template<typename T>
void WriteFieldWidth (const T &aValue, int aWidth, bool aEndLine=false)
template<typename T>
void WriteField (const T &aValue, bool aEndLine=false)
void SetStreamJustify ()
 Set the configured justification on the stream.
void SetStreamFormat ()
 Set the configured format on the stream.

Static Public Attributes

static constexpr int cMIN_PRECISION {6}
static constexpr int cDEFAULT_PRECISION {6}
static constexpr int cMAX_PRECISION {20}
static constexpr int cMIN_WIDTH {9}
static constexpr int cDEFAULT_WIDTH {15}
static constexpr int cMAX_WIDTH {23}

Detailed Description

Class defining the capability to write field formatted output into a stream.

The output produced by this class is designed around making readable CSV format. Clients can set the format, justification, precision, and width of the fields written by this object.

Constructor & Destructor Documentation

◆ TextOutputWriter() [1/2]

wsf::coverage::TextOutputWriter::TextOutputWriter ( )
default

◆ TextOutputWriter() [2/2]

wsf::coverage::TextOutputWriter::TextOutputWriter ( const TextOutputWriter & aOther)

References TextOutputWriter().

◆ ~TextOutputWriter()

virtual wsf::coverage::TextOutputWriter::~TextOutputWriter ( )
virtualdefault

Member Function Documentation

◆ Clone()

virtual TextOutputWriter * wsf::coverage::TextOutputWriter::Clone ( ) const
inlinevirtual

References TextOutputWriter().

◆ CloseStream()

void wsf::coverage::TextOutputWriter::CloseStream ( )
virtual

◆ CreateContainingFolder()

bool wsf::coverage::TextOutputWriter::CreateContainingFolder ( const std::string & aPath) const
virtual

Create the path up to the containing folder.

This will ensure that all folders exist in the given aPath. This method returns true if the folder is successfully created, or if the folder already exists.

Parameters
aPath- The folder whose existence is to be ensured.
Returns
- true is successful; false otherwise.

Referenced by wsf::coverage::OverlayOutput::Write(), wsf::coverage::RawDataOutput::Write(), and wsf::coverage::Grid::WriteGridDataFile().

◆ GetPrecision()

int wsf::coverage::TextOutputWriter::GetPrecision ( ) const
inline

Get the field precision.

◆ GetStream()

virtual std::ostream & wsf::coverage::TextOutputWriter::GetStream ( )
inlinevirtual

Return the underlying stream object.

Referenced by SetStreamFormat(), SetStreamJustify(), and WriteFieldWidth().

◆ GetWidth()

int wsf::coverage::TextOutputWriter::GetWidth ( ) const
inline

Get the field width.

◆ IsFixedFormat()

bool wsf::coverage::TextOutputWriter::IsFixedFormat ( ) const
inline

Return if output should be in fixed format.

◆ IsRightJustified()

bool wsf::coverage::TextOutputWriter::IsRightJustified ( ) const
inline

Return if output should be right justified.

◆ OpenFile()

bool wsf::coverage::TextOutputWriter::OpenFile ( const std::string & aOutputDir,
const std::string & aFileName )

Template pattern method for opening the file stream.

This will open the file for writing with the given aFileName in the given aOutputDir. Subclasses are free to ignore the arguments.

Open the file.

This is a template pattern method that calls into the appropriate members of the interface in the correct order.

References OpenStream().

Referenced by wsf::coverage::OverlayOutput::Write(), and wsf::coverage::RawDataOutput::Write().

◆ OpenStream()

bool wsf::coverage::TextOutputWriter::OpenStream ( const std::string & aFileName)
virtual

Open the file stream to write to the given aFileName.

Referenced by OpenFile(), and wsf::coverage::Grid::WriteGridDataFile().

◆ SetFixedFormat()

void wsf::coverage::TextOutputWriter::SetFixedFormat ( bool aFixedFormat)
inline

Set if output should be in fixed format.

Parameters
aFixedFormat- true if data should be in fixed format; false for scientific notation format.

Referenced by wsf::coverage::OverlayOutput::Write(), and wsf::coverage::RawDataOutput::Write().

◆ SetPrecision()

void wsf::coverage::TextOutputWriter::SetPrecision ( int aPrecision)
inline

Set the field precision.

Referenced by wsf::coverage::Grid::WriteGridDataFile().

◆ SetRightJustified()

void wsf::coverage::TextOutputWriter::SetRightJustified ( bool aRightJustify)
inline

Set if output is to be right justified.

Parameters
aRightJustify- true if data should be right justified; false for left justification.

Referenced by wsf::coverage::OverlayOutput::Write(), and wsf::coverage::RawDataOutput::Write().

◆ SetStreamFormat()

void wsf::coverage::TextOutputWriter::SetStreamFormat ( )

◆ SetStreamJustify()

void wsf::coverage::TextOutputWriter::SetStreamJustify ( )

Set the configured justification on the stream.

References GetStream().

Referenced by wsf::coverage::OverlayOutput::Write(), wsf::coverage::RawDataOutput::Write(), and wsf::coverage::Grid::WriteGridDataFile().

◆ SetWidth()

void wsf::coverage::TextOutputWriter::SetWidth ( int aWidth)
inline

◆ WriteField()

template<typename T>
void wsf::coverage::TextOutputWriter::WriteField ( const T & aValue,
bool aEndLine = false )
inline

Write a value to the stream.

This will write the given value to the field, respecting the options set on this object. A comma is added after the field if aEndLine is false, otherwise a newline is appended.

Parameters
aValue- The value to add to the stream.
aEndLine- true if this is to be the last field on a line.

References WriteFieldWidth().

Referenced by wsf::coverage::Grid::WriteGridDataFile().

◆ WriteFieldWidth()

template<typename T>
void wsf::coverage::TextOutputWriter::WriteFieldWidth ( const T & aValue,
int aWidth,
bool aEndLine = false )
inline

Write a value to the stream, overriding the field width.

This will write the given value to the field, respecting the options set on this object, but overriding the field width with the given aWidth. A comma is added after the field if aEndLine is false, otherwise a newline is appended.

Parameters
aValue- The value to add to the stream.
aWidth- The width of the field to stream.
aEndLine- true if this is to be the last field on a line.

References GetStream().

Referenced by WriteField().

Member Data Documentation

◆ cDEFAULT_PRECISION

int wsf::coverage::TextOutputWriter::cDEFAULT_PRECISION {6}
staticconstexpr

◆ cDEFAULT_WIDTH

int wsf::coverage::TextOutputWriter::cDEFAULT_WIDTH {15}
staticconstexpr

◆ cMAX_PRECISION

int wsf::coverage::TextOutputWriter::cMAX_PRECISION {20}
staticconstexpr

◆ cMAX_WIDTH

int wsf::coverage::TextOutputWriter::cMAX_WIDTH {23}
staticconstexpr

◆ cMIN_PRECISION

int wsf::coverage::TextOutputWriter::cMIN_PRECISION {6}
staticconstexpr

◆ cMIN_WIDTH

int wsf::coverage::TextOutputWriter::cMIN_WIDTH {9}
staticconstexpr

The documentation for this class was generated from the following files:
Copyrights Multiple, All Rights Reserved