26#include "musx/dom/Document.h"
27#include "musx/factory/HeaderFactory.h"
28#include "musx/factory/PoolFactory.h"
29#include "musx/xml/XmlInterface.h"
40 using DocumentPtr = std::shared_ptr<Document>;
50 template <
typename XmlDocumentType>
51 static DocumentPtr
create(
const std::vector<char>& xmlBuffer)
53 static_assert(std::is_base_of<musx::xml::IXmlDocument, XmlDocumentType>::value,
54 "XmlReaderType must derive from IXmlDocument.");
56 std::unique_ptr<musx::xml::IXmlDocument> xmlDocument = std::make_unique<XmlDocumentType>();
57 xmlDocument->loadFromString(xmlBuffer);
59 auto rootElement = xmlDocument->getRootElement();
60 if (!rootElement || rootElement->getTagName() !=
"finale") {
61 throw std::invalid_argument(
"Missing <finale> element.");
67 for (
auto element = rootElement->getFirstChildElement(); element; element = element->getNextSibling()) {
68 if (element->getTagName() ==
"header") {
70 }
else if (element->getTagName() ==
"options") {
72 }
else if (element->getTagName() ==
"others") {
74 }
else if (element->getTagName() ==
"details") {
76 }
else if (element->getTagName() ==
"entries") {
78 }
else if (element->getTagName() ==
"texts") {
82 if (!document->getHeader()) document->getHeader() = std::make_shared<musx::dom::Header>();
83 if (!document->getOptions()) document->getOptions() = std::make_shared<musx::dom::OptionsPool>();
84 if (!document->getOthers()) document->getOthers() = std::make_shared<musx::dom::OthersPool>();
85 if (!document->getDetails()) document->getDetails() = std::make_shared<musx::dom::DetailsPool>();
86 if (!document->getEntries()) document->getEntries() = std::make_shared<musx::dom::EntryPool>();
87 if (!document->getTexts()) document->getTexts() = std::make_shared<musx::dom::TextsPool>();
90#ifdef MUSX_DISPLAY_NODE_NAMES
Represents a document object that encapsulates the entire EnigmaXML structure.
Definition Document.h:51
static std::shared_ptr< PoolType > create(const XmlElementPtr &element, const dom::DocumentPtr &document, ElementLinker &elementLinker)
Creates a OthersPool object from an XML element.
Definition PoolFactory.h:68
Factory class for creating Document objects from XML.
Definition DocumentFactory.h:38
static DocumentPtr create(const std::vector< char > &xmlBuffer)
Creates a Document object from an XML element.
Definition DocumentFactory.h:51
A utility class for managing deferred relationships between elements during document construction.
Definition FactoryBase.h:70
void resolveAll(const dom::DocumentPtr &document)
Resolves all deferred relationships.
Definition FactoryBase.h:108
static std::shared_ptr< PoolType > create(const XmlElementPtr &element, const dom::DocumentPtr &document, ElementLinker &elementLinker)
Creates a OthersPool object from an XML element.
Definition PoolFactory.h:68
Factory base class.
Definition FactoryBase.h:132
static std::shared_ptr< PoolType > create(const XmlElementPtr &element, const dom::DocumentPtr &document, ElementLinker &elementLinker)
Creates a OthersPool object from an XML element.
Definition PoolFactory.h:68
static std::shared_ptr< PoolType > create(const XmlElementPtr &element, const dom::DocumentPtr &document, ElementLinker &elementLinker)
Creates a OthersPool object from an XML element.
Definition PoolFactory.h:68
static std::shared_ptr< PoolType > create(const XmlElementPtr &element, const dom::DocumentPtr &document, ElementLinker &elementLinker)
Creates a OthersPool object from an XML element.
Definition PoolFactory.h:68
@ Verbose
Informational messages that should only displayed when verbose logging is requested.
static void log(LogLevel level, const std::string &message)
Logs a message with a specific severity level.
Definition Logger.h:87
object model for musx file (enigmaxml)
Definition BaseClasses.h:32