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

A helper data stream that allows filtering the results of another data stream. More...

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

Inheritance diagram for CeresEngine::FilteredInputStream:
CeresEngine::IInputStream CeresEngine::IStream CeresEngine::BufferedInputStream

Public Member Functions

 FilteredInputStream (InputStream &&inputStream)
 Creates a new filtered data stream.
 
 FilteredInputStream (FilteredInputStream &&) noexcept=default
 
 ~FilteredInputStream () override=default
 
InputStreamgetInputStream () noexcept
 The data stream being filtered.
 
const InputStreamgetInputStream () const noexcept
 The data stream being filtered.
 
bool isSeekable (const Seek mode=Seek::Start) const noexcept override
 Checks if the stream is seekable.
 
void seek (const std::streamsize position, const Seek mode=Seek::Start) override
 Changes the position of the data stream.
 
bool isTellable () const noexcept override
 Checks if the stream knows it's current absolute position.
 
size_t tell () override
 Gets the absolute stream position, in bytes.
 
bool isSizeKnown () const noexcept override
 Checks if the stream knows the size of the data.
 
size_t size () override
 Gets the number of bytes available on the stream.
 
bool isReadable () const noexcept override
 Checks if the stream is readable.
 
size_t read (void *data, const size_t n) override
 Reads data from the data stream to a buffer of raw memory data with length n.
 
bool invalidate () override
 In the stream is buffered, invalidates any buffered read data from the stream.
 
- Public Member Functions inherited from CeresEngine::IInputStream
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.
 
- 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
 
void skip (const size_t n)
 Skips n bytes from the data stream.
 

Protected Attributes

InputStream mInputStream
 The data stream being filtered.
 

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 helper data stream that allows filtering the results of another data stream.

Constructor & Destructor Documentation

◆ FilteredInputStream() [1/2]

CeresEngine::FilteredInputStream::FilteredInputStream ( InputStream &&  inputStream)
inlineexplicit

Creates a new filtered data stream.

◆ FilteredInputStream() [2/2]

CeresEngine::FilteredInputStream::FilteredInputStream ( FilteredInputStream &&  )
defaultnoexcept

◆ ~FilteredInputStream()

CeresEngine::FilteredInputStream::~FilteredInputStream ( )
overridedefault

Member Function Documentation

◆ getInputStream() [1/2]

const InputStream & CeresEngine::FilteredInputStream::getInputStream ( ) const
inlinenoexcept

The data stream being filtered.

◆ getInputStream() [2/2]

InputStream & CeresEngine::FilteredInputStream::getInputStream ( )
inlinenoexcept

The data stream being filtered.

◆ invalidate()

bool CeresEngine::FilteredInputStream::invalidate ( )
inlineoverridevirtual

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 from CeresEngine::IInputStream.

◆ isReadable()

bool CeresEngine::FilteredInputStream::isReadable ( ) const
inlineoverridevirtualnoexcept

Checks if the stream is readable.

If this method returns true, read() is safe to be called on this stream.

Reimplemented from CeresEngine::IInputStream.

◆ isSeekable()

bool CeresEngine::FilteredInputStream::isSeekable ( const Seek  mode = Seek::Start) const
inlineoverridevirtualnoexcept

Checks if the stream is seekable.

If this method returns true, seek() is safe to be called on this stream.

Reimplemented from CeresEngine::IStream.

◆ isSizeKnown()

bool CeresEngine::FilteredInputStream::isSizeKnown ( ) const
inlineoverridevirtualnoexcept

Checks if the stream knows the size of the data.

If this method returns true, size() is safe to be called on this stream.

Reimplemented from CeresEngine::IStream.

◆ isTellable()

bool CeresEngine::FilteredInputStream::isTellable ( ) const
inlineoverridevirtualnoexcept

Checks if the stream knows it's current absolute position.

If this method returns true, tell() is safe to be called on this stream.

Reimplemented from CeresEngine::IStream.

◆ read()

size_t CeresEngine::FilteredInputStream::read ( void data,
const size_t  n 
)
inlineoverridevirtual

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 from CeresEngine::IInputStream.

◆ seek()

void CeresEngine::FilteredInputStream::seek ( const std::streamsize  position,
const Seek  mode = Seek::Start 
)
inlineoverridevirtual

Changes the position of the data stream.

Note
This method is only callable if isSeekable() returns true.
Parameters
positionThe position to set the data stream to.
modeThe mode to change the data stream position.

Reimplemented from CeresEngine::IStream.

◆ size()

size_t CeresEngine::FilteredInputStream::size ( )
inlineoverridevirtual

Gets the number of bytes available on the stream.

Note
This method is only callable if isSizeKnown() returns true.

Reimplemented from CeresEngine::IStream.

◆ tell()

size_t CeresEngine::FilteredInputStream::tell ( )
inlineoverridevirtual

Gets the absolute stream position, in bytes.

Note
This method is only callable if isTellable() returns true.

Reimplemented from CeresEngine::IStream.

Member Data Documentation

◆ mInputStream

InputStream CeresEngine::FilteredInputStream::mInputStream
protected

The data stream being filtered.


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