ProjectStore.h header
#include <ew/app/ProjectStore.h>
Namespace ew::app
ProjectStore class
class ew::app::ProjectStore
Reads and writes a project to/from the on-disk folder-of-text store (DESIGN.md section 6.1): each content object is one file, so revisions diff and merge cleanly in Perforce/Git. Recoverable IO/parse failures are returned as an Error inside the Result, never thrown.
Members
static ew::core::Result< void > ew::app::ProjectStore::save(const ew::core::Project &project, const QString &directory)
Writes project into directory (created if needed), one file per object.
static ew::core::Result< std::unique_ptr< ew::core::Project > > ew::app::ProjectStore::load(const QString &directory)
Loads a project from directory; an absent object folder yields an empty project rather than an error.
static ew::core::Result< void > ew::app::ProjectStore::saveSubset(const ew::core::Project &project, const std::vector< ew::core::ContentId > &objectIds, const std::vector< ew::core::CategoryId > &categoryIds, const QString &directory)
Writes only the objects with ids in objectIds and the taxonomy categories with ids in categoryIds from project into directory (folder-of-text), for authoring a content pack from a selected subset (DESIGN 4.20). No project-level metadata (pins, mounts, goals, ...) is written; ids not present in project are skipped. The directory is created if needed.
static std::unique_ptr< ew::core::ContentObject > ew::app::ProjectStore::cloneObject(const ew::core::ContentObject &object)
Returns a deep copy of object with a freshly generated identity, produced by round-tripping it through the same per-object JSON serialization used to persist the project. Because the copy is reconstructed from the object's full serialized form, every stored field is duplicated and the clone stays complete as new fields are added – so it is safe to build "Duplicate" actions on. The returned object is not yet part of any project; the caller adds it (e.g. via AddObjectCommand) and adjusts placement fields (title, parent, sort order) as needed.
Functions
bool ew::app::isManagedProjectFile(const QString &relativePath)
Whether relativePath (a forward-slash, project-relative path, as produced by readTextSnapshot) is a file this store owns: project.json, or a *.json directly under the objects/ or taxonomy/ subfolder. save() writes exactly these and prunes only within those two subfolders, so every other file in the folder – a user's README.md, a nested library, an export – is foreign. The external-change reconcile uses this to consider only store-owned files: a foreign file, being absent from the project's own serialization, would otherwise look "deleted locally" and be removed. Case-sensitive on the .json suffix per the on-disk convention.