Structure f3d::engine::state
Definition: engine.h (line 264)
A serializable snapshot of an engine: the files added to the scene, the camera configuration and the options that have been set. Captured from an engine with engine::dump() and applied back with engine::load(), so a state taken from one engine can be restored into another.
A state can be read from and written to a JSON string, a file, the system clipboard or any stream. In its string, stream and clipboard forms, file paths are stored as absolute paths; in its file form, file paths contained by the directory of the file are stored relatively so the statefile stays portable when moved alongside its files.
Scene content added from memory (mesh, mesh view or buffer) is not captured.
Members
Friends
Friend engine
Definition: engine.h (line 307)
Friend operator<<
Definition: engine.h (line 308)
Write a state as a JSON string into the provided stream, with file paths stored as absolute paths.
Friend operator>>
Definition: engine.h (line 309)
Read a state from the JSON content of the provided stream. Throws a engine::statefile_exception if the content cannot be parsed.
Private attributes
Variable Content
Definition: engine.h (line 311)
std::string f3d::engine::state::Content
Type: std::string
Public static functions
Function fromString
static F3D_EXPORT state f3d::engine::state::fromString(const std::string &content)
Build a state from a JSON string previously produced by state::toString. Throws a engine::statefile_exception if the content cannot be parsed.
Parameters:
- const std::string & content
Return type: F3D_EXPORT state
Function fromFile
static F3D_EXPORT state f3d::engine::state::fromFile(const std::filesystem::path &filePath)
Build a state from a JSON statefile previously written by state::toFile. File paths stored relatively are resolved against the directory of the file. Throws a engine::statefile_exception if the file cannot be read or parsed.
Parameters:
- const std::filesystem::path & filePath
Return type: F3D_EXPORT state
Function fromClipboard
static F3D_EXPORT state f3d::engine::state::fromClipboard()
Build a state from the JSON content currently held by the system clipboard. Throws a engine::statefile_exception if the clipboard has no readable text, its content cannot be parsed, or clipboard support is not available in this build.
Return type: F3D_EXPORT state
Public functions
Function toString
F3D_EXPORT std::string f3d::engine::state::toString() const
Return the state as a JSON string, with file paths stored as absolute paths.
Return type: F3D_EXPORT std::string
Function toFile
F3D_EXPORT void f3d::engine::state::toFile(const std::filesystem::path &filePath) const
Write the state as a JSON statefile at the provided path. File paths contained by the directory of the file are stored relatively, as absolute paths otherwise. Throws a engine::statefile_exception if the file cannot be written.
Parameters:
- const std::filesystem::path & filePath
Return type: F3D_EXPORT void
Function toClipboard
F3D_EXPORT void f3d::engine::state::toClipboard() const
Copy the state into the system clipboard as a JSON string, with file paths stored as absolute paths. Throws a engine::statefile_exception if the clipboard cannot be written or clipboard support is not available in this build.
Return type: F3D_EXPORT void