CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::IInputStream Class Reference

A stream that provides read-only stream functionality. More...

#include <CeresEngine/Foundation/IO/Stream.hpp>

Inheritance diagram for CeresEngine::IInputStream:
CeresEngine::IStream CeresEngine::FilteredInputStream CeresEngine::IDataStream CeresEngine::IResourceInputStream CeresEngine::PipeInputStream CeresEngine::BufferedInputStream CeresEngine::AsyncDataStreamAdapter CeresEngine::FileDataStream CeresEngine::FilteredDataStream CeresEngine::LimitedInputStream CeresEngine::MemoryDataStream CeresEngine::WrappedResourceInputStream CeresEngine::BufferedDataStream

Public Member Functions

virtual bool isReadable () const noexcept
 Checks if the stream is readable.
 
virtual size_t read (void *data, size_t n)
 Reads data from the data stream to a buffer of raw memory data with length n.
 
template<typename T >
size_t read (const MemoryView< T > &memoryView)
 Reads data from the strea into a memory view.
 
template<typename T >
size_t read (const StridedMemoryView< T > &memoryView)
 Reads data from the stream into a strided memory view.
 
Optional< StringreadString ()
 Reads data from the buffer as a C++ String.
 
template<typename T >
requires std::is_trivially_copyable_v<T>
Optional< Tread ()
 Reads a trivially copyable obhect from the stream.
 
virtual bool invalidate ()
 In the stream is buffered, invalidates any buffered read data from the stream.
 
- Public Member Functions inherited from CeresEngine::IStream
 IStream ()=default
 
 IStream (const IStream &) noexcept=delete
 
IStreamoperator= (const IStream &) noexcept=delete
 
 IStream (IStream &&) noexcept=default
 
IStreamoperator= (IStream &&) noexcept=default
 
virtual ~IStream () noexcept=default
 
virtual bool isSeekable (Seek mode=Seek::Start) const noexcept
 Checks if the stream is seekable.
 
virtual void seek (std::streamsize position, Seek mode=Seek::Start)
 Changes the position of the data stream.
 
void skip (const size_t n)
 Skips n bytes from the data stream.
 
virtual bool isTellable () const noexcept
 Checks if the stream knows it's current absolute position.
 
virtual size_t tell ()
 Gets the absolute stream position, in bytes.
 
virtual bool isSizeKnown () const noexcept
 Checks if the stream knows the size of the data.
 
virtual size_t size ()
 Gets the number of bytes available on the stream.
 

Additional Inherited Members

- Public Types inherited from CeresEngine::IStream
enum class  Seek { Start = SEEK_SET , Current = SEEK_CUR , End = SEEK_END }
 An enumeration that describes how a data stream should be seeked. More...
 

Detailed Description

A stream that provides read-only stream functionality.

Member Function Documentation

◆ invalidate()

virtual bool CeresEngine::IInputStream::invalidate ( )
virtual

In the stream is buffered, invalidates any buffered read data from the stream.

Non-buffered streams are free to ignore this method.

Returns
True if the invalidation finished successfully; false otherwise.

Reimplemented in CeresEngine::BufferedInputStream, CeresEngine::BufferedDataStream, CeresEngine::FilteredInputStream, CeresEngine::FilteredDataStream, and CeresEngine::WrappedResourceInputStream.

◆ isReadable()

virtual bool CeresEngine::IInputStream::isReadable ( ) const
inlinevirtualnoexcept

◆ read() [1/4]

template<typename T >
requires std::is_trivially_copyable_v<T>
Optional< T > CeresEngine::IInputStream::read ( )
inline

Reads a trivially copyable obhect from the stream.

Template Parameters
TThe type of object to be read.
Returns
The read object.

◆ read() [2/4]

template<typename T >
size_t CeresEngine::IInputStream::read ( const MemoryView< T > &  memoryView)
inline

Reads data from the strea into a memory view.

Parameters
memoryViewThe memory view to read data to.
Returns
The number of bytes actually read. Can be smaller than n. If 0, indicates that the stream has ended.

◆ read() [3/4]

template<typename T >
size_t CeresEngine::IInputStream::read ( const StridedMemoryView< T > &  memoryView)
inline

Reads data from the stream into a strided memory view.

Data is read sequentially from the stream, but is placed respecting the striding requirements of the view.

Parameters
memoryViewThe memory view to read data to.
Returns
The number of bytes actually read. Can be smaller than n. If 0, indicates that the stream has ended.

◆ read() [4/4]

virtual size_t CeresEngine::IInputStream::read ( void data,
size_t  n 
)
virtual

Reads data from the data stream to a buffer of raw memory data with length n.

Note
This method is only callable if isReadable() returns true.
Parameters
dataThe memory location to which read data should be placed.
nThe maximum number of bytes to be read from the data stream.
Returns
The number of bytes actually read. Can be smaller than n. If 0, indicates that the stream has ended.

Reimplemented in CeresEngine::FilteredInputStream, CeresEngine::FilteredDataStream, CeresEngine::WrappedResourceInputStream, CeresEngine::BufferedInputStream, CeresEngine::BufferedDataStream, CeresEngine::AsyncDataStreamAdapter, CeresEngine::FileDataStream, CeresEngine::MemoryDataStream, CeresEngine::PipeInputStream, and CeresEngine::LimitedInputStream.

◆ readString()

Optional< String > CeresEngine::IInputStream::readString ( )
inline

Reads data from the buffer as a C++ String.


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