7 #ifndef NAZARA_RESOURCESAVER_HPP 8 #define NAZARA_RESOURCESAVER_HPP 10 #include <Nazara/Core/Enums.hpp> 11 #include <Nazara/Core/Resource.hpp> 12 #include <Nazara/Core/ResourceParameters.hpp> 13 #include <Nazara/Core/String.hpp> 16 #include <type_traits> 22 template<
typename Type,
typename Parameters>
25 static_assert(std::is_base_of<ResourceParameters, Parameters>::value,
"ResourceParameters must be a base of Parameters");
30 using ExtensionGetter = bool (*)(
const String& extension);
31 using FormatQuerier = bool (*)(
const String& format);
32 using FileSaver = bool (*)(
const Type& resource,
const String& filePath,
const Parameters& parameters);
33 using StreamSaver = bool (*)(
const Type& resource,
const String& format,
Stream& stream,
const Parameters& parameters);
40 static bool SaveToFile(
const Type& resource,
const String& filePath,
const Parameters& parameters = Parameters());
41 static bool SaveToStream(
const Type& resource,
Stream& stream,
const String& format,
const Parameters& parameters = Parameters());
43 static void RegisterSaver(FormatQuerier formatQuerier, StreamSaver streamSaver, FileSaver fileSaver =
nullptr);
44 static void UnregisterSaver(FormatQuerier formatQuerier, StreamSaver streamSaver, FileSaver fileSaver =
nullptr);
47 using Saver = std::tuple<FormatQuerier, StreamSaver, FileSaver>;
48 using SaverList = std::list<Saver>;
52 #include <Nazara/Core/ResourceSaver.inl> 54 #endif // NAZARA_RESOURCESAVER_HPP TODO: Inherit SoundEmitter from Node.
Definition: Algorithm.hpp:12
Core class that represents a string.
Definition: String.hpp:22
static bool SaveToFile(const Type &resource, const String &filePath, const Parameters ¶meters=Parameters())
Saves a resource to a file.
Definition: ResourceSaver.inl:54
Core class that represents a list of saver functions for a specific resource type.
Definition: ResourceSaver.hpp:23
static void UnregisterSaver(FormatQuerier formatQuerier, StreamSaver streamSaver, FileSaver fileSaver=nullptr)
Unregisters a saver.
Definition: ResourceSaver.inl:184
static void RegisterSaver(FormatQuerier formatQuerier, StreamSaver streamSaver, FileSaver fileSaver=nullptr)
Registers a saver.
Definition: ResourceSaver.inl:166
static bool IsFormatSupported(const String &extension)
Checks whether the extension of the file is supported.
Definition: ResourceSaver.inl:27
static bool SaveToStream(const Type &resource, Stream &stream, const String &format, const Parameters ¶meters=Parameters())
Saves a resource to a stream.
Definition: ResourceSaver.inl:120
Core class that represents a stream.
Definition: Stream.hpp:19