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

#include <StdInputStream.h>

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

Public Member Functions

 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
 
virtual std::string acquireName () const
 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.
 

Protected Member Functions

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.
 

Constructor & Destructor Documentation

◆ StdInputStream() [1/3]

ph::StdInputStream::StdInputStream ( )
inlinedefault

◆ StdInputStream() [2/3]

ph::StdInputStream::StdInputStream ( std::unique_ptr< std::istream > stream)
explicit

◆ StdInputStream() [3/3]

ph::StdInputStream::StdInputStream ( StdInputStream && other)
inlinenoexcept

Member Function Documentation

◆ ensureStreamIsGoodForRead()

void ph::StdInputStream::ensureStreamIsGoodForRead ( ) const
protected

Check if the stream has any error.

Exceptions
IOExceptionIf there is any error.

◆ getReasonForError()

std::string ph::StdInputStream::getReasonForError ( ) const
protected

A description for why the stream is not in a good state.

◆ getStream()

std::istream * ph::StdInputStream::getStream ( ) const
inline

◆ isStreamGoodForRead()

bool ph::StdInputStream::isStreamGoodForRead ( ) const
inlineprotected

◆ operator bool()

ph::StdInputStream::operator bool ( ) const
inlineoverridevirtual
Returns
Whether the stream is good for read.

Implements ph::IInputStream.

◆ operator=()

StdInputStream & ph::StdInputStream::operator= ( StdInputStream && rhs)
inlinenoexcept

◆ read()

void ph::StdInputStream::read ( std::size_t numBytes,
std::byte * out_bytes )
overridevirtual

Read specific number of raw bytes in one go. The method does not return before finishing the reading process.

Parameters
numBytesNumber of bytes to read.
[out]out_bytesThe read bytes. Must contain storage for at least numBytes bytes.
Exceptions
IOExceptionIf the read operation failed.

Implements ph::IInputStream.

◆ readSome()

std::size_t ph::StdInputStream::readSome ( std::size_t numBytes,
std::byte * out_bytes )
overridevirtual

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.

Parameters
numBytesMaximum number of bytes to read.
[out]out_bytesThe read bytes. Must contain storage for at least numBytes bytes.
Returns
How many bytes were actually read.
Exceptions
IOExceptionIf the read operation failed.

Reimplemented from ph::IInputStream.

◆ readString()

void ph::StdInputStream::readString ( std::string * out_string,
char delimiter )
overridevirtual

Read a string in one go. Note the EOF is also considered a delimiter (the final one).

Parameters
out_stringThe read string. Does not include the delimiter.
delimiterThe character that denotes the ending of a line.
Exceptions
IOExceptionIf the read operation failed.

Implements ph::IInputStream.

◆ seekGet()

void ph::StdInputStream::seekGet ( std::size_t pos)
overridevirtual

Set the input position of the stream. The unit of the position is defined by the implementation.

Parameters
posThe position to set to.
Exceptions
IOExceptionIf the seeking process failed.

Implements ph::IInputStream.

◆ tellGet()

std::optional< std::size_t > ph::StdInputStream::tellGet ( )
overridevirtual

Get the current input position of the stream. The unit of the position is defined by the implementation.

Returns
Current input position. Empty if the position is unavailable.

Implements ph::IInputStream.


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