summaryrefslogtreecommitdiff
path: root/src/core/model/Document.cpp
diff options
context:
space:
mode:
authorBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-02-04 20:20:02 +0100
committerBenjamin Paassen <bpaassen@techfak.uni-bielefeld.de>2015-02-04 20:20:02 +0100
commitfce5cce5fdc7bd265eb023dfc0fc1accbe5a796e (patch)
treec745b76fc01ff7fa8c38c5810682c8878ade1fc1 /src/core/model/Document.cpp
parente76f58e912bd6661ba755d27da97bebf711f06ad (diff)
set non-empty default field name.
Diffstat (limited to 'src/core/model/Document.cpp')
-rw-r--r--src/core/model/Document.cpp28
1 files changed, 6 insertions, 22 deletions
diff --git a/src/core/model/Document.cpp b/src/core/model/Document.cpp
index 8c87cfe..f27da1d 100644
--- a/src/core/model/Document.cpp
+++ b/src/core/model/Document.cpp
@@ -34,31 +34,15 @@ int DocumentEntity::getFieldDescriptorIndex(const std::string &fieldName,
const NodeVector<FieldDescriptor> &fds = descriptor->getFieldDescriptors();
unsigned int f = 0;
- // look if we have an empty name.
- if (fieldName == "") {
- // in that case we look for a default field.
- // First: Do we only have one field?
- if (fds.size() == 1) {
- // if so we return that one.
+ // otherwise we return the FieldDescriptor with the correct name (if
+ // such a descriptor exists).
+ for (auto &fd : fds) {
+ if (fd->getName() == fieldName) {
return f;
}
- // Second: Do we have a TREE field?
- for (auto &fd : fds) {
- if (fd->getFieldType() == FieldDescriptor::FieldType::TREE) {
- return f;
- }
- f++;
- }
- } else {
- // otherwise we return the FieldDescriptor with the correct name (if
- // such a descriptor exists).
- for (auto &fd : fds) {
- if (fd->getName() == fieldName) {
- return f;
- }
- f++;
- }
+ f++;
}
+
if (enforce) {
throw OusiaException(std::string("\"") + descriptor->getName() +
"\" has no field with name \"" + fieldName + "\"");