summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/parser/stack/DocumentHandler.cpp24
-rw-r--r--src/core/parser/stack/DocumentHandler.hpp22
2 files changed, 34 insertions, 12 deletions
diff --git a/src/core/parser/stack/DocumentHandler.cpp b/src/core/parser/stack/DocumentHandler.cpp
index 2be3008..34d4d17 100644
--- a/src/core/parser/stack/DocumentHandler.cpp
+++ b/src/core/parser/stack/DocumentHandler.cpp
@@ -54,6 +54,15 @@ void DocumentHandler::end() { scope().pop(logger()); }
/* DocumentField */
+DocumentField::DocumentField(Manager &mgr, Handle<Node> parent, size_t fieldIdx,
+ bool transparent, bool explicitField)
+ : Node(mgr, parent),
+ fieldIdx(fieldIdx),
+ transparent(transparent),
+ explicitField(explicitField)
+{
+}
+
Rooted<FieldDescriptor> DocumentField::getDescriptor()
{
// Fetch the FieldDescriptor from the parent node. The parent node should
@@ -166,11 +175,12 @@ void DocumentChildHandler::pushScopeTokens()
void DocumentChildHandler::pushDocumentField(Handle<Node> parent,
Handle<FieldDescriptor> fieldDescr,
- size_t fieldIdx, bool transparent)
+ size_t fieldIdx, bool transparent,
+ bool explicitField)
{
// Push the field onto the scope
- Rooted<DocumentField> field =
- new DocumentField(manager(), parent, fieldIdx, transparent);
+ Rooted<DocumentField> field = new DocumentField(manager(), parent, fieldIdx,
+ transparent, explicitField);
field->setLocation(location());
scope().push(field);
}
@@ -192,7 +202,7 @@ void DocumentChildHandler::createPath(const NodeVector<Node> &path,
parent->getDescriptor()->getFieldDescriptorIndex();
const Rooted<FieldDescriptor> fieldDescr =
parent->getDescriptor()->getFieldDescriptor(fieldIdx);
- pushDocumentField(scope().getLeaf(), fieldDescr, fieldIdx, true);
+ pushDocumentField(scope().getLeaf(), fieldDescr, fieldIdx, true, false);
// add the transparent/implicit structure element.
Rooted<StructuredEntity> transparent =
@@ -208,7 +218,7 @@ void DocumentChildHandler::createPath(const NodeVector<Node> &path,
const ssize_t fieldIdx = parent->getDescriptor()->getFieldDescriptorIndex();
const Rooted<FieldDescriptor> fieldDescr =
parent->getDescriptor()->getFieldDescriptor(fieldIdx);
- pushDocumentField(scope().getLeaf(), fieldDescr, fieldIdx, true);
+ pushDocumentField(scope().getLeaf(), fieldDescr, fieldIdx, true, false);
// Generally allow explicit fields in the new field
scope().setFlag(ParserFlag::POST_EXPLICIT_FIELDS, false);
@@ -325,7 +335,7 @@ bool DocumentChildHandler::startCommand(Variant::mapType &args)
parentNode,
parent->getDescriptor()->getFieldDescriptor(
newFieldIdx),
- newFieldIdx, false);
+ newFieldIdx, false, true);
pushScopeTokens();
isExplicitField = true;
return true;
@@ -682,7 +692,7 @@ bool DocumentChildHandler::fieldStart(bool &isDefault, size_t fieldIdx)
}
// push the field on the stack.
- pushDocumentField(parentNode, fields[fieldIdx], fieldIdx, false);
+ pushDocumentField(parentNode, fields[fieldIdx], fieldIdx, false, false);
pushScopeTokens();
// Generally allow explicit fields in the new field
diff --git a/src/core/parser/stack/DocumentHandler.hpp b/src/core/parser/stack/DocumentHandler.hpp
index 0a32267..75e32fd 100644
--- a/src/core/parser/stack/DocumentHandler.hpp
+++ b/src/core/parser/stack/DocumentHandler.hpp
@@ -73,17 +73,29 @@ public:
* Temporary Node that is being pushed onto the ParserScope in order to indicate
* the field the parser is currently in. The name of the Node is stored in the
* "name" field of the parent Node class.
+ *
+ * TODO: Invent some common base class for the DocumentField, StructuredEntity
+ * and AnnotationEntity classes.
*/
class DocumentField : public Node {
public:
const size_t fieldIdx;
const bool transparent;
+ const bool explicitField;
+ /**
+ * Constructor of the DocumentField class.
+ *
+ * @param mgr is the parent Manager instance.
+ * @param parent is the structure the field belongs to.
+ * @param fieldIdx is the index of the field within the parent fields.
+ * @param transparent is set to true if this field has been created as part
+ * of an implicitly created structure.
+ * @param explicitField is set to true if the field has been created as part
+ * of an explicit field reference.
+ */
DocumentField(Manager &mgr, Handle<Node> parent, size_t fieldIdx,
- bool transparent)
- : Node(mgr, parent), fieldIdx(fieldIdx), transparent(transparent)
- {
- }
+ bool transparent, bool explicitField);
/**
* Returns the FieldDescriptor represented by this DocumentField instance.
@@ -196,7 +208,7 @@ private:
*/
void pushDocumentField(Handle<Node> parent,
Handle<FieldDescriptor> fieldDescr, size_t fieldIdx,
- bool transparent);
+ bool transparent, bool explicitField);
/**
* Pops a DocumentField from the scope stack and retracts the permitted