summaryrefslogtreecommitdiff
path: root/src/core/parser/stack/DocumentHandler.hpp
diff options
context:
space:
mode:
authorBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-02-16 18:48:58 +0100
committerBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-02-16 18:48:58 +0100
commitf8c457674aaf1c6b1b3855ca9621ef2887b5100b (patch)
tree6b420206f09eacc9c33989a88377fffe297384d9 /src/core/parser/stack/DocumentHandler.hpp
parentfe1e817f29de61cdbc48dc4945dcfc235cf71a41 (diff)
completely reworked document handler to be consistent with OSML and provide more coherent behaviour in general.
Diffstat (limited to 'src/core/parser/stack/DocumentHandler.hpp')
-rw-r--r--src/core/parser/stack/DocumentHandler.hpp78
1 files changed, 65 insertions, 13 deletions
diff --git a/src/core/parser/stack/DocumentHandler.hpp b/src/core/parser/stack/DocumentHandler.hpp
index 2c474f9..5953e3a 100644
--- a/src/core/parser/stack/DocumentHandler.hpp
+++ b/src/core/parser/stack/DocumentHandler.hpp
@@ -76,29 +76,74 @@ public:
*/
class DocumentField : public Node {
public:
- using Node::Node;
+ const size_t fieldIdx;
+ const bool transparent;
+
+ DocumentField(Manager &mgr, Handle<Node> parent, size_t fieldIdx,
+ bool transparent)
+ : Node(mgr, parent), fieldIdx(fieldIdx), transparent(transparent)
+ {
+ }
};
/**
* The DocumentChildHandler class performs the actual parsing of the user
* defined elements in an Ousía document.
*/
-class DocumentChildHandler : public StaticHandler {
+class DocumentChildHandler : public Handler {
private:
+ bool isExplicitField = false;
+
/**
- * Code shared by both the start() and the end() method. Checks whether the
- * parser currently is in a field and returns the name of this field.
+ * Code shared by both the start(), fieldStart() and the data() method.
+ * Checks whether the parser currently is in a field and returns the name
+ * of this field.
*
* @param parentNode is the next possible parent node (a document,
* a structured entity, an annotation entity or a field).
- * @param fieldName is an output parameter to which the name of the current
+ * @param fieldIdx is an output parameter to which the index of the current
* field is written (or unchanged if we're not in a field).
* @param parent is an output parameter to which the parent document entity
* will be written.
- * @param inField is set to true if we actually are in a field.
*/
- void preamble(Handle<Node> parentNode, std::string &fieldName,
- DocumentEntity *&parent, bool &inField);
+ void preamble(Rooted<Node> &parentNode, size_t &fieldIdx,
+ DocumentEntity *&parent);
+
+ /**
+ * Creates transparent elements that are stored in the given path.
+ *
+ * @param path a NodeVector of alternating FieldDescriptors and
+ * StructuredClasses. For each of the StructuredClasses at
+ * index p an instance is created and added to the field at
+ * index p-1 of the previously created instance of the
+ * StructuredClass at index p-2.
+ * @param parent is the parent DocumentEntity for the first transparent
+ * element. This will be reset for each created transparent
+ * element.
+ * @param p0 is the index of the path vector of the first
+ * StructuredClass for which an instance shall be created.
+ * This is 1 per default.
+ */
+ void createPath(const NodeVector<Node> &path, DocumentEntity *&parent,
+ size_t p0 = 1);
+
+ /**
+ * Creates transparent elements that are stored in the given path.
+ *
+ * @param fieldIdx is the index of the field for which the first instance
+ * shall be added.
+ * @param path a NodeVector of alternating FieldDescriptors and
+ * StructuredClasses. For each of the StructuredClasses at
+ * index p an instance is created and added to the field at
+ * index p-1 of the previously created instance of the
+ * StructuredClass at index p-2. The first element has
+ * to be a StructuredClass.
+ * @param parent is the parent DocumentEntity for the first transparent
+ * element. This will be reset for each created transparent
+ * element.
+ */
+ void createPath(const size_t &fieldIdx, const NodeVector<Node> &path,
+ DocumentEntity *&parent);
/**
* Tries to convert the given data to the type that is specified in the
@@ -116,12 +161,22 @@ private:
Logger &logger);
public:
- using StaticHandler::StaticHandler;
+ using Handler::Handler;
bool start(Variant::mapType &args) override;
void end() override;
bool data(Variant &data) override;
+ bool fieldStart(bool &isDefault, size_t fieldIdx) override;
+
+ void fieldEnd() override;
+
+ bool annotationStart(const Variant &className,
+ Variant::mapType &args) override;
+
+ bool annotationEnd(const Variant &className,
+ const Variant &elementName) override;
+
/**
* Creates a new instance of the DocumentChildHandler.
*
@@ -146,7 +201,6 @@ extern const State Document;
*/
extern const State DocumentChild;
}
-
}
namespace RttiTypes {
@@ -155,8 +209,6 @@ namespace RttiTypes {
*/
extern const Rtti DocumentField;
}
-
}
-#endif /* _OUSIA_PARSER_STACK_DOCUMENT_HANDLER_HPP_ */
-
+#endif /* _OUSIA_PARSER_STACK_DOCUMENT_HANDLER_HPP_ */ \ No newline at end of file