Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ph::FormattedTextOutputStream Class Reference

Write text with basic auto formatting applied. More...

#include <FormattedTextOutputStream.h>

Inheritance diagram for ph::FormattedTextOutputStream:
ph::StdOutputStream ph::IOutputStream ph::IDataStream

Public Member Functions

 FormattedTextOutputStream ()=default
 
 FormattedTextOutputStream (const Path &filePath)
 Output to a file as stream.
 
 FormattedTextOutputStream (std::string initialStrContent)
 Output to a string as stream.
 
 FormattedTextOutputStream (FormattedTextOutputStream &&other)=default
 
std::string acquireName () const override
 Access to the stream's name. This method is not meant to be used in a high performance context, unless otherwise stated by the overridder. Stream name is not always available.
 
void writeChar (char ch)
 Write a single char to the stream.
 
void writeNewLine ()
 Write newline to the stream.
 
template<typename... Args>
void writeString (std::format_string< Args... > strFormat, Args &&... args)
 Write formatted string to the stream.
 
std::string getString () const
 Get the string that was written.
 
FormattedTextOutputStreamoperator= (FormattedTextOutputStream &&rhs)=default
 
void writeString (std::string_view str) override
 Write a string in one go.
 
- Public Member Functions inherited from ph::StdOutputStream
 StdOutputStream ()=default
 
 StdOutputStream (std::unique_ptr< std::ostream > stream)
 
 StdOutputStream (StdOutputStream &&other) noexcept
 
void write (std::size_t numBytes, const std::byte *bytes) override
 Write data in the form of raw bytes in one go. The method does not return before finishing the writing process.
 
void writeString (std::string_view str) override
 Write a string in one go.
 
void seekPut (std::size_t pos) override
 Set the output position of the stream. The unit of the position is defined by the implementation.
 
std::optional< std::size_t > tellPut () override
 Get the current output position of the stream. The unit of the position is defined by the implementation.
 
 operator bool () const override
 
std::ostream * getStream () const
 
StdOutputStreamoperator= (StdOutputStream &&rhs) noexcept
 
- Public Member Functions inherited from ph::IOutputStream
virtual std::size_t writeSome (std::size_t numBytes, const std::byte *bytes)
 Write some data in the form of raw bytes. The method may return before finish writing all bytes. In such case, the method returns how many bytes were actually written.
 
void writeLine (std::string_view str)
 Write a line. Equivalent to calling writeString(std::string_view) with '
' as an extra character.
 
- Public Member Functions inherited from ph::IDataStream
virtual ~IDataStream ()=default
 

Additional Inherited Members

- Protected Member Functions inherited from ph::StdOutputStream
bool isStreamGoodForWrite () const
 
void ensureStreamIsGoodForWrite () const
 Check if the stream has any error.
 
std::string getReasonForError () const
 A description for why the stream is not in a good state.
 

Detailed Description

Write text with basic auto formatting applied.

Constructor & Destructor Documentation

◆ FormattedTextOutputStream() [1/4]

ph::FormattedTextOutputStream::FormattedTextOutputStream ( )
inlinedefault

◆ FormattedTextOutputStream() [2/4]

ph::FormattedTextOutputStream::FormattedTextOutputStream ( const Path & filePath)
explicit

Output to a file as stream.

Parameters
filePathThe file to open as stream.

◆ FormattedTextOutputStream() [3/4]

ph::FormattedTextOutputStream::FormattedTextOutputStream ( std::string initialStrContent)
explicit

Output to a string as stream.

Parameters
initialStrContentThe initial content of the stream. This string will be copied.

◆ FormattedTextOutputStream() [4/4]

ph::FormattedTextOutputStream::FormattedTextOutputStream ( FormattedTextOutputStream && other)
inlinedefault

Member Function Documentation

◆ acquireName()

std::string ph::FormattedTextOutputStream::acquireName ( ) const
overridevirtual

Access to the stream's name. This method is not meant to be used in a high performance context, unless otherwise stated by the overridder. Stream name is not always available.

Reimplemented from ph::IDataStream.

◆ getString()

std::string ph::FormattedTextOutputStream::getString ( ) const

Get the string that was written.

Exceptions
IOExceptionIf the stream is not a string stream.

◆ operator=()

FormattedTextOutputStream & ph::FormattedTextOutputStream::operator= ( FormattedTextOutputStream && rhs)
inlinedefault

◆ writeChar()

void ph::FormattedTextOutputStream::writeChar ( char ch)

Write a single char to the stream.

Parameters
chThe character to write.

◆ writeNewLine()

void ph::FormattedTextOutputStream::writeNewLine ( )

Write newline to the stream.

◆ writeString() [1/2]

template<typename... Args>
void ph::FormattedTextOutputStream::writeString ( std::format_string< Args... > strFormat,
Args &&... args )
inline

Write formatted string to the stream.

Parameters
strFormatThe format string. Accepts the same syntax as the standard formatting library.
argsThe arguments to be formatted.

◆ writeString() [2/2]

void ph::StdOutputStream::writeString ( std::string_view str)
overridevirtual

Write a string in one go.

Parameters
strThe written string.
Exceptions
IOExceptionIf the write operation failed.

Implements ph::IOutputStream.


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