+ #include <engine/assets/bridges/old/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 cubos::engine::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(int indentation = 4) + +
- 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>
+
+ cubos:: engine:: old:: JSONBridge<T>:: JSONBridge(int indentation = 4)
+
+ Constructs a bridge.
+Parameters | |
---|---|
indentation | +Indentation level to use when saving the JSON file. | +
If the indentation
level is set to -1, all whitespace is removed.
+
+ template<typename T>
+
+ bool cubos:: engine:: old:: 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:: old:: 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. | +