CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::DataStream Class Referencefinal

General purpose class used for encapsulating the reading and writing of data from and to various sources using a common interface. More...

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

Inheritance diagram for CeresEngine::DataStream:
CeresEngine::Poly< IDataStream, kStreamPolySize, false, IStream >

Public Member Functions

 DataStream (AsyncDataStream asyncDataStream)
 
 DataStream (const FilePath &path)
 Creates a new file stream by opening the file at the given path.
 
 DataStream (size_t size)
 Allocates a new chunk of memory and wraps it in a stream.
 
 DataStream (const ByteMemoryView &buffer, bool freeOnClose=false)
 Wrap an existing memory chunk in a stream.
 
 Poly (const Poly &other)
 Creates a new Poly by copying an existing one.
 
 Poly (Poly &&other) noexcept
 Creates a new Poly by moving an existing one.
 
 Poly (std::nullptr_t) noexcept
 Creates a new empty Poly.
 
template<typename TT = T>
requires (std::is_default_constructible_v<TT>)
 Poly () noexcept
 Creates a new empty Poly.
 
template<typename TT , typename... Args>
requires (std::is_convertible_v<TT*, T*>&& std::is_constructible_v<TT, Args&&...>)
 Poly (std::in_place_type_t< TT >, Args &&... args)
 Creates a new Poly that holds a newly constructed object of type TT.
 
template<typename... Args>
requires (std::is_constructible_v<T, Args...>)
 Poly (Args &&... args)
 Creates a new Poly that holds a newly constructed object of type T.
 
template<typename TT >
requires (std::is_convertible_v<TT*, T*> && Copyable)
 Poly (TT object)
 Creates a new Poly that holds a copy constructed object of type TT.
 
template<typename TT >
requires (std::is_convertible_v<TT*, T*> && !Copyable)
 Poly (TT &&object)
 Creates a new Poly that holds a copy constructed object of type TT.
 
 Poly (T *const instance)
 Creates a new Poly instance by referencing another.
 
template<typename U >
requires (Copyable)
 Poly (const Poly< U, SmallSize, Copyable, BaseType > &other)
 Creates a new Poly instance by referencing another.
 
template<typename U >
 Poly (Poly< U, SmallSize, Copyable, BaseType > &&other)
 Creates a new Poly instance by referencing another.
 
- Public Member Functions inherited from CeresEngine::Poly< IDataStream, kStreamPolySize, false, IStream >
 Poly (const Poly &other)
 Creates a new Poly by copying an existing one.
 
 Poly (Poly &&other) noexcept
 Creates a new Poly by moving an existing one.
 
 Poly (std::nullptr_t) noexcept
 Creates a new empty Poly.
 
 Poly () noexcept
 Creates a new empty Poly.
 
 Poly (std::in_place_type_t< TT >, Args &&... args)
 Creates a new Poly that holds a newly constructed object of type TT.
 
 Poly (Args &&... args)
 Creates a new Poly that holds a newly constructed object of type T.
 
 Poly (TT object)
 Creates a new Poly that holds a copy constructed object of type TT.
 
 Poly (TT &&object)
 Creates a new Poly that holds a copy constructed object of type TT.
 
 Poly (IDataStream *const instance)
 Creates a new Poly instance by referencing another.
 
 Poly (const Poly< U, SmallSize, Copyable, IStream > &other)
 Creates a new Poly instance by referencing another.
 
 Poly (Poly< U, SmallSize, Copyable, IStream > &&other)
 Creates a new Poly instance by referencing another.
 
bool isCopyable () const noexcept
 Checks if the Poly copy constructor can be safely called.
 
Polyoperator= (const Poly &other)
 Assigns a Poly by copying an existing one.
 
Polyoperator= (Poly &&other)
 Assigns a Poly by moving an existing one.
 
Polyoperator= (std::nullptr_t) noexcept
 Assigns the Poly a nullptr value.
 
bool isMovable () const noexcept
 Checks if the Poly move constructor can be safely called.
 
 ~Poly () noexcept
 Destroys the Poly and destroys the object is present.
 
TT & emplace (Args &&... args)
 Emplace a new object of type TT into the Poly.
 
TT & emplace (TT &&instance)
 
bool valid () const
 Checks if the pointer has a valid object stored in it.
 
bool empty () const
 Checks if the pointer has a valid object stored in it.
 
 operator bool () const
 Checks if the pointer has a valid object stored in it.
 
IDataStreamget ()
 
const IDataStreamget () const
 
IDataStreamoperator-> ()
 
const IDataStreamoperator-> () const
 
const IDataStreamoperator* () const &
 
IDataStreamoperator* () &
 &
 
IDataStream && operator* () &&
 &
 
const std::type_info & getTypeID () const
 
bool is () const
 Checks if the hold object is of type TT.
 
TT * being ()
 Safely casts the hold type to TT.
 
const TT * being () const
 Safely casts the hold type to TT.
 
TT & as () &
 Casts the hold type to TT.
 
TT && as () &&
 Casts the hold type to TT.
 
const TT & as () const &
 Casts the hold type to TT.
 

Static Public Member Functions

static size_t copy (InputStream input, OutputStream output, size_t buffer=16 *1024)
 Copies data by reading data from the input stream and writes it to output stream.
 

