summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-02-14 00:09:14 +0100
committerBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-02-14 00:09:14 +0100
commit9216a4eb4e2af997444cb7b7c3e4938b91edc4d9 (patch)
treef864f6ee29b267aa950e61186df589d66811af97
parentc6257435c8d09a672e16379731e8b75e0d01a82b (diff)
added DocumentEntity::getField with direct indexation.
-rw-r--r--src/core/model/Document.cpp15
-rw-r--r--src/core/model/Document.hpp12
2 files changed, 25 insertions, 2 deletions
diff --git a/src/core/model/Document.cpp b/src/core/model/Document.cpp
index b38f2c0..a2ba5cf 100644
--- a/src/core/model/Document.cpp
+++ b/src/core/model/Document.cpp
@@ -306,6 +306,18 @@ const NodeVector<StructureNode> &DocumentEntity::getField(
return fields[enforceGetFieldDescriptorIndex(descriptor, fieldDescriptor)];
}
+const NodeVector<StructureNode> &DocumentEntity::getField(
+ const size_t &idx) const
+{
+ if (idx >= fields.size()) {
+ throw OusiaException(std::string("Descriptor \"") +
+ descriptor->getName() +
+ "\" does not have enough fields for index \"" +
+ std::to_string(idx) + "\".");
+ }
+ return fields[idx];
+}
+
void DocumentEntity::addStructureNode(Handle<StructureNode> s, const int &i)
{
// only add the new node if we don't have it already.
@@ -813,5 +825,4 @@ const Rtti AnnotationEntity =
.parent(&Node)
.composedOf({&StructuredEntity, &DocumentPrimitive, &Anchor});
}
-}
-
+} \ No newline at end of file
diff --git a/src/core/model/Document.hpp b/src/core/model/Document.hpp
index bffd397..5f06eb0 100644
--- a/src/core/model/Document.hpp
+++ b/src/core/model/Document.hpp
@@ -237,6 +237,18 @@ public:
Handle<FieldDescriptor> fieldDescriptor) const;
/**
+ * This returns the vector of entities containing all members of the field
+ * with the given index.
+ *
+ * If the index is out of bounds an exception is thrown.
+ *
+ * @param idx is the index of a field as specified in the
+ * FieldDescriptor in the Domain description.
+ * @return a NodeVector of all StructuredEntities in that field.
+ */
+ const NodeVector<StructureNode> &getField(const size_t& idx ) const;
+
+ /**
* This adds a StructureNode to the field with the given index.
*
* This method also changes the parent of the newly added StructureNode if