|
ArAsset implementation that stores asset content in a heap-allocated buffer managed by this object. More...
#include <inMemoryAsset.h>
Public Member Functions | |
AR_API | ~ArInMemoryAsset () |
Destructor. | |
AR_API size_t | GetSize () const override |
Returns the size of the buffer managed by this object. | |
AR_API std::shared_ptr< const char > | GetBuffer () const override |
Returns the buffer managed by this object. | |
AR_API size_t | Read (void *buffer, size_t count, size_t offset) const override |
Reads count bytes from the buffer held by this object at the given offset into buffer . | |
AR_API std::pair< FILE *, size_t > | GetFileUnsafe () const override |
Returns { nullptr, 0 } as this object is not associated with a file. | |
AR_API std::shared_ptr< ArAsset > | GetDetachedAsset () const override |
Returns a new ArInMemoryAsset instance that shares the same buffer as this object. | |
template<class BufferSharedPtr > | |
ArInMemoryAsset (BufferSharedPtr &&buffer, size_t bufferSize, PrivateCtorTag) | |
Public Member Functions inherited from ArAsset | |
ArAsset (const ArAsset &)=delete | |
ArAsset & | operator= (const ArAsset &)=delete |
virtual AR_API size_t | GetSize () const =0 |
Returns size of the asset. | |
virtual AR_API std::shared_ptr< const char > | GetBuffer () const =0 |
Returns a pointer to a buffer with the contents of the asset, with size given by GetSize(). | |
virtual AR_API size_t | Read (void *buffer, size_t count, size_t offset) const =0 |
Read count bytes at offset from the beginning of the asset into buffer . | |
virtual AR_API std::pair< FILE *, size_t > | GetFileUnsafe () const =0 |
Returns a read-only FILE* handle and offset for this asset if available, or (nullptr, 0) otherwise. | |
virtual AR_API std::shared_ptr< ArAsset > | GetDetachedAsset () const |
Returns an ArAsset with the contents of this asset detached from from this asset's serialized data. | |
Static Public Member Functions | |
static AR_API std::shared_ptr< ArInMemoryAsset > | FromAsset (const ArAsset &srcAsset) |
Constructs a new instance containing the entire contents of srcAsset . | |
static AR_API std::shared_ptr< ArInMemoryAsset > | FromBuffer (const std::shared_ptr< const char > &buffer, size_t bufferSize) |
Constructs a new instance sharing ownership of the given buffer containing bufferSize bytes. | |
static AR_API std::shared_ptr< ArInMemoryAsset > | FromBuffer (std::shared_ptr< const char > &&buffer, size_t bufferSize) |
Constructs a new instance taking ownership of the given buffer containing bufferSize bytes. | |
ArAsset implementation that stores asset content in a heap-allocated buffer managed by this object.
Definition at line 23 of file inMemoryAsset.h.
AR_API ~ArInMemoryAsset | ( | ) |
Destructor.
Note that this may not destroy the associated buffer if a client is holding on to the result of GetBuffer().
|
static |
Constructs a new instance containing the entire contents of srcAsset
.
Returns nullptr if a buffer large enough to hold srcAsset's
contents cannot be allocated or if an error occurs when reading srcAsset's
contents into the buffer.
|
static |
Constructs a new instance sharing ownership of the given buffer
containing bufferSize
bytes.
|
static |
Constructs a new instance taking ownership of the given buffer
containing bufferSize
bytes.
|
overridevirtual |
Returns the buffer managed by this object.
Implements ArAsset.
|
overridevirtual |
Returns a new ArInMemoryAsset instance that shares the same buffer as this object.
Reimplemented from ArAsset.
|
overridevirtual |
Returns { nullptr, 0 } as this object is not associated with a file.
Implements ArAsset.
|
overridevirtual |
Returns the size of the buffer managed by this object.
Implements ArAsset.
|
overridevirtual |
Reads count
bytes from the buffer held by this object at the given offset
into buffer
.
Implements ArAsset.