diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-01-04 22:21:52 +0100 |
---|---|---|
committer | Andreas Stöckel <andreas@somweyr.de> | 2015-01-04 22:21:52 +0100 |
commit | 0d671f899da720ff5035bdab7adf6b11cbf80cb1 (patch) | |
tree | 9839d502ff323198d0f9cb479e9809a978c5c550 /src/core/model/Document.cpp | |
parent | 7e1c72a5a5d5dc890a49f79c5daec3edcb38a33b (diff) | |
parent | 319ad738f677a20403cc27192f1df7bb65ce8c0e (diff) |
Merge branch 'master' of somweyr.de:ousia
Diffstat (limited to 'src/core/model/Document.cpp')
-rw-r--r-- | src/core/model/Document.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/core/model/Document.cpp b/src/core/model/Document.cpp index 854e717..e5d0755 100644 --- a/src/core/model/Document.cpp +++ b/src/core/model/Document.cpp @@ -57,20 +57,22 @@ int DocumentEntity::getFieldDescriptorIndex(const std::string &fieldName) return -1; } -void DocumentEntity::getField(NodeVector<StructuredEntity> &res, - const std::string &fieldName) +NodeVector<StructuredEntity> &DocumentEntity::getField( + const std::string &fieldName) { int f = getFieldDescriptorIndex(fieldName); if (f < 0) { - NodeVector<StructuredEntity> empty{this}; - res = NodeVector<StructuredEntity>(this); + throw OusiaException("No field for the given name exists!"); } - res = fields[f]; + return fields[f]; } NodeVector<StructuredEntity> &DocumentEntity::getField( - Rooted<FieldDescriptor> fieldDescriptor) + Handle<FieldDescriptor> fieldDescriptor) { + if(fieldDescriptor.isNull()){ + throw OusiaException("The given FieldDescriptor handle is null!"); + } const NodeVector<FieldDescriptor> &fds = descriptor->getFieldDescriptors(); int f = 0; for (auto &fd : fds) { @@ -155,8 +157,7 @@ Rooted<StructuredEntity> StructuredEntity::buildEntity( return {nullptr}; } // append the new entity to the right field. - NodeVector<StructuredEntity> field(parent); - parent->getField(field, fieldName); + NodeVector<StructuredEntity>& field = parent->getField(fieldName); field.push_back(entity); // and return it. @@ -179,8 +180,7 @@ Rooted<DocumentPrimitive> DocumentPrimitive::buildEntity( return {nullptr}; } // append the new entity to the right field. - NodeVector<StructuredEntity> field(parent); - parent->getField(field, fieldName); + NodeVector<StructuredEntity>& field = parent->getField(fieldName); field.push_back(entity); // and return it. |