Core class that represents a loader of resources.
More...
|
using | ExtensionGetter = bool(*)(const String &extension) |
|
using | FileLoader = bool(*)(Type *resource, const String &filePath, const Parameters ¶meters) |
|
using | MemoryLoader = bool(*)(Type *resource, const void *data, std::size_t size, const Parameters ¶meters) |
|
using | StreamChecker = Ternary(*)(Stream &stream, const Parameters ¶meters) |
|
using | StreamLoader = bool(*)(Type *resource, Stream &stream, const Parameters ¶meters) |
|
|
static bool | IsExtensionSupported (const String &extension) |
| Checks whether the extension of the file is supported. More...
|
|
static bool | LoadFromFile (Type *resource, const String &filePath, const Parameters ¶meters=Parameters()) |
| Loads a resource from a file. More...
|
|
static bool | LoadFromMemory (Type *resource, const void *data, std::size_t size, const Parameters ¶meters=Parameters()) |
| Loads a resource from a raw memory, a size and parameters. More...
|
|
static bool | LoadFromStream (Type *resource, Stream &stream, const Parameters ¶meters=Parameters()) |
| Loads a resource from a stream and parameters. More...
|
|
static void | RegisterLoader (ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader=nullptr, MemoryLoader memoryLoader=nullptr) |
| Registers the loader. More...
|
|
static void | UnregisterLoader (ExtensionGetter extensionGetter, StreamChecker checkFunc, StreamLoader streamLoader, FileLoader fileLoader=nullptr, MemoryLoader memoryLoader=nullptr) |
| Unregisters the loader. More...
|
|
template<typename Type, typename Parameters>
class Nz::ResourceLoader< Type, Parameters >
Core class that represents a loader of resources.
◆ IsExtensionSupported()
template<typename Type , typename Parameters >
Checks whether the extension of the file is supported.
- Returns
- true if supported
- Parameters
-
extension | Extension of the file |
◆ LoadFromFile()
template<typename Type , typename Parameters >
bool Nz::ResourceLoader< Type, Parameters >::LoadFromFile |
( |
Type * |
resource, |
|
|
const String & |
filePath, |
|
|
const Parameters & |
parameters = Parameters() |
|
) |
| |
|
static |
Loads a resource from a file.
- Returns
- true if successfully loaded
- Parameters
-
resource | Resource to load |
filePath | Path to the resource |
parameters | Parameters for the load |
◆ LoadFromMemory()
template<typename Type , typename Parameters >
bool Nz::ResourceLoader< Type, Parameters >::LoadFromMemory |
( |
Type * |
resource, |
|
|
const void * |
data, |
|
|
std::size_t |
size, |
|
|
const Parameters & |
parameters = Parameters() |
|
) |
| |
|
static |
Loads a resource from a raw memory, a size and parameters.
- Returns
- true if successfully loaded
- Parameters
-
resource | Resource to load |
data | Raw memory of the resource |
size | Size available for the read |
parameters | Parameters for the load |
◆ LoadFromStream()
template<typename Type , typename Parameters >
bool Nz::ResourceLoader< Type, Parameters >::LoadFromStream |
( |
Type * |
resource, |
|
|
Stream & |
stream, |
|
|
const Parameters & |
parameters = Parameters() |
|
) |
| |
|
static |
Loads a resource from a stream and parameters.
- Returns
- true if successfully loaded
- Parameters
-
resource | Resource to load |
stream | Stream of the resource |
parameters | Parameters for the load |
◆ RegisterLoader()
template<typename Type , typename Parameters >
void Nz::ResourceLoader< Type, Parameters >::RegisterLoader |
( |
ExtensionGetter |
extensionGetter, |
|
|
StreamChecker |
checkFunc, |
|
|
StreamLoader |
streamLoader, |
|
|
FileLoader |
fileLoader = nullptr , |
|
|
MemoryLoader |
memoryLoader = nullptr |
|
) |
| |
|
static |
Registers the loader.
- Parameters
-
extensionGetter | A function to test whether the extension (as a string) is supported by this loader |
checkFunc | A function to check the stream with the parser |
streamLoader | A function to load the data from a stream in the resource |
fileLoader | Optional function to load the data from a file in the resource |
memoryLoader | Optional function to load the data from a raw memory in the resource |
◆ UnregisterLoader()
template<typename Type , typename Parameters >
void Nz::ResourceLoader< Type, Parameters >::UnregisterLoader |
( |
ExtensionGetter |
extensionGetter, |
|
|
StreamChecker |
checkFunc, |
|
|
StreamLoader |
streamLoader, |
|
|
FileLoader |
fileLoader = nullptr , |
|
|
MemoryLoader |
memoryLoader = nullptr |
|
) |
| |
|
static |
Unregisters the loader.
- Parameters
-
extensionGetter | A function to test whether the extension (as a string) is supported by this loader |
checkFunc | A function to check the stream with the parser |
streamLoader | A function to load the data from a stream in the resource |
fileLoader | Optional function to load the data from a file in the resource |
memoryLoader | Optional function to load the data from a raw memory in the resource |
The documentation for this class was generated from the following files: