#include <engine/assets/bridges/json.hpp>
template<typename T>
JSONBridge class
Bridge for loading and saving assets which are serialized to and from a JSON file.
Template parameters | |
---|---|
T | Type of asset to load and save. Must be default constructible. |
This bridge automatically serializes and deserializes assets of type T
to and from a JSON file. Thus, T
must be serializable and deserializable. No additional context is given to the serializer or deserializer.
Base classes
- class FileBridge
- Abstract bridge type defined to reduce boilerplate code in bridge implementations which open a single file to load and save assets.
Constructors, destructors, conversion operators
- JSONBridge()
- Constructs a bridge.
Protected functions
-
auto loadFromFile(Assets& assets,
const AnyAsset& handle,
core::
memory:: Stream& stream) -> bool override - Loads an asset from a file stream.
-
auto saveToFile(const Assets& assets,
const AnyAsset& handle,
core::
memory:: Stream& stream) -> bool override - Saves an asset to a file stream.
Function documentation
template<typename T>
bool cubos:: engine:: JSONBridge<T>:: loadFromFile(Assets& assets,
const AnyAsset& handle,
core:: memory:: Stream& stream) override protected
Loads an asset from a file stream.
Parameters | |
---|---|
assets | Manager to write into. |
handle | Handle of the asset being loaded. |
stream | File stream. |
Returns | Whether the asset was successfully loaded. |
template<typename T>
bool cubos:: engine:: JSONBridge<T>:: saveToFile(const Assets& assets,
const AnyAsset& handle,
core:: memory:: Stream& stream) override protected
Saves an asset to a file stream.
Parameters | |
---|---|
assets | Manager to read from. |
handle | Handle of the asset being saved. |
stream | File stream. |
Returns | Whether the asset was successfully saved. |