ContentPack.h header
#include <ew/app/ContentPack.h>
Namespace ew::app
ContentPackApplyResult struct
struct ew::app::ContentPackApplyResult
A report of what applying a content pack contributed to the target project (DESIGN 4.20). Counts reflect the command the builder returns: added items are those the pack introduces, skipped items are those whose id already existed in the project, so re-applying a pack is idempotent.
Members
bool ew::app::ContentPackApplyResult::packLoaded = false
True if the pack folder was read successfully; when false the other fields stay zero.
int ew::app::ContentPackApplyResult::categoriesAdded = 0
Taxonomy categories the pack adds (its categories not already present by id).
int ew::app::ContentPackApplyResult::objectsAdded = 0
Content objects the pack adds (its objects not already present by id).
int ew::app::ContentPackApplyResult::categoriesSkipped = 0
Categories skipped because one with the same id already existed.
int ew::app::ContentPackApplyResult::objectsSkipped = 0
Objects skipped because one with the same id already existed.
ContentPackManifest struct
struct ew::app::ContentPackManifest
The descriptive manifest of a content pack (its pack.json): free-text metadata shown when browsing or applying a pack. All fields are optional.
Members
QString ew::app::ContentPackManifest::name
The pack's display name.
QString ew::app::ContentPackManifest::description
A short description of what the pack contains.
QString ew::app::ContentPackManifest::author
Who authored the pack (optional).
QString ew::app::ContentPackManifest::version
The pack's version, e.g. "1.0".
Functions
std::unique_ptr< ew::core::Command > ew::app::buildApplyContentPackCommand(ew::core::Project &project, const QString &packDir, ContentPackApplyResult &result)
Builds an undoable command that overlays the content pack in packDir – a folder-of-text bundle in the same format as a project – onto project: the pack's taxonomy categories and content objects are added, skipping any whose id already exists in project so re-applying a pack is idempotent (DESIGN 4.20 "apply a pack onto an existing project ... with conflict
handling"). The merge preserves referential integrity: identity is by globally unique id, so an entity and the category it references are added together and never dangle.
result is populated with what the returned command will add and skip. Returns nullptr if the pack folder could not be read (result.packLoaded stays false). The returned command may be empty (ew::core::CompositeCommand::isEmpty()) when the pack introduces nothing new. Push the command onto the command stack to apply it (and to make it undoable).
ContentPackManifest ew::app::readContentPackManifest(const QString &packDir)
Reads the pack.json manifest from packDir; an absent or malformed file yields an all-empty manifest (a pack without a manifest still applies).
bool ew::app::saveAsContentPack(const ew::core::Project &project, const std::vector< ew::core::ContentId > &objectIds, const ContentPackManifest &manifest, const QString &packDir)
Writes the objects objectIds from project – plus every taxonomy category those objects reference and each of those categories' ancestors – to packDir as a folder-of-text content pack, tagged with a pack.json built from manifest (DESIGN 4.20 authoring). Referenced categories are included so the pack applies without dangling category links. Returns true on success, false if the pack could not be written.