Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::controllers::ProjectLoader Class Reference

Handles loading of Zrythm projects from disk. More...

#include <src/controllers/project_loader.h>

Data Structures

struct  LoadResult
 Result of a project load operation. More...

Static Public Member Functions

static QFuture< LoadResultload_from_directory (const fs::path &project_dir)
 Loads and validates a project from the specified directory.
static std::string get_uncompressed_project_text (const fs::path &project_dir)
 Reads and decompresses the project file.
static nlohmann::json parse_and_validate (const std::string &json_str)
 Parses JSON string and validates against schema.
static utils::Utf8String extract_title (const nlohmann::json &j)
 Extracts the project title from JSON metadata.
static void deserialize (const nlohmann::json &j, structure::project::Project &project, structure::project::ProjectUiState &ui_state, undo::UndoStack &undo_stack)
 Deserializes the project data into the given objects.

Detailed Description

Handles loading of Zrythm projects from disk.

This class manages the complete project loading pipeline:

  1. Reading compressed project file
  2. Zstd decompression
  3. JSON parsing
  4. Schema validation
  5. Metadata extraction
  6. Deserialization of Project, ProjectUiState, and UndoStack

Definition at line 40 of file project_loader.h.

Member Function Documentation

◆ deserialize()

void zrythm::controllers::ProjectLoader::deserialize ( const nlohmann::json & j,
structure::project::Project & project,
structure::project::ProjectUiState & ui_state,
undo::UndoStack & undo_stack )
static

Deserializes the project data into the given objects.

Parameters
jThe JSON to deserialize from.
projectThe project instance to populate.
ui_stateThe UI state instance to populate.
undo_stackThe undo stack instance to populate.
Exceptions
ZrythmExceptionon deserialization error.

◆ extract_title()

utils::Utf8String zrythm::controllers::ProjectLoader::extract_title ( const nlohmann::json & j)
static

Extracts the project title from JSON metadata.

Parameters
jThe validated JSON object.
Returns
The project title, or "Untitled" if not found.

◆ get_uncompressed_project_text()

std::string zrythm::controllers::ProjectLoader::get_uncompressed_project_text ( const fs::path & project_dir)
static

Reads and decompresses the project file.

Parameters
project_dirThe project directory.
Returns
The decompressed JSON string.
Exceptions
ZrythmExceptionif reading or decompression fails.

◆ load_from_directory()

QFuture< LoadResult > zrythm::controllers::ProjectLoader::load_from_directory ( const fs::path & project_dir)
staticnodiscard

Loads and validates a project from the specified directory.

Parameters
project_dirThe project directory containing project.zpj
Returns
QFuture containing LoadResult with the parsed JSON and metadata.
Exceptions
ZrythmExceptionif loading fails.

◆ parse_and_validate()

nlohmann::json zrythm::controllers::ProjectLoader::parse_and_validate ( const std::string & json_str)
static

Parses JSON string and validates against schema.

Parameters
json_strThe raw JSON string.
Returns
Parsed and validated JSON object.
Exceptions
ZrythmExceptionif parsing or validation fails.

The documentation for this class was generated from the following file: