1.10 |
Manages EGT resource data blobs. More...
#include <resource.h>
Public Types | |
using | ItemArray = std::vector< std::string > |
Item array type. | |
Public Member Functions | |
void | add (const char *name, const std::vector< unsigned char > &data) |
Register a resource as raw data. | |
void | add (const char *name, const unsigned char *data, size_t len) |
Register a resource as raw data. | |
void | clear () |
Clear all registered resources. | |
void | clear (const char *name) |
Clear the specified resource by name. | |
const unsigned char * | data (const char *name) |
Get a pointer to the in-memory resource data. | |
bool | exists (const char *name) const |
EGT_NODISCARD ItemArray | list () const |
Get a list of registered resource names. | |
bool | read (const char *name, unsigned char *data, size_t length, size_t offset=0) |
Read data from a resource. | |
void | remove (const char *name) |
Unregister a resource. | |
size_t | size (const char *name) |
Get the data length of a resource. | |
bool | stream_read (const char *name, unsigned char *data, size_t length) |
Read starting from internal stream offset. | |
void | stream_reset (const char *name) |
Reset internal read stream offset. | |
Static Public Member Functions | |
static ResourceManager & | instance () |
Get a reference to the ResourceManager instance. | |
Manages EGT resource data blobs.
Resources can be registered with this class and then read back later directly from this class. When using an EGT API, like Image() that takes a URI, prefix the name in the URI with scheme 'res' to make EGT read the resource from ResourceManager.
using ItemArray = std::vector<std::string> |
Item array type.
void add | ( | const char * | name, |
const std::vector< unsigned char > & | data | ||
) |
Register a resource as raw data.
void add | ( | const char * | name, |
const unsigned char * | data, | ||
size_t | len | ||
) |
Register a resource as raw data.
void clear | ( | ) |
Clear all registered resources.
void clear | ( | const char * | name | ) |
Clear the specified resource by name.
const unsigned char * data | ( | const char * | name | ) |
Get a pointer to the in-memory resource data.
bool exists | ( | const char * | name | ) | const |
|
static |
Get a reference to the ResourceManager instance.
EGT_NODISCARD ItemArray list | ( | ) | const |
Get a list of registered resource names.
bool read | ( | const char * | name, |
unsigned char * | data, | ||
size_t | length, | ||
size_t | offset = 0 |
||
) |
Read data from a resource.
void remove | ( | const char * | name | ) |
Unregister a resource.
size_t size | ( | const char * | name | ) |
Get the data length of a resource.
bool stream_read | ( | const char * | name, |
unsigned char * | data, | ||
size_t | length | ||
) |
Read starting from internal stream offset.
void stream_reset | ( | const char * | name | ) |
Reset internal read stream offset.