MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
XmlManifest.hpp
Go to the documentation of this file.
1#pragma once
2
4
7
9
10/**
11 * @brief The Manifest tables for an XML document.
12 *
13 * Fixes the source type, so a host that loads XML never spells it: every table, binding and
14 * registration is written against these aliases. Forma includes no XML header outside this one.
15 */
20
21/**
22 * @brief Read an XML file and place it through @p tables.
23 *
24 * Loads the file, takes its root and runs instantiate_document, so the document, its tables and
25 * the surfaces the host bound are all a host supplies. Surfaces stay the host's to create,
26 * with create_surface, because that is what binds a window and a name.
27 *
28 * @param path The XML file.
29 * @param tables Factories, calls and actions by name.
30 * @param surfaces Surfaces by the name the document's surface elements use.
31 * @param error Receives the reason, with a row for a placement error, when nullopt is returned.
32 * @return Each placed instance by id, with its surface and element.
33 */
34[[nodiscard]] inline std::optional<PlacedInstances> instantiate_xml(
35 const std::filesystem::path& path, const XmlTables& tables, SurfaceMap& surfaces, std::string& error)
36{
37 const auto document = IO::XmlDocument::load(path.string(), error);
38 if (!document)
39 return std::nullopt;
40 const auto root = document->root_element();
41 if (!root) {
42 error = "the document has no root element";
43 return std::nullopt;
44 }
45 return instantiate_document(tables, *root, surfaces, error);
46}
47
48}
static std::shared_ptr< const XmlDocument > load(const std::string &path, std::string &error)
Parse a file into an owning document.
Actions by name, which a document attaches to events and never defines.
Functions a document calls by name, with the function's own parameter names as attributes.
Named factories that turn a template's factory element and an instance into placed Forma elements,...
CallTable< IO::XmlElementView > XmlCallTable
FactoryTable< IO::XmlElementView > XmlFactoryTable
ActionTable< IO::XmlElementView > XmlActionTable
ManifestTables< IO::XmlElementView > XmlTables
The Manifest tables for an XML document.
std::map< std::string, Surface, std::less<> > SurfaceMap
Surfaces by the document name a host binds them to.
std::optional< PlacedInstances > instantiate_xml(const std::filesystem::path &path, const XmlTables &tables, SurfaceMap &surfaces, std::string &error)
Read an XML file and place it through tables.
std::optional< PlacedInstances > instantiate_document(const FactoryTable< Source, Access > &table, const Source &root, SurfaceMap &surfaces, std::string &error)
Place every instance of a document through a table.
The three tables a document is placed through, as one plain value.