Additional Inherited Members

- Static Public Attributes inherited from CeresEngine::Poly< IDataStream, kStreamPolySize, false, IStream >
static constexpr bool isSmall
 true if an object of type U will not cause an allocation.
 

Detailed Description

General purpose class used for encapsulating the reading and writing of data from and to various sources using a common interface.

Constructor & Destructor Documentation

◆ DataStream() [1/4]

CeresEngine::DataStream::DataStream ( AsyncDataStream  asyncDataStream)
explicit

◆ DataStream() [2/4]

CeresEngine::DataStream::DataStream ( const FilePath path)
explicit

Creates a new file stream by opening the file at the given path.

Parameters
pathThe file path to be open

◆ DataStream() [3/4]

CeresEngine::DataStream::DataStream ( size_t  size)
explicit

Allocates a new chunk of memory and wraps it in a stream.

Parameters
sizeSize of the memory chunk in bytes.

◆ DataStream() [4/4]

CeresEngine::DataStream::DataStream ( const ByteMemoryView buffer,
bool  freeOnClose = false 
)
explicit

Wrap an existing memory chunk in a stream.

Parameters
bufferMemory to wrap the data stream around.
freeOnCloseShould the memory buffer be freed when the data stream goes out of scope.

Member Function Documentation

◆ copy()

static size_t CeresEngine::DataStream::copy ( InputStream  input,
OutputStream  output,
size_t  buffer = 16 *1024 
)
static

Copies data by reading data from the input stream and writes it to output stream.

Parameters
inputThe stream to read data from.
outputThe stream to write data to.
bufferThe length of the buffer to copy.
Returns
The number of bytes copied between the streams.

◆ Poly() [1/11]

template<typename TT = T>
requires (std::is_default_constructible_v<TT>)
CeresEngine::Poly< T, SmallSize, Copyable, BaseType >::Poly ( )
inlinenoexcept

Creates a new empty Poly.

◆ Poly() [2/11]

template<typename... Args>
requires (std::is_constructible_v<T, Args...>)
CeresEngine::Poly< T, SmallSize, Copyable, BaseType >::Poly ( Args &&...  args)
inlineexplicit

Creates a new Poly that holds a newly constructed object of type T.

Template Parameters
Argsthe object constructor argument types
Parameters
argsThe object constructor arguments

◆ Poly() [3/11]

CeresEngine::Poly< T, SmallSize, Copyable, BaseType >::Poly ( const Poly other)
inline

Creates a new Poly by copying an existing one.

Parameters
otherThe instance to copy from

◆ Poly() [4/11]

template<typename U >
requires (Copyable)
CeresEngine::Poly< T, SmallSize, Copyable, BaseType >::Poly ( const Poly< U, SmallSize, Copyable, BaseType > &  other)
inline

Creates a new Poly instance by referencing another.

This will not copy the object and will always reference to the original instance.

Parameters
instanceThe instance to create a new Poly reference from.

◆ Poly() [5/11]

CeresEngine::Poly< T, SmallSize, Copyable, BaseType >::Poly ( Poly &&  other)
inlinenoexcept

Creates a new Poly by moving an existing one.

Parameters
otherThe instance to move from

◆ Poly() [6/11]

template<typename U >
CeresEngine::Poly< T, SmallSize, Copyable, BaseType >::Poly ( Poly< U, SmallSize, Copyable, BaseType > &&  other)
inline

Creates a new Poly instance by referencing another.

This will not copy the object and will always reference to the original instance.

Parameters
instanceThe instance to create a new Poly reference from.

◆ Poly() [7/11]

template<typename TT , typename... Args>
requires (std::is_convertible_v<TT*, T*>&& std::is_constructible_v<TT, Args&&...>)
CeresEngine::Poly< T, SmallSize, Copyable, BaseType >::Poly ( std::in_place_type_t< TT ,
Args &&...  args 
)
inlineexplicit

Creates a new Poly that holds a newly constructed object of type TT.

Template Parameters
TTthe object type
Argsthe object constructor argument types
Parameters
argsThe object constructor arguments

◆ Poly() [8/11]

CeresEngine::Poly< T, SmallSize, Copyable, BaseType >::Poly ( std::nullptr_t  )
inlinenoexcept

Creates a new empty Poly.

◆ Poly() [9/11]

CeresEngine::Poly< T, SmallSize, Copyable, BaseType >::Poly ( T *const  instance)
inline

Creates a new Poly instance by referencing another.

This will not copy the object and will always reference to the original instance.

Parameters
instanceThe instance to create a new Poly reference from.

◆ Poly() [10/11]

template<typename TT >
requires (std::is_convertible_v<TT*, T*> && !Copyable)
CeresEngine::Poly< T, SmallSize, Copyable, BaseType >::Poly ( TT &&  object)
inline

Creates a new Poly that holds a copy constructed object of type TT.

Template Parameters
TTthe object type

◆ Poly() [11/11]

template<typename TT >
requires (std::is_convertible_v<TT*, T*> && Copyable)
CeresEngine::Poly< T, SmallSize, Copyable, BaseType >::Poly ( TT  object)
inline

Creates a new Poly that holds a copy constructed object of type TT.

Template Parameters
TTthe object type

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