diff options
-rw-r--r-- | src/core/model/Document.cpp | 15 | ||||
-rw-r--r-- | src/core/model/Document.hpp | 12 |
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 |