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

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

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

Inheritance diagram for CeresEngine::IOutputStream:
CeresEngine::IStream CeresEngine::FilteredOutputStream CeresEngine::IDataStream CeresEngine::IResourceOutputStream CeresEngine::PipeOutputStream CeresEngine::BufferedOutputStream CeresEngine::AsyncDataStreamAdapter CeresEngine::FileDataStream CeresEngine::FilteredDataStream CeresEngine::LimitedInputStream CeresEngine::MemoryDataStream CeresEngine::WrappedResourceOutputStream CeresEngine::BufferedDataStream

Public Member Functions

virtual bool isWritable () const noexcept
 Checks if the stream is writable.
 
virtual size_t write (const void *data, size_t n)
 Writes data to the data stream from a buffer of raw memory data with length n.
 
template<typename T >
size_t write (const MemoryView< const T > &memoryView)
 Writes data from a memory view to the stream.
 
template<typename T >
size_t write (const StridedMemoryView< const T > &memoryView)
 Writes data from a strided memory view to the stream.
 
size_t writeString (const StringView string)
 Writes a string to the data stream.
 
template<typename T >
requires std::is_trivially_copyable_v<T>
bool write (T value)
 Writes a trivially copyable object to the stream.
 
virtual bool flush ()
 In the stream is buffered, invalidates any buffered write data from to 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 write-only stream functionality.

Member Function Documentation

◆ flush()

virtual bool CeresEngine::IOutputStream::flush ( )
virtual

In the stream is buffered, invalidates any buffered write data from to stream.

Non-buffered streams are free to ignore this method.

Returns
True if the flushing finished successfully; false otherwise.

Reimplemented in CeresEngine::BufferedOutputStream, CeresEngine::BufferedDataStream, CeresEngine::FilteredOutputStream, CeresEngine::FilteredDataStream, and CeresEngine::WrappedResourceOutputStream.

◆ isWritable()

virtual bool CeresEngine::IOutputStream::isWritable ( ) const
inlinevirtualnoexcept

◆ write() [1/4]

template<typename T >
size_t CeresEngine::IOutputStream::write ( const MemoryView< const T > &  memoryView)
inline

Writes data from a memory view to the stream.

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.

◆ write() [2/4]

template<typename T >
size_t CeresEngine::IOutputStream::write ( const StridedMemoryView< const T > &  memoryView)
inline

Writes data from a strided memory view to the stream.

Data is written sequentially from the stream, but is read 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.

◆ write() [3/4]

virtual size_t CeresEngine::IOutputStream::write ( const void data,
size_t  n 
)
virtual

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

Note
This method is only callable if isWritable() returns true.
Parameters
dataThe memory location to which written data should be copied from.
nThe maximum number of bytes to be write to the data stream.
Returns
The number of bytes actually written. Can be smaller than n, in that case the write operation must be repeated to ensure that all data was written. If 0, indicates that the stream has ended.

Reimplemented in CeresEngine::FilteredOutputStream, CeresEngine::FilteredDataStream, CeresEngine::WrappedResourceOutputStream, CeresEngine::FilteredOutputStream, CeresEngine::BufferedOutputStream, CeresEngine::BufferedDataStream, CeresEngine::AsyncDataStreamAdapter, CeresEngine::FileDataStream, CeresEngine::MemoryDataStream, and CeresEngine::PipeOutputStream.

◆ write() [4/4]

template<typename T >
requires std::is_trivially_copyable_v<T>
bool CeresEngine::IOutputStream::write ( T  value)
inline

Writes a trivially copyable object to the stream.

Template Parameters
TThe trivially copyable object type to be written.
Parameters
valueThe trivially copyable object value to be written.

◆ writeString()

size_t CeresEngine::IOutputStream::writeString ( const StringView  string)
inline

Writes a string to the data stream.

Parameters
stringThe string to be written.
Returns
The number of bytes written.

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