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

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

#include <FormattedTextInputStream.h>

Inheritance diagram for ph::FormattedTextInputStream:
ph::StdInputStream ph::IInputStream ph::IDataStream

Public Member Functions

 FormattedTextInputStream ()=default
 
 FormattedTextInputStream (const Path &textFilePath)
 Take a file as stream.
 
 FormattedTextInputStream (std::string textString)
 Take a string as stream.
 
 FormattedTextInputStream (FormattedTextInputStream &&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 readAll (std::string *out_allText)
 Read all remaining text. All contents are preserved. All original input contents are preserved (including any line endings such as CRLF, LF), no matter what platform the stream is operating on.
 
void readAllTightly (std::string *out_allText)
 Read all remaining text without any whitespaces.
 
FormattedTextInputStreamoperator= (FormattedTextInputStream &&rhs)=default
 
- Public Member Functions inherited from ph::StdInputStream
 StdInputStream ()=default
 
 StdInputStream (std::unique_ptr< std::istream > stream)
 
 StdInputStream (StdInputStream &&other) noexcept
 
void read (std::size_t numBytes, std::byte *out_bytes) override
 Read specific number of raw bytes in one go. The method does not return before finishing the reading process.
 
void readString (std::string *out_string, char delimiter) override
 Read a string in one go. Note the EOF is also considered a delimiter (the final one).
 
void seekGet (std::size_t pos) override
 Set the input position of the stream. The unit of the position is defined by the implementation.
 
std::optional< std::size_t > tellGet () override
 Get the current input position of the stream. The unit of the position is defined by the implementation.
 
 operator bool () const override
 
std::size_t readSome (std::size_t numBytes, std::byte *out_bytes) override
 Read some data in the form of raw bytes. The method may return before finish reading all bytes. In such case, the method returns how many bytes were actually read.
 
std::istream * getStream () const
 
StdInputStreamoperator= (StdInputStream &&rhs) noexcept
 
- Public Member Functions inherited from ph::IInputStream
void readLine (std::string *out_string)
 Read a line. Equivalent to calling readString(std::string*, char) with '
' as the delimiter.
 
- Public Member Functions inherited from ph::IDataStream
virtual ~IDataStream ()=default
 

Protected Member Functions

 FormattedTextInputStream (std::unique_ptr< std::istream > stream, std::string streamName)
 
- Protected Member Functions inherited from ph::StdInputStream
bool isStreamGoodForRead () const
 
void ensureStreamIsGoodForRead () 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

Read text with basic auto formatting applied.

Constructor & Destructor Documentation

◆ FormattedTextInputStream() [1/5]

ph::FormattedTextInputStream::FormattedTextInputStream ( )
inlinedefault

◆ FormattedTextInputStream() [2/5]

ph::FormattedTextInputStream::FormattedTextInputStream ( const Path & textFilePath)
explicit

Take a file as stream.

Parameters
textFilePathThe file to open as stream.

◆ FormattedTextInputStream() [3/5]

ph::FormattedTextInputStream::FormattedTextInputStream ( std::string textString)
explicit

Take a string as stream.

Parameters
textStringThe string to read as stream. This string will be copied.

◆ FormattedTextInputStream() [4/5]

ph::FormattedTextInputStream::FormattedTextInputStream ( FormattedTextInputStream && other)
inlinedefault

◆ FormattedTextInputStream() [5/5]

ph::FormattedTextInputStream::FormattedTextInputStream ( std::unique_ptr< std::istream > stream,
std::string streamName )
protected
Parameters
streamA standard formatted input stream.

Member Function Documentation

◆ acquireName()

std::string ph::FormattedTextInputStream::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.

◆ operator=()

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

◆ readAll()

void ph::FormattedTextInputStream::readAll ( std::string * out_allText)

Read all remaining text. All contents are preserved. All original input contents are preserved (including any line endings such as CRLF, LF), no matter what platform the stream is operating on.

Parameters
[out]out_allTextBuffer to store all text from this stream.

◆ readAllTightly()

void ph::FormattedTextInputStream::readAllTightly ( std::string * out_allText)

Read all remaining text without any whitespaces.

Parameters
[out]out_allTextBuffer to store all text from this stream with whitespaces removed.

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