summaryrefslogtreecommitdiff
path: root/src/formats/osxml/OsxmlParser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/formats/osxml/OsxmlParser.cpp')
-rw-r--r--src/formats/osxml/OsxmlParser.cpp890
1 files changed, 15 insertions, 875 deletions
diff --git a/src/formats/osxml/OsxmlParser.cpp b/src/formats/osxml/OsxmlParser.cpp
index 4f6503c..869c76a 100644
--- a/src/formats/osxml/OsxmlParser.cpp
+++ b/src/formats/osxml/OsxmlParser.cpp
@@ -24,882 +24,22 @@
#include <expat.h>
#include <core/common/CharReader.hpp>
-#include <core/common/RttiBuilder.hpp>
#include <core/common/Utils.hpp>
#include <core/common/VariantReader.hpp>
-#include <core/parser/ParserStack.hpp>
#include <core/parser/ParserScope.hpp>
+#include <core/parser/ParserStack.hpp>
+#include <core/parser/stack/DocumentHandler.hpp>
+#include <core/parser/stack/DomainHandler.hpp>
+#include <core/parser/stack/ImportIncludeHandler.hpp>
+#include <core/parser/stack/TypesystemHandler.hpp>
#include <core/model/Document.hpp>
#include <core/model/Domain.hpp>
-#include <core/model/Project.hpp>
-#include <core/model/RootNode.hpp>
#include <core/model/Typesystem.hpp>
#include "XmlParser.hpp"
namespace ousia {
-/* HeadNode Helper class */
-
-namespace {
-class HeadNode : public Node {
-public:
- using Node::Node;
-};
-}
-
-namespace RttiTypes {
-static Rtti HeadNode = RttiBuilder<ousia::HeadNode>("HeadNode");
-}
-
-/* Element Handler Classes */
-
-class DocumentHandler : public Handler {
-public:
- using Handler::Handler;
-
- void start(Variant::mapType &args) override
- {
- Rooted<Document> document =
- project()->createDocument(args["name"].asString());
- document->setLocation(location());
- scope().push(document);
- scope().setFlag(ParserFlag::POST_HEAD, false);
- }
-
- void end() override { scope().pop(); }
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new DocumentHandler{handlerData};
- }
-};
-
-class DocumentField : public Node {
-public:
- DocumentField(Manager &mgr, std::string name, Handle<Node> parent)
- : Node(mgr, name, parent)
- {
- }
-};
-
-namespace RttiTypes {
-const Rtti DocumentField =
- RttiBuilder<ousia::DocumentField>("DocumentField").parent(&Node);
-}
-
-class DocumentChildHandler : public Handler {
-public:
- using Handler::Handler;
-
- void preamble(Handle<Node> parentNode, std::string &fieldName,
- DocumentEntity *&parent, bool &inField)
- {
- // check if the parent in the structure tree was an explicit field
- // reference.
- inField = parentNode->isa(&RttiTypes::DocumentField);
- if (inField) {
- fieldName = parentNode->getName();
- parentNode = scope().selectOrThrow(
- {&RttiTypes::StructuredEntity, &RttiTypes::AnnotationEntity});
- } else {
- // if it wasn't an explicit reference, we use the default field.
- fieldName = DEFAULT_FIELD_NAME;
- }
- // reference the parent entity explicitly.
- parent = nullptr;
- if (parentNode->isa(&RttiTypes::StructuredEntity)) {
- parent = static_cast<DocumentEntity *>(
- parentNode.cast<StructuredEntity>().get());
- } else if (parentNode->isa(&RttiTypes::AnnotationEntity)) {
- parent = static_cast<DocumentEntity *>(
- parentNode.cast<AnnotationEntity>().get());
- }
- }
-
- void start(Variant::mapType &args) override
- {
- scope().setFlag(ParserFlag::POST_HEAD, true);
- Rooted<Node> parentNode = scope().selectOrThrow(
- {&RttiTypes::Document, &RttiTypes::StructuredEntity,
- &RttiTypes::AnnotationEntity, &RttiTypes::DocumentField});
-
- std::string fieldName;
- DocumentEntity *parent;
- bool inField;
-
- preamble(parentNode, fieldName, parent, inField);
-
- // try to find a FieldDescriptor for the given tag if we are not in a
- // field already.
- // TODO: Consider fields of transparent classes
- if (!inField && parent != nullptr &&
- parent->getDescriptor()->hasField(name())) {
- Rooted<DocumentField> field{new DocumentField(
- parentNode->getManager(), fieldName, parentNode)};
- field->setLocation(location());
- scope().push(field);
- return;
- }
-
- // Otherwise create a new StructuredEntity
- // TODO: Consider Anchors and AnnotationEntities
- Rooted<StructuredClass> strct = scope().resolve<StructuredClass>(
- Utils::split(name(), ':'), logger());
- if (strct == nullptr) {
- // if we could not resolve the name, throw an exception.
- throw LoggableException(
- std::string("\"") + name() + "\" could not be resolved.",
- location());
- }
-
- std::string name;
- auto it = args.find("name");
- if (it != args.end()) {
- name = it->second.asString();
- args.erase(it);
- }
-
- Rooted<StructuredEntity> entity;
- if (parentNode->isa(&RttiTypes::Document)) {
- entity = parentNode.cast<Document>()->createRootStructuredEntity(
- strct, args, name);
- } else {
- // calculate a path if transparent entities are needed in between.
- auto path = parent->getDescriptor()->pathTo(strct);
- if (path.empty()) {
- throw LoggableException(
- std::string("An instance of \"") + strct->getName() +
- "\" is not allowed as child of an instance of \"" +
- parent->getDescriptor()->getName() + "\"",
- location());
- }
-
- // create all transparent entities until the last field.
- for (size_t p = 1; p < path.size() - 1; p = p + 2) {
- parent = static_cast<DocumentEntity *>(
- parent->createChildStructuredEntity(
- path[p].cast<StructuredClass>(),
- Variant::mapType{}, path[p - 1]->getName(),
- "").get());
- }
- entity = parent->createChildStructuredEntity(strct, args, fieldName,
- name);
- }
- entity->setLocation(location());
- scope().push(entity);
- }
-
- void end() override { scope().pop(); }
-
- void data(const std::string &data, int fieldIdx) override
- {
- Rooted<Node> parentNode = scope().selectOrThrow(
- {&RttiTypes::StructuredEntity, &RttiTypes::AnnotationEntity,
- &RttiTypes::DocumentField});
-
- std::string fieldName;
- DocumentEntity *parent;
- bool inField;
-
- preamble(parentNode, fieldName, parent, inField);
-
- // retrieve the correct FieldDescriptor.
- // TODO: Consider fields of transparent classes
- Rooted<Descriptor> desc = parent->getDescriptor();
- Rooted<FieldDescriptor> field = desc->getFieldDescriptor(fieldName);
- if (field == nullptr) {
- logger().error(
- std::string("Can't handle data because no field with name \"") +
- fieldName + "\" exists in descriptor\"" + desc->getName() +
- "\".",
- location());
- return;
- }
- if (!field->isPrimitive()) {
- logger().error(std::string("Can't handle data because field \"") +
- fieldName + "\" of descriptor \"" +
- desc->getName() + "\" is not primitive!",
- location());
- return;
- }
-
- // try to parse the content.
- auto res = VariantReader::parseGenericString(
- data, logger(), location().getSourceId(), location().getStart());
- if (!res.first) {
- return;
- }
- // try to convert it to the correct type.
- if (!field->getPrimitiveType()->build(res.second, logger())) {
- return;
- }
- // add it as primitive content.
- parent->createChildDocumentPrimitive(res.second, fieldName);
- }
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new DocumentChildHandler{handlerData};
- }
-};
-
-class TypesystemHandler : public Handler {
-public:
- using Handler::Handler;
-
- void start(Variant::mapType &args) override
- {
- // Create the typesystem instance
- Rooted<Typesystem> typesystem =
- project()->createTypesystem(args["name"].asString());
- typesystem->setLocation(location());
-
- // Push the typesystem onto the scope, set the POST_HEAD flag to true
- scope().push(typesystem);
- scope().setFlag(ParserFlag::POST_HEAD, false);
- }
-
- void end() override { scope().pop(); }
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new TypesystemHandler{handlerData};
- }
-};
-
-class TypesystemEnumHandler : public Handler {
-public:
- using Handler::Handler;
-
- void start(Variant::mapType &args) override
- {
- scope().setFlag(ParserFlag::POST_HEAD, true);
-
- // Fetch the current typesystem and create the enum node
- Rooted<Typesystem> typesystem = scope().selectOrThrow<Typesystem>();
- Rooted<EnumType> enumType =
- typesystem->createEnumType(args["name"].asString());
- enumType->setLocation(location());
-
- scope().push(enumType);
- }
-
- void end() override { scope().pop(); }
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new TypesystemEnumHandler{handlerData};
- }
-};
-
-class TypesystemEnumEntryHandler : public Handler {
-public:
- using Handler::Handler;
-
- std::string entry;
-
- void start(Variant::mapType &args) override {}
-
- void end() override
- {
- Rooted<EnumType> enumType = scope().selectOrThrow<EnumType>();
- enumType->addEntry(entry, logger());
- }
-
- void data(const std::string &data, int field) override
- {
- if (field != 0) {
- // TODO: This should be stored in the HandlerData
- logger().error("Enum entry only has one field.");
- return;
- }
- entry.append(data);
- }
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new TypesystemEnumEntryHandler{handlerData};
- }
-};
-
-class TypesystemStructHandler : public Handler {
-public:
- using Handler::Handler;
-
- void start(Variant::mapType &args) override
- {
- scope().setFlag(ParserFlag::POST_HEAD, true);
-
- // Fetch the arguments used for creating this type
- const std::string &name = args["name"].asString();
- const std::string &parent = args["parent"].asString();
-
- // Fetch the current typesystem and create the struct node
- Rooted<Typesystem> typesystem = scope().selectOrThrow<Typesystem>();
- Rooted<StructType> structType = typesystem->createStructType(name);
- structType->setLocation(location());
-
- // Try to resolve the parent type and set it as parent structure
- if (!parent.empty()) {
- scope().resolve<StructType>(
- parent, structType, logger(),
- [](Handle<Node> parent, Handle<Node> structType,
- Logger &logger) {
- if (parent != nullptr) {
- structType.cast<StructType>()->setParentStructure(
- parent.cast<StructType>(), logger);
- }
- });
- }
- scope().push(structType);
- }
-
- void end() override { scope().pop(); }
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new TypesystemStructHandler{handlerData};
- }
-};
-
-class TypesystemStructFieldHandler : public Handler {
-public:
- using Handler::Handler;
-
- void start(Variant::mapType &args) override
- {
- // Read the argument values
- const std::string &name = args["name"].asString();
- const std::string &type = args["type"].asString();
- const Variant &defaultValue = args["default"];
- const bool optional =
- !(defaultValue.isObject() && defaultValue.asObject() == nullptr);
-
- Rooted<StructType> structType = scope().selectOrThrow<StructType>();
- Rooted<Attribute> attribute =
- structType->createAttribute(name, defaultValue, optional, logger());
- attribute->setLocation(location());
-
- // Try to resolve the type and default value
- if (optional) {
- scope().resolveTypeWithValue(
- type, attribute, attribute->getDefaultValue(), logger(),
- [](Handle<Node> type, Handle<Node> attribute, Logger &logger) {
- if (type != nullptr) {
- attribute.cast<Attribute>()->setType(type.cast<Type>(),
- logger);
- }
- });
- } else {
- scope().resolveType(
- type, attribute, logger(),
- [](Handle<Node> type, Handle<Node> attribute, Logger &logger) {
- if (type != nullptr) {
- attribute.cast<Attribute>()->setType(type.cast<Type>(),
- logger);
- }
- });
- }
- }
-
- void end() override {}
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new TypesystemStructFieldHandler{handlerData};
- }
-};
-
-class TypesystemConstantHandler : public Handler {
-public:
- using Handler::Handler;
-
- void start(Variant::mapType &args) override
- {
- scope().setFlag(ParserFlag::POST_HEAD, true);
-
- // Read the argument values
- const std::string &name = args["name"].asString();
- const std::string &type = args["type"].asString();
- const Variant &value = args["value"];
-
- Rooted<Typesystem> typesystem = scope().selectOrThrow<Typesystem>();
- Rooted<Constant> constant = typesystem->createConstant(name, value);
- constant->setLocation(location());
-
- // Try to resolve the type
- scope().resolveTypeWithValue(
- type, constant, constant->getValue(), logger(),
- [](Handle<Node> type, Handle<Node> constant, Logger &logger) {
- if (type != nullptr) {
- constant.cast<Constant>()->setType(type.cast<Type>(),
- logger);
- }
- });
- }
-
- void end() override {}
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new TypesystemConstantHandler{handlerData};
- }
-};
-
-/*
- * Domain Handlers
- */
-
-class DomainHandler : public Handler {
-public:
- using Handler::Handler;
-
- void start(Variant::mapType &args) override
- {
- Rooted<Domain> domain =
- project()->createDomain(args["name"].asString());
- domain->setLocation(location());
-
- scope().push(domain);
- }
-
- void end() override { scope().pop(); }
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new DomainHandler{handlerData};
- }
-};
-
-class DomainStructHandler : public Handler {
-public:
- using Handler::Handler;
-
- void start(Variant::mapType &args) override
- {
- scope().setFlag(ParserFlag::POST_HEAD, true);
-
- Rooted<Domain> domain = scope().selectOrThrow<Domain>();
-
- Rooted<StructuredClass> structuredClass = domain->createStructuredClass(
- args["name"].asString(), args["cardinality"].asCardinality(),
- nullptr, args["transparent"].asBool(), args["isRoot"].asBool());
- structuredClass->setLocation(location());
-
- const std::string &isa = args["isa"].asString();
- if (!isa.empty()) {
- scope().resolve<StructuredClass>(
- isa, structuredClass, logger(),
- [](Handle<Node> superclass, Handle<Node> structuredClass,
- Logger &logger) {
- if (superclass != nullptr) {
- structuredClass.cast<StructuredClass>()->setSuperclass(
- superclass.cast<StructuredClass>(), logger);
- }
- });
- }
-
- scope().push(structuredClass);
- }
-
- void end() override { scope().pop(); }
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new DomainStructHandler{handlerData};
- }
-};
-
-class DomainAnnotationHandler : public Handler {
-public:
- using Handler::Handler;
-
- void start(Variant::mapType &args) override
- {
- scope().setFlag(ParserFlag::POST_HEAD, true);
-
- Rooted<Domain> domain = scope().selectOrThrow<Domain>();
-
- Rooted<AnnotationClass> annotationClass =
- domain->createAnnotationClass(args["name"].asString());
- annotationClass->setLocation(location());
-
- scope().push(annotationClass);
- }
-
- void end() override { scope().pop(); }
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new DomainAnnotationHandler{handlerData};
- }
-};
-
-class DomainAttributesHandler : public Handler {
-public:
- using Handler::Handler;
-
- void start(Variant::mapType &args) override
- {
- // Fetch the current typesystem and create the struct node
- Rooted<Descriptor> parent = scope().selectOrThrow<Descriptor>();
-
- Rooted<StructType> attrDesc = parent->getAttributesDescriptor();
- attrDesc->setLocation(location());
-
- scope().push(attrDesc);
- }
-
- void end() override { scope().pop(); }
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new DomainAttributesHandler{handlerData};
- }
-};
-
-class DomainFieldHandler : public Handler {
-public:
- using Handler::Handler;
-
- void start(Variant::mapType &args) override
- {
- FieldDescriptor::FieldType type;
- if (args["isSubtree"].asBool()) {
- type = FieldDescriptor::FieldType::SUBTREE;
- } else {
- type = FieldDescriptor::FieldType::TREE;
- }
-
- Rooted<Descriptor> parent = scope().selectOrThrow<Descriptor>();
-
- Rooted<FieldDescriptor> field = parent->createFieldDescriptor(
- type, args["name"].asString(), args["optional"].asBool());
- field->setLocation(location());
-
- scope().push(field);
- }
-
- void end() override { scope().pop(); }
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new DomainFieldHandler{handlerData};
- }
-};
-
-class DomainFieldRefHandler : public Handler {
-public:
- using Handler::Handler;
-
- void start(Variant::mapType &args) override
- {
- Rooted<Descriptor> parent = scope().selectOrThrow<Descriptor>();
-
- const std::string &name = args["name"].asString();
- scope().resolve<FieldDescriptor>(
- name, parent, logger(),
- [](Handle<Node> field, Handle<Node> parent, Logger &logger) {
- if (field != nullptr) {
- parent.cast<StructuredClass>()->addFieldDescriptor(
- field.cast<FieldDescriptor>());
- }
- });
- }
-
- void end() override {}
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new DomainFieldRefHandler{handlerData};
- }
-};
-
-class DomainPrimitiveHandler : public Handler {
-public:
- using Handler::Handler;
-
- void start(Variant::mapType &args) override
- {
- Rooted<Descriptor> parent = scope().selectOrThrow<Descriptor>();
-
- Rooted<FieldDescriptor> field = parent->createPrimitiveFieldDescriptor(
- nullptr, args["name"].asString(), args["optional"].asBool());
- field->setLocation(location());
-
- const std::string &type = args["type"].asString();
- scope().resolve<Type>(
- type, field, logger(),
- [](Handle<Node> type, Handle<Node> field, Logger &logger) {
- if (type != nullptr) {
- field.cast<FieldDescriptor>()->setPrimitiveType(
- type.cast<Type>());
- }
- });
-
- scope().push(field);
- }
-
- void end() override { scope().pop(); }
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new DomainPrimitiveHandler{handlerData};
- }
-};
-
-class DomainChildHandler : public Handler {
-public:
- using Handler::Handler;
-
- void start(Variant::mapType &args) override
- {
- Rooted<FieldDescriptor> field =
- scope().selectOrThrow<FieldDescriptor>();
-
- const std::string &ref = args["ref"].asString();
- scope().resolve<StructuredClass>(
- ref, field, logger(),
- [](Handle<Node> child, Handle<Node> field, Logger &logger) {
- if (child != nullptr) {
- field.cast<FieldDescriptor>()->addChild(
- child.cast<StructuredClass>());
- }
- });
- }
-
- void end() override {}
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new DomainChildHandler{handlerData};
- }
-};
-
-class DomainParent : public Node {
-public:
- DomainParent(Manager &mgr, std::string name, Handle<Node> parent)
- : Node(mgr, name, parent)
- {
- }
-};
-
-namespace RttiTypes {
-const Rtti DomainParent =
- RttiBuilder<ousia::DomainParent>("DomainParent").parent(&Node);
-}
-
-class DomainParentHandler : public Handler {
-public:
- using Handler::Handler;
-
- void start(Variant::mapType &args) override
- {
- Rooted<StructuredClass> strct =
- scope().selectOrThrow<StructuredClass>();
-
- Rooted<DomainParent> parent{new DomainParent(
- strct->getManager(), args["name"].asString(), strct)};
- parent->setLocation(location());
- scope().push(parent);
- }
-
- void end() override { scope().pop(); }
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new DomainParentHandler{handlerData};
- }
-};
-
-class DomainParentFieldHandler : public Handler {
-public:
- using Handler::Handler;
-
- void start(Variant::mapType &args) override
- {
- Rooted<DomainParent> parentNameNode =
- scope().selectOrThrow<DomainParent>();
- FieldDescriptor::FieldType type;
- if (args["isSubtree"].asBool()) {
- type = FieldDescriptor::FieldType::SUBTREE;
- } else {
- type = FieldDescriptor::FieldType::TREE;
- }
-
- const std::string &name = args["name"].asString();
- const bool optional = args["optional"].asBool();
- Rooted<StructuredClass> strct =
- parentNameNode->getParent().cast<StructuredClass>();
-
- // resolve the parent, create the declared field and add the declared
- // StructuredClass as child to it.
- scope().resolve<Descriptor>(
- parentNameNode->getName(), strct, logger(),
- [type, name, optional](Handle<Node> parent, Handle<Node> strct,
- Logger &logger) {
- if (parent != nullptr) {
- Rooted<FieldDescriptor> field =
- parent.cast<Descriptor>()->createFieldDescriptor(
- type, name, optional);
- field->addChild(strct.cast<StructuredClass>());
- }
- });
- }
-
- void end() override {}
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new DomainParentFieldHandler{handlerData};
- }
-};
-
-class DomainParentFieldRefHandler : public Handler {
-public:
- using Handler::Handler;
-
- void start(Variant::mapType &args) override
- {
- Rooted<DomainParent> parentNameNode =
- scope().selectOrThrow<DomainParent>();
-
- const std::string &name = args["name"].asString();
- Rooted<StructuredClass> strct =
- parentNameNode->getParent().cast<StructuredClass>();
- auto loc = location();
-
- // resolve the parent, get the referenced field and add the declared
- // StructuredClass as child to it.
- scope().resolve<Descriptor>(parentNameNode->getName(), strct, logger(),
- [name, loc](Handle<Node> parent,
- Handle<Node> strct,
- Logger &logger) {
- if (parent != nullptr) {
- auto res = parent.cast<Descriptor>()->resolve(
- &RttiTypes::FieldDescriptor, name);
- if (res.size() != 1) {
- logger.error(
- std::string("Could not find referenced field ") + name,
- loc);
- return;
- }
- Rooted<FieldDescriptor> field =
- res[0].node.cast<FieldDescriptor>();
- field->addChild(strct.cast<StructuredClass>());
- }
- });
- }
-
- void end() override {}
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new DomainParentFieldRefHandler{handlerData};
- }
-};
-
-/*
- * Import and Include Handler
- */
-
-class ImportIncludeHandler : public Handler {
-public:
- using Handler::Handler;
-
- bool srcInArgs = false;
- std::string rel;
- std::string type;
- std::string src;
-
- void start(Variant::mapType &args) override
- {
- rel = args["rel"].asString();
- type = args["type"].asString();
- src = args["src"].asString();
- srcInArgs = !src.empty();
- }
-
- void data(const std::string &data, int field) override
- {
- if (srcInArgs) {
- logger().error("\"src\" attribute has already been set");
- return;
- }
- if (field != 0) {
- logger().error("Command has only one field.");
- return;
- }
- src.append(data);
- }
-};
-
-class ImportHandler : public ImportIncludeHandler {
-public:
- using ImportIncludeHandler::ImportIncludeHandler;
-
- void start(Variant::mapType &args) override
- {
- ImportIncludeHandler::start(args);
-
- // Make sure imports are still possible
- if (scope().getFlag(ParserFlag::POST_HEAD)) {
- logger().error("Imports must be listed before other commands.",
- location());
- return;
- }
- }
-
- void end() override
- {
- // Fetch the last node and check whether an import is valid at this
- // position
- Rooted<Node> leaf = scope().getLeaf();
- if (leaf == nullptr || !leaf->isa(&RttiTypes::RootNode)) {
- logger().error(
- "Import not supported here, must be inside a document, domain "
- "or typesystem command.",
- location());
- return;
- }
- Rooted<RootNode> leafRootNode = leaf.cast<RootNode>();
-
- // Perform the actual import, register the imported node within the leaf
- // node
- Rooted<Node> imported =
- context().import(src, type, rel, leafRootNode->getReferenceTypes());
- if (imported != nullptr) {
- leafRootNode->reference(imported);
- }
- }
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new ImportHandler{handlerData};
- }
-};
-
-class IncludeHandler : public ImportIncludeHandler {
-public:
- using ImportIncludeHandler::ImportIncludeHandler;
-
- void start(Variant::mapType &args) override
- {
- ImportIncludeHandler::start(args);
- }
-
- void end() override
- {
- context().include(src, type, rel, {&RttiTypes::Node});
- }
-
- static Handler *create(const HandlerData &handlerData)
- {
- return new IncludeHandler{handlerData};
- }
-};
-
namespace ParserStates {
/* Document states */
static const ParserState Document =
@@ -961,7 +101,7 @@ static const ParserState DomainField =
.parents({&DomainStruct, &DomainAnnotation})
.createdNodeType(&RttiTypes::FieldDescriptor)
.elementHandler(DomainFieldHandler::create)
- .arguments({Argument::String("name", DEFAULT_FIELD_NAME),
+ .arguments({Argument::String("name", ""),
Argument::Bool("isSubtree", false),
Argument::Bool("optional", false)});
@@ -970,16 +110,16 @@ static const ParserState DomainFieldRef =
.parents({&DomainStruct, &DomainAnnotation})
.createdNodeType(&RttiTypes::FieldDescriptor)
.elementHandler(DomainFieldRefHandler::create)
- .arguments({Argument::String("name", DEFAULT_FIELD_NAME)});
+ .arguments({Argument::String("ref", DEFAULT_FIELD_NAME)});
static const ParserState DomainStructPrimitive =
ParserStateBuilder()
.parents({&DomainStruct, &DomainAnnotation})
.createdNodeType(&RttiTypes::FieldDescriptor)
.elementHandler(DomainPrimitiveHandler::create)
- .arguments({Argument::String("name", DEFAULT_FIELD_NAME),
- Argument::Bool("optional", false),
- Argument::String("type")});
+ .arguments(
+ {Argument::String("name", ""), Argument::Bool("isSubtree", false),
+ Argument::Bool("optional", false), Argument::String("type")});
static const ParserState DomainStructChild =
ParserStateBuilder()
@@ -992,14 +132,14 @@ static const ParserState DomainStructParent =
.parent(&DomainStruct)
.createdNodeType(&RttiTypes::DomainParent)
.elementHandler(DomainParentHandler::create)
- .arguments({Argument::String("name")});
+ .arguments({Argument::String("ref")});
static const ParserState DomainStructParentField =
ParserStateBuilder()
.parent(&DomainStructParent)
.createdNodeType(&RttiTypes::FieldDescriptor)
.elementHandler(DomainParentFieldHandler::create)
- .arguments({Argument::String("name", DEFAULT_FIELD_NAME),
+ .arguments({Argument::String("name", ""),
Argument::Bool("isSubtree", false),
Argument::Bool("optional", false)});
@@ -1008,7 +148,7 @@ static const ParserState DomainStructParentFieldRef =
.parent(&DomainStructParent)
.createdNodeType(&RttiTypes::FieldDescriptor)
.elementHandler(DomainParentFieldRefHandler::create)
- .arguments({Argument::String("name", DEFAULT_FIELD_NAME)});
+ .arguments({Argument::String("ref", DEFAULT_FIELD_NAME)});
/* Typesystem states */
static const ParserState Typesystem =
@@ -1079,8 +219,8 @@ static const std::multimap<std::string, const ParserState *> XmlStates{
{"field", &DomainField},
{"fieldRef", &DomainFieldRef},
{"primitive", &DomainStructPrimitive},
- {"child", &DomainStructChild},
- {"parent", &DomainStructParent},
+ {"childRef", &DomainStructChild},
+ {"parentRef", &DomainStructParent},
{"field", &DomainStructParentField},
{"fieldRef", &DomainStructParentFieldRef},
{"typesystem", &Typesystem},