summaryrefslogtreecommitdiff
path: root/src/core/parser
diff options
context:
space:
mode:
authorAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2015-03-31 23:42:12 +0200
committerAndreas Stöckel <astoecke@techfak.uni-bielefeld.de>2016-04-25 22:19:27 +0200
commitf1d5af1eeb96e56a2cf6fb92e1e71eeced118d81 (patch)
treedc18dd4a98a31eb06ae0368fb98c75eace4eafe9 /src/core/parser
parent648aa3b32fb75ced3a02bc32900901c4f33fb8be (diff)
Add getDescriptor method to DocumentField class
Diffstat (limited to 'src/core/parser')
-rw-r--r--src/core/parser/stack/DocumentHandler.cpp23
-rw-r--r--src/core/parser/stack/DocumentHandler.hpp5
2 files changed, 28 insertions, 0 deletions
diff --git a/src/core/parser/stack/DocumentHandler.cpp b/src/core/parser/stack/DocumentHandler.cpp
index 331fb0b..7a81186 100644
--- a/src/core/parser/stack/DocumentHandler.cpp
+++ b/src/core/parser/stack/DocumentHandler.cpp
@@ -52,6 +52,29 @@ bool DocumentHandler::startCommand(Variant::mapType &args)
void DocumentHandler::end() { scope().pop(logger()); }
+/* DocumentField */
+
+Rooted<FieldDescriptor> DocumentField::getDescriptor()
+{
+ // Fetch the FieldDescriptor from the parent node. The parent node should
+ // either be a structured entity or an annotation entity
+ Rooted<Managed> parent = getParent();
+ if (parent->isa(&RttiTypes::StructuredEntity)) {
+ return parent.cast<StructuredEntity>()
+ ->getDescriptor()
+ ->getFieldDescriptor(fieldIdx);
+ } else if (parent->isa(&RttiTypes::AnnotationEntity)) {
+ return parent.cast<AnnotationEntity>()
+ ->getDescriptor()
+ ->getFieldDescriptor(fieldIdx);
+ }
+
+ // Well, we never should get here
+ // TODO: Introduce macro for unreachable code?
+ assert(!"This should never be reached");
+ return nullptr;
+}
+
/* DocumentChildHandler */
DocumentChildHandler::DocumentChildHandler(const HandlerData &handlerData)
diff --git a/src/core/parser/stack/DocumentHandler.hpp b/src/core/parser/stack/DocumentHandler.hpp
index 47534fb..5157709 100644
--- a/src/core/parser/stack/DocumentHandler.hpp
+++ b/src/core/parser/stack/DocumentHandler.hpp
@@ -84,6 +84,11 @@ public:
: Node(mgr, parent), fieldIdx(fieldIdx), transparent(transparent)
{
}
+
+ /**
+ * Returns the FieldDescriptor represented by this DocumentField instance.
+ */
+ Rooted<FieldDescriptor> getDescriptor();
};
/**