Loading...
Searching...
No Matches
ArInMemoryAsset Class Reference

ArAsset implementation that stores asset content in a heap-allocated buffer managed by this object. More...

#include <inMemoryAsset.h>

+ Inheritance diagram for ArInMemoryAsset:

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< ArAssetGetDetachedAsset () 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
 
ArAssetoperator= (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< ArAssetGetDetachedAsset () 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< ArInMemoryAssetFromAsset (const ArAsset &srcAsset)
 Constructs a new instance containing the entire contents of srcAsset.
 
static AR_API std::shared_ptr< ArInMemoryAssetFromBuffer (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< ArInMemoryAssetFromBuffer (std::shared_ptr< const char > &&buffer, size_t bufferSize)
 Constructs a new instance taking ownership of the given buffer containing bufferSize bytes.
 

Detailed Description

ArAsset implementation that stores asset content in a heap-allocated buffer managed by this object.

Definition at line 40 of file inMemoryAsset.h.

Constructor & Destructor Documentation

◆ ~ArInMemoryAsset()

AR_API ~ArInMemoryAsset ( )

Destructor.

Note that this may not destroy the associated buffer if a client is holding on to the result of GetBuffer().

Member Function Documentation

◆ FromAsset()

static AR_API std::shared_ptr< ArInMemoryAsset > FromAsset ( const ArAsset srcAsset)
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.

◆ FromBuffer() [1/2]

static AR_API std::shared_ptr< ArInMemoryAsset > FromBuffer ( const std::shared_ptr< const char > &  buffer,
size_t  bufferSize 
)
static

Constructs a new instance sharing ownership of the given buffer containing bufferSize bytes.

◆ FromBuffer() [2/2]

static AR_API std::shared_ptr< ArInMemoryAsset > FromBuffer ( std::shared_ptr< const char > &&  buffer,
size_t  bufferSize 
)
static

Constructs a new instance taking ownership of the given buffer containing bufferSize bytes.

◆ GetBuffer()

AR_API std::shared_ptr< const char > GetBuffer ( ) const
overridevirtual

Returns the buffer managed by this object.

Implements ArAsset.

◆ GetDetachedAsset()

AR_API std::shared_ptr< ArAsset > GetDetachedAsset ( ) const
overridevirtual

Returns a new ArInMemoryAsset instance that shares the same buffer as this object.

Reimplemented from ArAsset.

◆ GetFileUnsafe()

AR_API std::pair< FILE *, size_t > GetFileUnsafe ( ) const
overridevirtual

Returns { nullptr, 0 } as this object is not associated with a file.

Implements ArAsset.

◆ GetSize()

AR_API size_t GetSize ( ) const
overridevirtual

Returns the size of the buffer managed by this object.

Implements ArAsset.

◆ Read()

AR_API size_t Read ( void *  buffer,
size_t  count,
size_t  offset 
) const
overridevirtual

Reads count bytes from the buffer held by this object at the given offset into buffer.

Implements ArAsset.


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