]> git.mxchange.org Git - simgear.git/blobdiff - simgear/hla/HLAObjectClass.cxx
Windows versionhelpers.h support.
[simgear.git] / simgear / hla / HLAObjectClass.cxx
index aa9e7856f2889fc57dfc3fc7d182f3e8c4d9d4a9..2740eb029d461ad6e573cf90331d9d3dbcb0e8a8 100644 (file)
@@ -191,23 +191,42 @@ HLAObjectClass::setAttributePublicationType(unsigned index, HLAPublicationType p
     _attributeVector[index]._publicationType = publicationType;
 }
 
-HLADataElement::IndexPathPair
-HLAObjectClass::getIndexPathPair(const HLADataElement::StringPathPair& stringPathPair) const
+bool
+HLAObjectClass::getDataElementIndex(HLADataElementIndex& dataElementIndex, const std::string& path) const
 {
-    unsigned index = getAttributeIndex(stringPathPair.first);
+    if (path.empty()) {
+        SG_LOG(SG_NETWORK, SG_ALERT, "HLAObjectClass: failed to parse empty element path!");
+        return false;
+    }
+    std::string::size_type len = std::min(path.find_first_of("[."), path.size());
+    unsigned index = 0;
+    while (index < getNumAttributes()) {
+        if (path.compare(0, len, getAttributeName(index)) == 0)
+            break;
+        ++index;
+    }
     if (getNumAttributes() <= index) {
-        SG_LOG(SG_NETWORK, SG_ALERT, "HLAObjectClass::getIndexPathPair(\""
-               << HLADataElement::toString(stringPathPair)
-               << "\"): Could not resolve attribute \"" << stringPathPair.first
-               << "\" for object class \"" << getName() << "\"!");
+        SG_LOG(SG_NETWORK, SG_ALERT, "HLAObjectClass: faild to parse data element index \"" << path << "\":\n"
+               << "Attribute \"" << path.substr(0, len) << "\" not found in object class \""
+               << getName() << "\"!");
+        return false;
+    }
+    if (!getAttributeDataType(index)) {
+        SG_LOG(SG_NETWORK, SG_ALERT, "HLAObjectClass: faild to parse data element index \"" << path << "\":\n"
+               << "Undefined attribute data type in variant record data type \""
+               << getAttributeName(index) << "\"!");
+        return false;
     }
-    return HLADataElement::IndexPathPair(index, stringPathPair.second);
+    dataElementIndex.push_back(index);
+    return getAttributeDataType(index)->getDataElementIndex(dataElementIndex, path, len);
 }
 
-HLADataElement::IndexPathPair
-HLAObjectClass::getIndexPathPair(const std::string& path) const
+HLADataElementIndex
+HLAObjectClass::getDataElementIndex(const std::string& path) const
 {
-    return getIndexPathPair(HLADataElement::toStringPathPair(path));
+    HLADataElementIndex dataElementIndex;
+    getDataElementIndex(dataElementIndex, path);
+    return dataElementIndex;
 }
 
 bool