diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2015-03-15 13:59:44 +0100 |
---|---|---|
committer | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2016-04-25 22:19:27 +0200 |
commit | 73aa1e763eeb631eaaf23c236d263832678314c4 (patch) | |
tree | 4e102dad0c725caebbb4dee055b79cc090d9e72c | |
parent | 2f394e84881ba663f1747a66891f994a54e5fdd4 (diff) |
Fix getFieldDescriptor with index ignoring inherited fields
-rw-r--r-- | src/core/model/Ontology.cpp | 12 | ||||
-rw-r--r-- | src/core/model/Ontology.hpp | 15 |
2 files changed, 14 insertions, 13 deletions
diff --git a/src/core/model/Ontology.cpp b/src/core/model/Ontology.cpp index bc7b1a7..0341df8 100644 --- a/src/core/model/Ontology.cpp +++ b/src/core/model/Ontology.cpp @@ -657,9 +657,17 @@ Rooted<FieldDescriptor> Descriptor::getFieldDescriptor( ssize_t idx = ousia::getFieldDescriptorIndex(fds, name); if (idx != -1) { return fds[idx]; - } else { - return nullptr; } + return nullptr; +} + +Rooted<FieldDescriptor> Descriptor::getFieldDescriptor(size_t idx) const +{ + NodeVector<FieldDescriptor> fds = getFieldDescriptors(); + if (idx < fds.size()) { + return fds[idx]; + } + return nullptr; } bool Descriptor::addAndSortFieldDescriptor(Handle<FieldDescriptor> fd, diff --git a/src/core/model/Ontology.hpp b/src/core/model/Ontology.hpp index 8d6e596..cb314cc 100644 --- a/src/core/model/Ontology.hpp +++ b/src/core/model/Ontology.hpp @@ -681,22 +681,15 @@ public: Rooted<FieldDescriptor> getFieldDescriptor( const std::string &name = DEFAULT_FIELD_NAME) const; - /** * Returns the FieldDescriptor with the given index. * - * @param index the index of the field that should be retrieved. + * @param idx the index of the field that should be retrieved. - * @return the FieldDescriptor with the given index or a nullptr if no - * such FieldDescriptor was found. + * @return the FieldDescriptor with the given index or a nullptr if no + * such FieldDescriptor was found. */ - Rooted<FieldDescriptor> getFieldDescriptor(size_t index) const - { - if (index < fieldDescriptors.size()) { - return fieldDescriptors[index]; - } - return nullptr; - } + Rooted<FieldDescriptor> getFieldDescriptor(size_t idx) const; /** * This returns true if this Descriptor has a FieldDescriptor with the |