Plasma Engine  2.0
Loading...
Searching...
No Matches
plMemoryStreamContainerStorage< CONTAINER > Class Template Reference

Templated implementation of plMemoryStreamStorageInterface that adapts most standard pl containers to the interface. More...

#include <MemoryStream.h>

Inheritance diagram for plMemoryStreamContainerStorage< CONTAINER >:

Public Member Functions

 plMemoryStreamContainerStorage (plUInt32 uiInitialCapacity=0, plAllocator *pAllocator=plFoundation::GetDefaultAllocator())
 Creates the storage object for a memory stream. Use uiInitialCapacity to reserve some memory up front.
 
virtual plUInt64 GetStorageSize64 () const override
 Returns the number of bytes that are currently stored.
 
virtual void Clear () override
 Clears the entire storage. All readers and writers must be reset to start from the beginning again.
 
virtual void Compact () override
 Deallocates any allocated memory that's not needed to hold the currently stored data.
 
virtual plUInt64 GetHeapMemoryUsage () const override
 Returns the amount of bytes that are currently allocated on the heap.
 
virtual void Reserve (plUInt64 uiBytes) override
 Reserves N bytes of storage.
 
virtual plResult CopyToStream (plStreamWriter &inout_stream) const override
 Writes the entire content of the storage to the provided stream.
 
virtual plArrayPtr< const plUInt8 > GetContiguousMemoryRange (plUInt64 uiStartByte) const override
 Returns a read-only plArrayPtr that represents a contiguous area in memory which starts at the given first byte.
 
virtual plArrayPtr< plUInt8 > GetContiguousMemoryRange (plUInt64 uiStartByte) override
 Non-const overload of GetContiguousMemoryRange().
 
const plUInt8 * GetData () const
 The data is guaranteed to be contiguous.
 
- Public Member Functions inherited from plMemoryStreamStorageInterface
plUInt32 GetStorageSize32 () const
 Returns the number of bytes that are currently stored. Asserts that the stored amount is less than 4GB.
 
void ReadAll (plStreamReader &inout_stream, plUInt64 uiMaxBytes=plMath::MaxValue< plUInt64 >())
 Copies all data from the given stream into the storage.
 

Detailed Description

template<typename CONTAINER>
class plMemoryStreamContainerStorage< CONTAINER >

Templated implementation of plMemoryStreamStorageInterface that adapts most standard pl containers to the interface.

Note that plMemoryStreamContainerStorage assumes contiguous storage, so using an plDeque for storage will not work.

Member Function Documentation

◆ Clear()

template<typename CONTAINER >
virtual void plMemoryStreamContainerStorage< CONTAINER >::Clear ( )
inlineoverridevirtual

Clears the entire storage. All readers and writers must be reset to start from the beginning again.

Implements plMemoryStreamStorageInterface.

◆ Compact()

template<typename CONTAINER >
virtual void plMemoryStreamContainerStorage< CONTAINER >::Compact ( )
inlineoverridevirtual

Deallocates any allocated memory that's not needed to hold the currently stored data.

Implements plMemoryStreamStorageInterface.

◆ CopyToStream()

template<typename CONTAINER >
virtual plResult plMemoryStreamContainerStorage< CONTAINER >::CopyToStream ( plStreamWriter & inout_stream) const
inlineoverridevirtual

Writes the entire content of the storage to the provided stream.

Implements plMemoryStreamStorageInterface.

◆ GetContiguousMemoryRange() [1/2]

template<typename CONTAINER >
virtual plArrayPtr< const plUInt8 > plMemoryStreamContainerStorage< CONTAINER >::GetContiguousMemoryRange ( plUInt64 uiStartByte) const
inlineoverridevirtual

Returns a read-only plArrayPtr that represents a contiguous area in memory which starts at the given first byte.

This piece of memory can be read/copied/modified in one operation (memcpy etc). The next byte after this slice may be located somewhere entirely different in memory. Call GetContiguousMemoryRange() again with the next byte after this range, to get access to the next memory area.

Chunks may differ in size.

Implements plMemoryStreamStorageInterface.

◆ GetContiguousMemoryRange() [2/2]

template<typename CONTAINER >
virtual plArrayPtr< plUInt8 > plMemoryStreamContainerStorage< CONTAINER >::GetContiguousMemoryRange ( plUInt64 uiStartByte)
inlineoverridevirtual

Non-const overload of GetContiguousMemoryRange().

Implements plMemoryStreamStorageInterface.

◆ GetHeapMemoryUsage()

template<typename CONTAINER >
virtual plUInt64 plMemoryStreamContainerStorage< CONTAINER >::GetHeapMemoryUsage ( ) const
inlineoverridevirtual

Returns the amount of bytes that are currently allocated on the heap.

Implements plMemoryStreamStorageInterface.

◆ GetStorageSize64()

template<typename CONTAINER >
virtual plUInt64 plMemoryStreamContainerStorage< CONTAINER >::GetStorageSize64 ( ) const
inlineoverridevirtual

Returns the number of bytes that are currently stored.

Implements plMemoryStreamStorageInterface.

◆ Reserve()

template<typename CONTAINER >
virtual void plMemoryStreamContainerStorage< CONTAINER >::Reserve ( plUInt64 uiBytes)
inlineoverridevirtual

Reserves N bytes of storage.

Implements plMemoryStreamStorageInterface.

◆ SetInternalSize()

template<typename CONTAINER >
virtual void plMemoryStreamContainerStorage< CONTAINER >::SetInternalSize ( plUInt64 uiSize)
inlineoverrideprivatevirtual

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