Core class that represents a list of saver functions for a specific resource type.
More...
|
using | ExtensionGetter = bool(*)(const String &extension) |
|
using | FormatQuerier = bool(*)(const String &format) |
|
using | FileSaver = bool(*)(const Type &resource, const String &filePath, const Parameters ¶meters) |
|
using | StreamSaver = bool(*)(const Type &resource, const String &format, Stream &stream, const Parameters ¶meters) |
|
|
static bool | IsFormatSupported (const String &extension) |
| Checks whether the extension of the file is supported. More...
|
|
static bool | SaveToFile (const Type &resource, const String &filePath, const Parameters ¶meters=Parameters()) |
| Saves a resource to a file. More...
|
|
static bool | SaveToStream (const Type &resource, Stream &stream, const String &format, const Parameters ¶meters=Parameters()) |
| Saves a resource to a stream. More...
|
|
static void | RegisterSaver (FormatQuerier formatQuerier, StreamSaver streamSaver, FileSaver fileSaver=nullptr) |
| Registers a saver. More...
|
|
static void | UnregisterSaver (FormatQuerier formatQuerier, StreamSaver streamSaver, FileSaver fileSaver=nullptr) |
| Unregisters a saver. More...
|
|
template<typename Type, typename Parameters>
class Nz::ResourceSaver< Type, Parameters >
Core class that represents a list of saver functions for a specific resource type.
◆ IsFormatSupported()
template<typename Type , typename Parameters >
Checks whether the extension of the file is supported.
- Returns
- true if supported
- Parameters
-
extension | Extension of the file |
◆ RegisterSaver()
template<typename Type , typename Parameters >
void Nz::ResourceSaver< Type, Parameters >::RegisterSaver |
( |
FormatQuerier |
formatQuerier, |
|
|
StreamSaver |
streamSaver, |
|
|
FileSaver |
fileSaver = nullptr |
|
) |
| |
|
static |
Registers a saver.
- Parameters
-
formatQuerier | A function to test whether the format (as a string) is supported by this saver |
streamSaver | A function which saves the resource to a stream |
fileSaver | Optional function which saves the resource directly to a file given a file path |
◆ SaveToFile()
template<typename Type , typename Parameters >
bool Nz::ResourceSaver< Type, Parameters >::SaveToFile |
( |
const Type & |
resource, |
|
|
const String & |
filePath, |
|
|
const Parameters & |
parameters = Parameters() |
|
) |
| |
|
static |
Saves a resource to a file.
- Returns
- true if successfully saved
- Parameters
-
resource | Resource to save |
filePath | Path to the file where the resource will be written |
parameters | Parameters for the save |
- See also
- SaveToStream
◆ SaveToStream()
template<typename Type , typename Parameters >
bool Nz::ResourceSaver< Type, Parameters >::SaveToStream |
( |
const Type & |
resource, |
|
|
Stream & |
stream, |
|
|
const String & |
format, |
|
|
const Parameters & |
parameters = Parameters() |
|
) |
| |
|
static |
Saves a resource to a stream.
- Returns
- true if successfully saved
- Parameters
-
resource | Resource to load |
stream | Stream with write access where the resource data will be written |
format | Data format to save the resource to |
parameters | Parameters for the saving |
- See also
- SaveToFile
◆ UnregisterSaver()
template<typename Type , typename Parameters >
void Nz::ResourceSaver< Type, Parameters >::UnregisterSaver |
( |
FormatQuerier |
formatQuerier, |
|
|
StreamSaver |
streamSaver, |
|
|
FileSaver |
fileSaver = nullptr |
|
) |
| |
|
static |
Unregisters a saver.
- Parameters
-
formatQuerier | A function to test whether the format (as a string) is supported by this saver |
streamSaver | A function which saves the resource to a stream |
fileSaver | A function function which saves the resource directly to a file given a file path |
The documentation for this class was generated from the following files: