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

#include <IInputStream.h>

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

Public Member Functions

virtual void read (std::size_t numBytes, std::byte *out_bytes)=0
 Read specific number of raw bytes in one go. The method does not return before finishing the reading process.
 
virtual void readString (std::string *out_string, char delimiter)=0
 Read a string in one go. Note the EOF is also considered a delimiter (the final one).
 
virtual void seekGet (std::size_t pos)=0
 Set the input position of the stream. The unit of the position is defined by the implementation.
 
virtual std::optional< std::size_t > tellGet ()=0
 Get the current input position of the stream. The unit of the position is defined by the implementation.
 
 operator bool () const override=0
 
virtual std::size_t readSome (std::size_t numBytes, std::byte *out_bytes)
 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.
 
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.
 

Member Function Documentation

◆ operator bool()

ph::IInputStream::operator bool ( ) const
overridepure virtual
Returns
Whether the stream is good for read.

Implements ph::IDataStream.

Implemented in ph::ByteBufferInputStream, and ph::StdInputStream.

◆ read()

virtual void ph::IInputStream::read ( std::size_t numBytes,
std::byte * out_bytes )
pure virtual

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.

Implemented in ph::ByteBufferInputStream, ph::FilteredInputStream, and ph::StdInputStream.

◆ readLine()

void ph::IInputStream::readLine ( std::string * out_string)
inline

Read a line. Equivalent to calling readString(std::string*, char) with '
' as the delimiter.

Parameters
[out]out_stringThe read string. Does not include the new-line character.
Exceptions
IOExceptionIf the read operation failed.

◆ readSome()

std::size_t ph::IInputStream::readSome ( std::size_t numBytes,
std::byte * out_bytes )
inlinevirtual

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 in ph::ByteBufferInputStream, and ph::StdInputStream.

◆ readString()

virtual void ph::IInputStream::readString ( std::string * out_string,
char delimiter )
pure virtual

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.

Implemented in ph::ByteBufferInputStream, and ph::StdInputStream.

◆ seekGet()

virtual void ph::IInputStream::seekGet ( std::size_t pos)
pure virtual

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.

Implemented in ph::ByteBufferInputStream, ph::FilteredInputStream, and ph::StdInputStream.

◆ tellGet()

virtual std::optional< std::size_t > ph::IInputStream::tellGet ( )
pure virtual

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.

Implemented in ph::ByteBufferInputStream, ph::FilteredInputStream, and ph::StdInputStream.


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